pike.git / lib / modules / Calendar.pmod / mkrules.pike

version» Context lines:

pike.git/lib/modules/Calendar.pmod/mkrules.pike:666:    werror("Reading %O...\n",file);    string s=Stdio.read_bytes(file),t;    if (!s)    {    // NB: This file is often used with the system Pike, so    // it can't use %m yet.    werror("%s:-: Failed to open file: %s.\n", file, strerror(errno()));    return;    }    +  // Current (2017) tzdata files are in UTF-8. +  catch { +  s = utf8_to_string(s); +  }; +     Zone lastz;    MyRule lastr;       foreach (s/"\n",string line)    {    n++;    mixed err=catch    {    if (line[..0]!="#")    if (sscanf(line,"Zone%*[ \t]%[^ \t]%*[ \t]%s",s,t)==4)
pike.git/lib/modules/Calendar.pmod/mkrules.pike:722:   int main(int ac,array(string) am)   {    array(string) files = am[1..];    if (!sizeof(files))    {    werror("Defaulting to reading zonefiles from %s...\n",    combine_path(__DIR__, "tzdata"));    files = get_dir(combine_path(__DIR__, "tzdata"));    files = map(sort(files),    lambda(string fname) { -  if ((< ".gitignore", "Makefile", "Theory", +  if ((< ".gitignore", "Makefile", "Theory", "calendars",    "leapseconds", "version", >)[fname] ||    (upper_case(fname) == fname) ||    has_prefix(fname, "solar") ||    has_suffix(fname, ".awk") || -  +  has_suffix(fname, ".html") ||    has_suffix(fname, ".list") ||    has_suffix(fname, ".pl") ||    has_suffix(fname, ".sh") ||    has_suffix(fname, ".tab")) return 0;    return combine_path(__DIR__, "tzdata", fname);    }) - ({ 0 });    }    map(files, collect_rules);       write("Thinking...\n");    -  string t="#pike "+__MAJOR__+"."+__MINOR__+"\n\n" + TZrules_base; +  string t= "#charset utf-8\n" +  "#pike __REAL_VERSION__\n\n" + TZrules_base;       foreach (arules,MyRule r)    t+=r->dump();       tzrules=compile_string(t)();       mv("TZrules.pmod","TZrules.pmod~"); -  +  t = string_to_utf8(t);    werror("Writing TZrules.pmod (%d bytes)...",sizeof(t));    Stdio.File("TZrules.pmod","wtc")->write(t);    werror("\n");    -  t="// ----------------------------------------------------------------\n" +  t= "#charset utf-8\n" +  "#pike __REAL_VERSION__\n" +  "// ----------------------------------------------------------------\n"    "// Timezones\n"    "//\n" -  "// NOTE: this file is generated by mkrules.pike;\n" +  "// NOTE: This file is generated by mkrules.pike;\n"    "// please do not edit manually /Mirar\n"    "// ----------------------------------------------------------------\n"    "\n"    "import \".\";\n\n";       t+=("// "+"-"*70+"\n"    "// Timezones\n"    "// "+"-"*70+"\n\n");       mixed err=catch {
pike.git/lib/modules/Calendar.pmod/mkrules.pike:800:    FIXID(z->id)+";\n";    t+="\n";    }    };    if (err) if (stringp(err)) error(err); else throw(err);       t+=("\n"    "// "+"-"*70+"\n");       mv("TZs.h","TZs.h~"); +  t = string_to_utf8(t);    werror("Writing TZs.h (%d bytes)...",sizeof(t));    Stdio.File("TZs.h","wtc")->write(t);    werror("\n");       mapping zs=([]);    foreach (azones,Zone z)    if (sscanf(z->id,"%s/%s",string s,string t)==2)    zs[s]=(zs[s]||({}))+({t});       // Read and parse the original TZnames.pmod file.    string orig_names = Stdio.read_bytes("TZnames.pmod"); -  +  catch { +  orig_names = utf8_to_string(orig_names); +  };    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";       multiset(string) zone_names = (multiset)indices(zs);
pike.git/lib/modules/Calendar.pmod/mkrules.pike:882:    " \n",    " \n",    " \n",    " \n",    " \n",    " \n", }), ({ "\n" })*8)) != t2) {    t2 = t;    }       mv("TZnames.pmod","TZnames.pmod~"); +  t = string_to_utf8(t);    werror("Writing TZnames.pmod (%d bytes)...",sizeof(t));    Stdio.File("TZnames.pmod","wtc")->write(t);    werror("\n");       return 0;   }         string TZrules_base=   #"// ---------------------------------------------------------------- - // Daylight savings and war time rules + // Daylight-saving and war time rules   //   // NOTE: this file is generated by mkrules.pike;   // please do not edit manually /Mirar   // ----------------------------------------------------------------      // ----------------------------------------------------------------   // all rules are based on the gregorian calendar, so   // this is the gregorian rule:   // ----------------------------------------------------------------