scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 1#!/bin/sh
 2
 3cat <<EOF
 4#include <stdlib.h>
 5#include <string.h>
 6#include <time.h>
 7
 8#include "../libc.h"
 9
10`
11awk '{
12	zones[$1] = 1
13	if (length($1) > max)
14		max = length($1)
15	nr++
16}
17END {
18	printf("#define MAX %d\n", max+1);
19	printf("#define NR %d\n", nr);
20	print("static char tzones[NR][MAX] = {");
21	for (z in zones)
22		printf("\t\\"%s\\",\n", z) | "sort"
23	close("sort")
24	print "};\n"
25}' "$@"`
26
27static int
28cmp(const void *ps1, const void *ps2)
29{
30	const char *s1 = ps1, *s2 = ps2;
31
32	return strcmp(s1, s2);
33}
34
35char *
36_gmtoff(char *tz)
37{
38	return bsearch(tz, tzones, NR, MAX, cmp);
39}
40EOF