pike.git / lib / modules / Calendar.pmod / tzdata / zishrink.awk

version» Context lines:

pike.git/lib/modules/Calendar.pmod/tzdata/zishrink.awk:13:    if (used_hashes[n]) {    printf "# ! collision: %s %s\n", used_hashes[n], name    exit 1    }    used_hashes[n] = name   }      # Return a shortened rule name representing NAME,   # and record this relationship to the hash table.    - function gen_rule_name(name, n) + function gen_rule_name(name, \ +  n)   {    # Use a simple memonic: the first two letters.    n = substr(name, 1, 2)    record_hash(n, name)    # printf "# %s = %s\n", n, name    return n   }    - function prehash_rule_names(name) + function prehash_rule_names( \ +  name)   {    # Rule names are not part of the tzdb API, so substitute shorter    # ones. Shortening them consistently from one release to the next    # simplifies comparison of the output. That being said, the    # 1-letter names below are not standardized in any way, and can    # change arbitrarily from one release to the next, as the main goal    # here is compression not comparison.       # Abbreviating these rules names to one letter saved the most space    # circa 2018e.
pike.git/lib/modules/Calendar.pmod/tzdata/zishrink.awk:141:    rule["Vanuatu"] = "VU"       # Avoid collisions.    rule["Detroit"] = "Dt" # De = Denver       for (name in rule) {    record_hash(rule[name], name)    }   }    - # Process an input line and save it for later output. + # Process the input line LINE and save it for later output.    - function process_input_line(line, field, end, i, n, startdef) + function process_input_line(line, \ +  field, end, i, n, startdef, \ +  linkline, ruleline, zoneline)   {    # Remove comments, normalize spaces, and append a space to each line.    sub(/#.*/, "", line)    line = line " "    gsub(/[\t ]+/, " ", line)    -  # Abbreviate keywords. Do not abbreviate "Link" to just "L", -  # as pre-2017c zic erroneously diagnoses "Li" as ambiguous. -  sub(/^Link /, "Li ", line) -  sub(/^Rule /, "R ", line) -  sub(/^Zone /, "Z ", line) +  # Abbreviate keywords and determine line type. +  linkline = sub(/^Link /, "L ", line) +  ruleline = sub(/^Rule /, "R ", line) +  zoneline = sub(/^Zone /, "Z ", line)       # SystemV rules are not needed.    if (line ~ /^R SystemV /) return       # Replace FooAsia rules with the same rules without "Asia", as they    # are duplicates.    if (match(line, /[^ ]Asia /)) { -  if (line ~ /^R /) return +  if (ruleline) return    line = substr(line, 1, RSTART) substr(line, RSTART + 5)    }       # Abbreviate times.    while (match(line, /[: ]0+[0-9]/))    line = substr(line, 1, RSTART) substr(line, RSTART + RLENGTH - 1)    while (match(line, /:0[^:]/))    line = substr(line, 1, RSTART - 1) substr(line, RSTART + 2)    -  # Abbreviate weekday names. Do not abbreviate "Sun" and "Sat", as -  # pre-2017c zic erroneously diagnoses "Su" and "Sa" as ambiguous. +  # Abbreviate weekday names.    while (match(line, / (last)?(Mon|Wed|Fri)[ <>]/)) {    end = RSTART + RLENGTH    line = substr(line, 1, end - 4) substr(line, end - 1)    } -  while (match(line, / (last)?(Tue|Thu)[ <>]/)) { +  while (match(line, / (last)?(Sun|Tue|Thu|Sat)[ <>]/)) {    end = RSTART + RLENGTH    line = substr(line, 1, end - 3) substr(line, end - 1)    }    -  # Abbreviate "max", "only" and month names. -  # Do not abbreviate "min", as pre-2017c zic erroneously diagnoses "mi" -  # as ambiguous. +  # Abbreviate "max", "min", "only" and month names.    gsub(/ max /, " ma ", line) -  +  gsub(/ min /, " mi ", line)    gsub(/ only /, " o ", line)    gsub(/ Jan /, " Ja ", line)    gsub(/ Feb /, " F ", line)    gsub(/ Apr /, " Ap ", line)    gsub(/ Aug /, " Au ", line)    gsub(/ Sep /, " S ", line)    gsub(/ Oct /, " O ", line)    gsub(/ Nov /, " N ", line)    gsub(/ Dec /, " D ", line)   
pike.git/lib/modules/Calendar.pmod/tzdata/zishrink.awk:214:    # Remove unnecessary trailing days-of-month "1".    if (match(line, /[A-Za-z] 1$/))    line = substr(line, 1, RSTART)       # Remove unnecessary trailing " Ja" (for January).    sub(/ Ja$/, "", line)       n = split(line, field)       # Abbreviate rule names. -  i = field[1] == "Z" ? 4 : field[1] == "Li" ? 0 : 2 +  i = zoneline ? 4 : linkline ? 0 : 2    if (i && field[i] ~ /^[^-+0-9]/) {    if (!rule[field[i]])    rule[field[i]] = gen_rule_name(field[i])    field[i] = rule[field[i]]    }       # If this zone supersedes an earlier one, delete the earlier one    # from the saved output lines.    startdef = "" -  if (field[1] == "Z") +  if (zoneline)    zonename = startdef = field[2] -  else if (field[1] == "Li") +  else if (linkline)    zonename = startdef = field[3] -  else if (field[1] == "R") +  else if (ruleline)    zonename = ""    if (startdef) {    i = zonedef[startdef]    if (i) {    do    output_line[i - 1] = ""    while (output_line[i++] ~ /^[-+0-9]/);    }    }    zonedef[zonename] = nout + 1       # Save the line for later output.    line = field[1]    for (i = 2; i <= n; i++)    line = line " " field[i]    output_line[nout++] = line   }    - function output_saved_lines(i) + function output_saved_lines( \ +  i)   {    for (i = 0; i < nout; i++)    if (output_line[i])    print output_line[i]   }      BEGIN {    # Files that the output normally depends on.    default_dep["africa"] = 1    default_dep["antarctica"] = 1