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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/mkrules.pike:18:   object nleapy=Year(1999);      object tzrules; // needed to make timezones, compiled below      mapping rules=([]);   mapping zones=([]);   mapping links=([]);   array arules=({});   array azones=({});    - mapping(string:array(string)) abbr2zones = ([ -  "DFT":({ "Europe/Oslo", "Europe/Paris" }), -  "NFT":({ "Europe/Oslo", "Europe/Paris" }), + mapping(string:mapping(int:array(string))) abbr2zones = ([ +  "DFT":([ 0x7fffffff:({ "Europe/Oslo", "Europe/Paris" }), ]), +  "NFT":([ 0x7fffffff:({ "Europe/Oslo", "Europe/Paris" }), ]),   ]);      #define FIXED(D) (yjd+((D)-1))   #define FIX_L(D) (yjd+leap+((D)-1))   #define LDAY(D,W) (yjd+((D)-1)-( (yjd+((D)+(8-W)-1)) % 7))   #define LDAYL(D,W) (yjd+((D)-1)+leap-( (yjd+leap+((D)+(8-W)-1)) % 7))      #define FIXID(id) replace(id,"/-+"/1,"__p"/1)    -  + void add_abbr(string abbr, string zone, int until) + { +  mapping(int:array(string)) zones = abbr2zones[abbr]; +  if (!zones) abbr2zones[abbr] = zones = ([]); +  zones[until] += ({ zone }); + } +    int parse_offset(string t)   {    int h,m,s;    string res;       if (t=="0") return 0;       res="";    if (sscanf(t,"-%d:%d:%d%s",h,m,s,res)&&res=="")    return -(h*3600+m*60+s);
pike.git/lib/modules/Calendar.pmod/mkrules.pike:479:       a=({parse_offset(a[0]), // offset    a[1], // rule or added offset    a[2], // string    a[3],    0, 0, "tz", 0}); // until    a[5]=rule_shift(a);    a[4]=clone_rule(a);       if (sizeof(a[2])) { +  int until = (a[5] == "forever")?0x7fffffff:(int)a[5];    foreach(a[2]/"/", string fmt) {    MyRule rule = global::rules[a[1]];    if (rule) {    foreach(indices(rule->symbols), string sym) {    if ((sizeof(sym) > 2) && (fmt != "%s")) continue; -  abbr2zones[sprintf(fmt, sym)] += ({ id }); +  add_abbr(sprintf(fmt, sym), id, until);    }    } else if (a[1] == "Romania") {    // Kludge for forward reference in tzdata2012c/europe    // for Europe/Chisinau to the Romania rule.    foreach(({ "", "S" }), string sym) { -  abbr2zones[sprintf(fmt, sym)] += ({ id }); +  add_abbr(sprintf(fmt, sym), id, until);    }    } else { -  abbr2zones[fmt] += ({ id }); +  add_abbr(fmt, id, until);    }    }    }       rules+=({a});    }       string clone_rule(array a)    {    int h,m,s,roff=-17;
pike.git/lib/modules/Calendar.pmod/mkrules.pike:855:    if (sizeof(fragments) == 1) fragments = t/" abbr2zones =";    if (sizeof(fragments) > 2)    fragments = ({ fragments[0], fragments[1..] * " abbr2zones =" });    fragments[1] = (fragments[1]/"]);\n\n")[1..]*"]);\n\n";       t = fragments[0] + " abbr2zones =\n"    "([\n";       foreach(sort(indices(abbr2zones)), string abbr) {    string line = sprintf(" %q: ({", abbr); -  foreach(sort(Array.uniq(abbr2zones[abbr])); int i; string zone) { +  +  mapping(int:array(string)) info = abbr2zones[abbr]; +  array(string) zones = ({}); +  array(int) until = ({}); +  foreach(info; int us; array(string) zs) { +  zones += zs; +  until += allocate(sizeof(zs), -us); +  } +  // Sort so that the most recent use comes first, +  // and secondarily on the zone name. +  sort(zones, until); +  sort(until, zones); +  foreach(Array.uniq(zones); int i; string zone) {    string seg = sprintf("%s%q", i?", ":"", zone);    if (sizeof(line) + sizeof(seg) < 77) {    line += seg;    continue;    }    t += line + ",\n";    line = sprintf(" %q", zone);    }    t += line + "}),\n";    }