Branch: Tag:

2009-05-12

2009-05-12 12:03:41 by Henrik Grubbström (Grubba) <grubba@grubba.org>

mkrules.pike now knows about how to update TZnames.pmod with minimal breakage.

Rev: lib/modules/Calendar.pmod/mkrules.pike:1.14

10:   // and zic(8) is the usual compiler.      // pike mkrules.pike ../data/{africa,antarctica,asia,australasia,backward,etcetera,europe,northamerica,pacificnew,southamerica,systemv} - // $Id: mkrules.pike,v 1.13 2008/06/28 19:59:36 nilsson Exp $ + // $Id: mkrules.pike,v 1.14 2009/05/12 12:03:41 grubba Exp $      #pike __REAL_VERSION__   
771:    if (sscanf(z->id,"%s/%s",string s,string t)==2)    zs[s]=(zs[s]||({}))+({t});    -  t="// ----------------------------------------------------------------\n" -  "// Timezone names\n" -  "//\n" -  "// NOTE: this file is generated by mkrules.pike;\n" -  "// please do not edit manually /Mirar\n" -  "// ----------------------------------------------------------------\n" -  "\n" -  "mapping _module_value=\n" +  // Read and parse the original TZnames.pmod file. +  string orig_names = Stdio.read_bytes("TZnames.pmod"); +  array(string) fragments = orig_names/" zones="; +  if (sizeof(fragments) == 1) fragments = orig_names/" zones ="; +  if (sizeof(fragments) > 2) +  fragments = ({ fragments[0], fragments[1..] * " zones =" }); +  fragments[1] = (fragments[1]/"]);\n\n")[1..]*"]);\n\n"; +  +  t = fragments[0] + " zones =\n"    "([\n"; -  foreach (indices(zs)-({"SystemV","Etc"}),string co) +  +  multiset(string) zone_names = (multiset)indices(zs); +  +  zone_names->SystemV = 0; +  zone_names->Etc = 0; +  +  // Historical ordering... +  foreach (({"America", "Pacific", "Antarctica", "Atlantic", "Indian", +  "Europe", "Africa", "Asia", "Australia" }), string co) {    t+=(replace(    sprintf(" %-13s({%-=63s\n",    sprintf("%O:",co),    map(zs[co],lambda(string s) { return sprintf("%O",s); })    *", "+"}),"),({", ",", "}),",,"/1)); -  t+="]);\n\n"; +  zone_names[co] = 0; +  } +  // Take care of any remaining zones (probably none). +  foreach (sort(indices(zone_names)),string co) +  t+=(replace( +  sprintf(" %-13s({%-=63s\n", +  sprintf("%O:",co), +  map(zs[co],lambda(string s) { return sprintf("%O",s); }) +  *", "+"}),"),({", ",", "}),",,"/1)); +  t += "]);\n\n" + +  fragments[1];    -  mv("TZnames.pike","TZnames.pike~"); +  mv("TZnames.pmod","TZnames.pmod~");    werror("writing TZnames.pmod (%d bytes)...",sizeof(t));    Stdio.File("TZnames.pmod","wtc")->write(t);    werror("\n");