gentz (577B)
1 #!/bin/sh 2 3 cat <<EOF 4 #include <stdlib.h> 5 #include <string.h> 6 #include <time.h> 7 8 #include "../libc.h" 9 10 ` 11 awk '{ 12 zones[$1] = 1 13 if (length($1) > max) 14 max = length($1) 15 nr++ 16 } 17 END { 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 27 static int 28 cmp(const void *ps1, const void *ps2) 29 { 30 const char *s1 = ps1, *s2 = ps2; 31 32 return strcmp(s1, s2); 33 } 34 35 char * 36 _gmtoff(char *tz) 37 { 38 return bsearch(tz, tzones, NR, MAX, cmp); 39 } 40 EOF