- updated modpost script for compressed kernel modules

--- scripts/modpost.awk
+++ scripts/modpost.awk
@@ -901,6 +901,7 @@
 		}
 		print_debug(1,pfx "module = " $0)
 		sub(/(\.mod)?\.(k)?o(\.gz)?$/, "")
+		sub("^" me "." PROCINFO["pid"] ".modules/", "")
 		if (own == values["pkgdirectory"]) {
 		    sub(/.*\//, "")
 		    $0 = values["pkgdirectory"] "/" $0
@@ -1140,15 +1141,68 @@
     close(command)
     print_vinfo(1,"r: dumpfiles, syms " count_syms ", unds " count_unds)
 }
-function read_moduledir(directory, src,	    dir,command)
+function read_moduledir(directory, src,	    dir,command,find,file,tmpdir,dirs,written)
 {
     print_vinfo(1,"r: moduledir, directory = \"" directory "\"")
+    tmpdir = me "." PROCINFO["pid"] ".modules"
+    system_command("mkdir -p -- " tmpdir)
     dir = "kernel"
-    command = "find " directory "/" dir " -type f -name '*.ko' 2>/dev/null | xargs -r objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
-    read_modobject(command, dir, "kernel", src)
+    find = "find " directory "/" dir " -type f \\( -name '*.ko' -o -name '*.ko.gz' \\) 2>/dev/null"
+    if (system("test -d " directory "/" dir) == 0) {
+	system_command("rm -f -- " tmpdir "/modules.list 2>/dev/null")
+	written = 0
+	while ((find | getline file) == 1) {
+	    if (file~/\.ko\.gz$/) {
+		dir = tmpdir "/" file
+		sub(/\/[^\/]*$/, "", dir)
+		if (!(dir in dirs)) {
+		    system_command("mkdir -p -- " dir)
+		    dirs[dir] = 1
+		}
+		sub(/\.ko\.gz$/, ".ko", file)
+		system_command("gzip -dc " file ".gz >" tmpdir "/" file)
+		print tmpdir "/" file >> tmpdir "/modules.list"
+	    } else {
+		print file >> tmpdir "/modules.list"
+	    }
+	    written = 1
+	}
+	close(find)
+	if (written) {
+	    close(tmpdir "/modules.list")
+	    command = "cat " tmpdir "/modules.list | xargs -r objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
+	    read_modobject(command, dir, "kernel", src)
+	}
+    }
     dir = values["pkgdirectory"]
-    command = "find " directory "/" dir " -type f -name '*.ko' 2>/dev/null | xargs -r objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
-    read_modobject(command, dir, values["pkgdirectory"], "pkgdirectory")
+    find = "find " directory "/" dir " -type f \\( -name '*.ko' -o -name '*.ko.gz' \\) 2>/dev/null"
+    if (system("test -d " directory "/" dir) == 0) {
+	system_command("rm -f -- " tmpdir "/modules.list 2>/dev/null")
+	written = 0
+	while ((find | getline file) == 1) {
+	    if (file~/\.ko\.gz$/) {
+		dir = tmpdir "/" file
+		sub(/\/[^\/]*$/, "", dir)
+		if (!(dir in dirs)) {
+		    system_command("mkdir -p -- " dir)
+		    dirs[dir] = 1
+		}
+		sub(/\.ko\.gz$/, ".ko", file)
+		system_command("gzip -dc " file ".gz >" tmpdir "/" file)
+		print tmpdir "/" file >> tmpdir "/modules.list"
+	    } else {
+		print file >> tmpdir "/modules.list"
+	    }
+	    written = 1
+	}
+	close(find)
+	if (written) {
+	    close("modules.list")
+	    command = "cat modules.list | xargs -r objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
+	    read_modobject(command, dir, values["pkgdirectory"], "pkgdirectory")
+	}
+    }
+    system_command("rm -rf -- " tmpdir)
 }
 function read_mymodules(modules, src,    i,pair,ind,base,name,sym,fmt) {
     fmt = "r: mymodules, %-20s: %14s; %-30s"
@@ -1156,9 +1210,11 @@
     for (i = 1; i in modules; i++)
 	print modules[i] > "modvers.list"
     close("modvers.list")
-    command = "cat modvers.list | xargs objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
+    #command = "cat modvers.list | xargs -r objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
+    command = "cat modvers.list | while read f ; do case $f in (*.ko) echo $f ;; (*.ko.gz) gzip -dc $f >/var/tmp/`basename $f .gz` ; echo /var/tmp/`basename $f .gz` ;; esac ; done | xargs -r objdump -t -j '*ABS*' -j '*UND*' -j __ksymtab -j __ksymtab_gpl -j __versions -j .init.text -j .exit.text -s"
     read_modobject(command, ".", values["pkgdirectory"], src)
     system("rm -f modvers.list")
+    system("rm -f /var/tmp/*.ko")
     # double check
     for (pair in mod_unds) {
 	split(pair, ind, SUBSEP); name = ind[1]; sym = ind[2]; base = name; gsub(/^.*\//, "", base)


adding in capability of no wobble / just exact duplicates


second

second

--- project.awk
+++ project.awk
@@ -33,7 +33,7 @@

 BEGIN {

-  while ((C = getopt(ARGC, ARGV, "abicxhp:d:m:r:s:")) != -1) {
+  while ((C = getopt(ARGC, ARGV, "abicxhp:d:m:s:")) != -1) {
       opts++
       if(C == "p")                 #  -p <project>   Use project name. No default.
         pid = verifypid(Optarg)
@@ -41,10 +41,6 @@
         did = verifyval(Optarg)
       if(C == "m")                 #  -m <data dir>  Meta directory. Defaults to default.meta in project.cfg
         mid = verifyval(Optarg)
-      if(C == "r") {               #  -r <date>      Retrieve list of articles edited by Cyberbot during day 20160214
-        type = "retrieve"
-        year = verifyval(Optarg)
-      }
       if(C == "c")                 #  -c             Create project files. -p required
         type = "create"
       if(C == "i")                 #  -i             Create index from data directory. -p required
@@ -101,11 +97,6 @@
     exit
   }

-  if(type ~ /retrieve/) {
-    getcatbirths(year,mid)
-    exit
-  }
-
   if(type ~ /delete/) {
     deleteproject(pid,mid,did)
     exit
@@ -136,22 +127,10 @@
     sys2var(Exe["mkdir"] " " mid pid)
     checkexists(mid pid, "project.awk", "exit")
   }
-#  if(checkexists(mid pid "/db"))
-#    print "tc.in directory already exists: " mid pid "/db"
-#  else {
-#    print "OK Creating " mid pid "/db"
-#    sys2var(Exe["mkdir"] " " mid pid "/db")
-#    checkexists(mid pid "/db", "project.awk", "exit")
-#  }

  # Write new project.cfg

   # Remove leading and trailing blank lines
-  # https://stackoverflow.com/questions/7359527/removing-trailing-starting-newlines-with-sed-awk-tr-and-friends
-  # $AWK '{ LINES=LINES $0 "\n"; } /./ { printf "%s", LINES; LINES=""; }' "$SHAREDIR"article.txt | $SED '/./,$\!d' > "$SHAREDIR""o"
-  # command = Exe["awk"] " '{ LINES=LINES $0 \"\\n\"; } /./ { printf \"%s\", LINES; LINES=\"\"; }' " Home "project.cfg | " Exe["sed"] " '/./,$!d' > " Home "project.cfg.orig"
-  # sys2var(command)
-  # system("")
   print stripfile(Home "project.cfg") > Home "project.cfg.orig"
   close(Home "project.cfg.orig")
   print "OK Saving project.cfg to project.cfg.orig"
@@ -267,39 +246,6 @@

 }

-#
-# Download full list of names in [[Category:#### births]] to births####.auth in the Meta directory
-#
-function getcatbirths(year,mid,   a) {
-
-  if(year ~ /^[0-9]{4}$/) {
-
-    # wget -q -O- "https://tools.wmflabs.org/ext-lnk-discover/sc/sc.php?category=1840_births" | \
-    # grep '
' | awk '{c=split($0,a,/
/); while(i++ < c){if(a[i] != "") print a[i]} }' | \
-    # sort > births1840.auth
-
-    command = Exe["wget"] " -q -O- \"https://tools.wmflabs.org/ext-lnk-discover/sc/sc.php?category=" year "_births\" | " Exe["grep"] " '
' | " Exe["awk"] " '{c=split($0,a,/
/); while(i++ < c){if(a[i] != \"\") print a[i]} }' | " Exe["sort"] " > " mid "births" year ".auth"
-    sys2var(command)
-    print "OK Created " mid "births" year ".auth"
-    command = Exe["wc"] " -l " mid "births" year ".auth"
-    split(sys2var(command), a, " ")
-    if(int(a[1]) > 999) a[1] = a[1]
-    else if(int(a[1]) < 1000 && int(a[1]) > 99) a[1] = "0" a[1]
-    else if(int(a[1]) < 100 && int(a[1]) > 9) a[1] = "00" a[1]
-    else if(int(a[1]) < 10 && int(a[1]) > 0) a[1] = "000" a[1]
-    else a[1] = "error"
-
-    print "sed 's/PNAME/births" year ".0001-" a[1] "/g' 0INSTRUCTIONS > 0INSTRUCTIONS." year
-
-    # print "Suggested Project: births" year ".0001-" a[1]
-  }
-  else {
-    print "Unable to determine year: " year
-    exit
-  }
-
-}
-
 function deleteproject(pid,mid,did,    i,c,re,a) {

  # Delete Data and Meta directories
@@ -386,7 +332,9 @@
   }
 }

-
+#
+# Search for string "re" in <filename> across entire project
+#
 function check_string(filename, pid, did, mid,    re,c,files,stampdir,i,command,count) {

  # Be careful with escaping as unsure how grep responds
@@ -422,7 +370,6 @@
     print("Error unable to find " filepath ". " name )
     return 0
   }
-#  re = "^" regesc(strip(name)) "$"
   re = name
   while ((getline s < filepath ) > 0) {
     split(s, a, "|")
@@ -443,7 +390,6 @@
   print "Project - manage projects."
   print ""
   print "Usage:"
-  print "       -r <date>      Download list of articles edited by Cyberbot during 20160214"
   print "       -i             Create index from ~/data files. -p required"
   print "       -c             Create project files. -p required"
   print "       -x             Delete project files. -p required"
@@ -455,10 +401,6 @@
   print "       -a             Find all fixemptyarchive"
   print "       -h             Help"
   print ""
-  print "Examples: project -x -p cb14feb16"
-  print "          project -c -d /mnt/data/ -m /mnt/meta/ -p cb14feb16"
-  print "          project -r 20160214"
-  print ""
   print "Path names for -d and -m end with trailing slash."
   print ""


Translate: enlarge timeout to 1000ms

Translate: enlarge timeout to 1000ms

--- include/Translate.awk
+++ include/Translate.awk
@@ -78,7 +78,7 @@
     }

     # How long to wait in milliseconds for IPv6 before trying IPv4
-    PROCINFO[HttpService, "READ_TIMEOUT"] = 300
+    PROCINFO[HttpService, "READ_TIMEOUT"] = 1000
 }

 # Pre-process string (URL-encode before send).


use GLOBAL TT to label qc graph

use GLOBAL TT to label qc graph

--- scripts/label_dot_edge.awk
+++ scripts/label_dot_edge.awk
@@ -1,34 +1,37 @@
 #! /usr/bin/gawk -f

 # label_dot_edge.awk
-# Attempts to augment opaque ontological terms with their current label
+# Augment ontological terms with their label
 # example usage:
-# label_dot_edge.awk predicate_curie_term_label.tab  in.dot > out.dot
+# ${DIPPER}/scripts/label_dot_edge.awk
+#	${DIPPER}/translationtable/GLOBAL_TERMS.yaml  in.dot > out.dot
 #
 # Arguments: two files
-# Loads the first file as a map from terms to labels:
-# (expects: [namespace:]<tab><term><tab><label>[<tab><whatever>])
-# the first set was generated via cypher queries against our scigraph
-# (neo4j) instance loaded with the ontologies we use.
+# Loads the first file as a map from  to curie to label :
+ # (expects: "label": "curie",)
 # Reads the second Graphviz digraph dot format file:
 # looks for <term> as edge-text
 # and appends "! <label> (Iff <term> is found in map)
 # note: This "<term> ! <label>" structure is a convention used by Ontologists.

-BEGIN{FS="\t"; OFS="\t"}
+BEGIN{FS="\""; OFS="\t"}
 # load labels
-FNR == NR && $3 != "null"{label[$1 $2]=$3}
+FNR == NR && /^"/{label[$4]=$2}

 # output lines that do not get labels
 FNR != NR && !/.* -> .*label=.*/ {print}

 # output lines w/labels if they are available
+
 FNR != NR && /.* -> .*label=.*/ {
 	line="";
 	split($0, row, / /)
+
 	split(row[4], term, /"/)
-	if (term[2] in label){
+	split(term[2], lclid, ":")
+
+	if (term[2] in label && lclid[2] != label[term[2]]){
 		term[2] = term[2] " ! " label[term[2]];
 		row[4] = term[1];
 		for(i=2;i<=length(term);i++)


Help: show proxy and user-agent in getVersion()

--- include/Help.awk
+++ include/Help.awk
@@ -28,6 +28,10 @@
         sprintf("%-22s%s\n", "home language", Option["hl"])             \
         sprintf("%-22s%s\n", "source language", Option["sl"])           \
         sprintf("%-22s%s\n", "target language", join(Option["tl"], "+")) \
+        sprintf("%-22s%s\n", "proxy", Option["proxy"] ? Option["proxy"] :
+                "[NONE]")                                               \
+        sprintf("%-22s%s\n", "user-agent", Option["user-agent"] ? Option["user-agent"] :
+                "[NONE]")                                               \
         sprintf("%-22s%s\n", "theme", Option["theme"])                  \
         sprintf("%-22s%s\n", "init file", InitScript ? InitScript : "[NONE]") \
         sprintf("\n%-22s%s", "Report bugs to:", "https://github.com/soimort/translate-shell/issues")


Utils: pass proxy to curl

Utils: pass proxy to curl

--- include/Utils.awk
+++ include/Utils.awk
@@ -151,6 +151,8 @@
     }

     command = Curl " --location --silent"
+    if (Option["proxy"])
+        command = command " --proxy " parameterize(Option["proxy"])
     if (Option["user-agent"])
         command = command " --user-agent " parameterize(Option["user-agent"])
     command = command " " parameterize(url)
@@ -176,6 +178,8 @@
     }

     command = Curl " --location --silent"
+    if (Option["proxy"])
+        command = command " --proxy " parameterize(Option["proxy"])
     if (Option["user-agent"])
         command = command " --user-agent " parameterize(Option["user-agent"])
     command = command " --request POST --data " parameterize(data)


Translate: add translateMain()

Translate: add translateMain()

--- lib/Translate.awk
+++ lib/Translate.awk
@@ -207,3 +207,25 @@
     }
     PROCINFO["sorted_in"] = saveSortedIn
 }
+
+# Read from input and translate each line.
+function translateMain(    i, line) {
+    if (Option["interactive"])
+        prompt()
+
+    i = 0
+    while (getline line < Option["input"]) {
+        # Non-interactive verbose mode: separator between sources
+        if (!Option["interactive"])
+            if (Option["verbose"] && i++ > 0)
+                print replicate("═", Option["width"])
+
+        translate(line)
+
+        # Interactive verbose mode: newline after each translation
+        if (Option["interactive"]) {
+            if (Option["verbose"]) printf "\n"
+            prompt()
+        }
+    }
+}


Update filter_en_uk.awk

Update filter_en_uk.awk

Added every key of the basic en uk keyboard and removed ugly hacks

--- filter_en_uk.awk
+++ filter_en_uk.awk
@@ -62,33 +62,85 @@
             if ($x == "/") {
                 macroLine = macroLine "+slash,-slash";
                 break;
-            }#
-            if ($x == "/") {
-                macroLine = macroLine "+numslash,-numslash";
-                break;
-            }#
-            if ($x == "!") {
-                macroLine = macroLine "+exclam,-exclam";
+            }
+            if ($x == "¬") {
+                macroLine = macroLine "+lshift,+grave,-grave,-lshift";
                 break;
             }
             if ($x == "!") {
-                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+1,-1,-u,-lshift,-lctrl";
+                macroLine = macroLine "+lshift,+1,-1,-lshift";
+                break;
+            }
+            if ($x == "\"") {
+                macroLine = macroLine "+lshift,+2,-2,-lshift";
+                break;
+            }
+            if ($x == "£") {
+                macroLine = macroLine "+lshift,+3,-3,-lshift";
+                break;
+            }
+            if ($x == "$") {
+                macroLine = macroLine "+lshift,+4,-4,-lshift";
+                break;
+            }
+            if ($x == "%") {
+                macroLine = macroLine "+lshift,+5,-5,-lshift";
+                break;
+            }
+            if ($x == "^") {
+                macroLine = macroLine "+lshift,+6,-6,-lshift";
+                break;
+            }
+            if ($x == "&") {
+                macroLine = macroLine "+lshift,+7,-7,-lshift";
+                break;
+            }
+            if ($x == "*") {
+                macroLine = macroLine "+lshift,+8,-8,-lshift";
+                break;
+            }
+            if ($x == "(") {
+                macroLine = macroLine "+lshift,+9,-9,-lshift";
+                break;
+            }
+            if ($x == ")") {
+                macroLine = macroLine "+lshift,+0,-0,-lshift";
+                break;
+            }
+            if ($x == "_") {
+                macroLine = macroLine "+lshift,+minus,-minus,-lshift";
+                break;
+            }
+            if ($x == "<") {
+                macroLine = macroLine "+lshift,+comma,-comma,-lshift";
+                break;
+            }
+            if ($x == ">") {
+                macroLine = macroLine "+lshift,+dot,-dot,-lshift";
                 break;
             }
             if ($x == "?") {
-                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+3,-3,+f,-f,-u,-lshift,-lctrl";
+                macroLine = macroLine "+lshift,+slash,-slash,-lshift";
                 break;
             }
-            if ($x == "(") {
-                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+8,-8,-u,-lshift,-lctrl";
+            if ($x == ":") {
+                macroLine = macroLine "+lshift,+colon,-colon,-lshift";
                 break;
             }
-            if ($x == ")") {
-                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+9,-9,-u,-lshift,-lctrl";
+            if ($x == "@") {
+                macroLine = macroLine "+lshift,+quote,-quote,-lshift";
                 break;
             }
-            if ($x == "\"") {
-                macroLine = macroLine "+lctrl,+lshift,+u,+2,-2,+0,-0,+1,-1,+c,-c,-u,-lshift,-lctrl";
+            if ($x == "~") {
+                macroLine = macroLine "+lshift,+hash,-hash,-lshift";
+                break;
+            }
+            if ($x == "{") {
+                macroLine = macroLine "+lshift,+lbrace,-lbrace,-lshift";
+                break;
+            }
+            if ($x == "}") {
+                macroLine = macroLine "+lshift,+rbrace,-rbrace,-lshift";
                 break;
             }

@@ -96,7 +148,7 @@
             macroLine = macroLine "+" $x ",-" $x
         }
         while (0)
-        # 0 means it runs only once instead of endlessly looping in case oferrors
+        # 0 means it runs only once instead of endlessly looping in case of errors

         # I add a comma between this key and the next unless I 'm at the last one
         if (x < NF)


fix usage2c.awk for mawk, add comments

fix usage2c.awk for mawk, add comments

--- usage2c.awk
+++ usage2c.awk
@@ -5,6 +5,10 @@
     print("#include <libxml/xmlversion.h>");
 }

+# text in src/foo-bar.txt results in
+#   static const char foo_text[] = {
+#     't', 'h', 'e', ' ', 't', 'e', 'x', 't', ...
+#   }
 length(command_name) == 0 {
     command_name = FILENAME;
     sub(/\.txt$/, "", command_name);
@@ -14,6 +18,12 @@
     progs = 0;
 }

+# escape percent signs: we are going to use printf(). I don't think there are
+# any %s currently, but it's bound to happen eventually.
+{ gsub(/%/, "%%"); }
+
+# white space separted instances of PROG will be replaced with the final name of
+# the xmlstarlet executable
 /PROG/ {
     for (i = 1; i <= NF; i++) {
         if ($i == "PROG") {
@@ -23,12 +33,22 @@
     }
 }

+# C-preprocessor directives are unchanged
 /^#/
+
+# convert plain text lines into equivalent char array literal
 !/^#/ {
-    gsub(/./, "'&',");
-    gsub(/'\\'/, "'\\\\'");     # '\' --> '\\'
-    gsub(/'''/, "'\\''");       # ''' --> '\''
-    print($0 "'\\n',");
+    for (i = 1; i <= length($0); i++) {
+        c = substr($0, i, 1);
+        if (c == "\\")          # \ --> '\\'
+            printf("'\\\\'");
+        else if (c == "'")      # ' --> '\''
+            printf("'\\''");
+        else                    # X --> 'X'
+            printf("'%c'", c);
+        printf(",");
+    }
+    print("'\\n',");
 }

 END {


RPi_system: Correctly report info about "OFF" dies to the browser

--- RPi_system/waas_all_info_cached.awk
+++ RPi_system/waas_all_info_cached.awk
@@ -34,33 +34,40 @@
   for (asic = 0; asic < NUM_ASIC; ++asic) {
     num = asic + 1;
     printf("\"asic_%d\": {\n", num);
+    all_dcdc_bad = 1;

     for (dcdc = 0; dcdc < NUM_DCDC; ++dcdc) {
       vout = "";
       if ("" != asic_dcdcVout[asic, dcdc])
         vout = (0.0 + asic_dcdcVout[asic, dcdc]);
-      if (vout <= 0)
+      if (vout <= 0) {
         vout_s = "";
-      else
+      } else {
         vout_s = sprintf("%.4f", vout);
+        all_dcdc_bad = 0;
+      }
       print "\t\"dcdc" dcdc "_Vout\": \"" vout_s "\","

       iout = "";
       if ("" != asic_dcdcIout[asic, dcdc])
         iout = (0.0 + asic_dcdcIout[asic, dcdc]);
-      if (iout <= 0)
+      if (iout <= 0) {
         iout_s = "";
-      else
+      } else {
         iout_s = sprintf("%.4f", iout);
+        all_dcdc_bad = 0;
+      }
       print "\t\"dcdc" dcdc "_Iout\": \"" iout_s "\","

       temp = "";
       if ("" != asic_dcdctemp[asic, dcdc])
         temp = (0.0 + asic_dcdctemp[asic, dcdc]);
-      if (temp <= 0)
+      if (temp <= 0) {
         temp_s = "";
-      else
+      } else {
         temp_s = sprintf("%.1f", temp);
+        all_dcdc_bad = 0;
+      }
       print "\t\"dcdc" dcdc "_Temp\": \"" temp_s "\","
     }

@@ -69,6 +76,8 @@
       if ("" != asic_freq[asic, die])
         freq = (0 + asic_freq[asic, die]);
       if (freq <= 0)
+        freq = "OFF";
+      if (all_dcdc_bad)
         freq = "";
       print "\t\"die" die "_Freq\": \"" freq "\",";

@@ -79,6 +88,8 @@
         volt_s = "";
       else
         volt_s = sprintf("%.4f", volt);
+      if (all_dcdc_bad)
+        volt_s = "";
       print "\t\"die" die "_Voffset\": \"" volt_s "\",";
     }


bump version: 0.9-dev

bump version: 0.9-dev

--- metainfo.awk
+++ metainfo.awk
@@ -1,7 +1,7 @@
 BEGIN {
     Name        = "Translate Shell"
     Description = "Google Translate to serve as a command-line tool"
-    Version     = "0.8.23"
+    Version     = "0.9-dev"
     Command     = "trans"
     EntryPoint  = "translate.awk"
 }


Mark CVaListPointer array generators as unavailable on Linux

--- GLib-2.0.awk
+++ GLib-2.0.awk
@@ -2,7 +2,7 @@
 #
 # Patch the generated wrapper Swift code to handle special cases
 #
-BEGIN { etpInit = 0 }
+BEGIN { etpInit = 0 ; vaptrptr = 0 }
 /public convenience init.T: ErrorTypeProtocol./ {
 	etpInit = 1
 	print "    /// Convenience copy constructor, creating a unique copy"
@@ -25,4 +25,20 @@
 	sub(/GIConv {/,"GIConv? {")
 	sub(/return rv/,"return rv == unsafeBitCast(-1, to: GIConv.self) ? nil : rv")
 }
+/UnsafeMutablePointer.CVaListPointer/ {
+	vaptrptr = 1
+	print "#if !os(Linux)"
+}
+/^$/ {
+	if (vaptrptr) {
+		print "#endif"
+		vaptrptr = 0
+	}
+}
+/\/\/\// {
+	if (vaptrptr) {
+		print "#endif"
+		vaptrptr = 0
+	}
+}
 // { print }


regdb: Generalize the mW to dBm power conversion

Generalize the power conversion from mW to dBm
using log. This should fix the below compilation
error for country NO which adds a new power value
2000mW which is not handled earlier.

 CC [M]  net/wireless/wext-sme.o
 CC [M]  net/wireless/regdb.o
net/wireless/regdb.c:1130:1: error: Unknown undeclared here (not in
a function)
net/wireless/regdb.c:1130:9: error: expected } before power
make[2]: *** [net/wireless/regdb.o] Error 1
make[1]: *** [net/wireless] Error 2
make: *** [net] Error 2

Reported-By:  John Walker <a51dda7c7ff50b61eaea0444371f4a6a9301e501@x109.net>
Signed-off-by: Chaitanya T K <199e9860d62930d367e80551e27f729f69f2d733@gmail.com>
Acked-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>
[remove unneeded parentheses, fix rounding by using %.0f]
Signed-off-by: Johannes Berg <bff32994ff0f8d048f262a8388145a71b6071bfe@intel.com>

--- net/wireless/genregdb.awk
+++ net/wireless/genregdb.awk
@@ -68,17 +68,7 @@
 	sub(/,/, "", units)
 	dfs_cac = $9
 	if (units == "mW") {
-		if (power == 100) {
-			power = 20
-		} else if (power == 200) {
-			power = 23
-		} else if (power == 500) {
-			power = 27
-		} else if (power == 1000) {
-			power = 30
-		} else {
-			print "Unknown power value in database!"
-		}
+		power = 10 * log(power)/log(10)
 	} else {
 		dfs_cac = $8
 	}
@@ -117,7 +107,7 @@

 	}
 	flags = flags "0"
-	printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %d, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
+	printf "\t\tREG_RULE_EXT(%d, %d, %d, %d, %.0f, %d, %s),\n", start, end, bw, gain, power, dfs_cac, flags
 	rules++
 }


Remove debugging 'PR |' printout

Remove debugging 'PR |' printout

--- getMHzFrom-episodePages.awk
+++ getMHzFrom-episodePages.awk
@@ -99,8 +99,8 @@
     if (episodeTitle ~ /^PR \|/) {
         # Episode is a Trailer (i.e. First look), set episodeType to "T"
         episodeType = "T"
-        print episodeTitle "\t" shortURL >> ERROR_FILE
         printf ("-1") >> NUM_EPISODES_FILE
+        # print episodeTitle "\t" shortURL >> ERROR_FILE
     }
     #
     # If start of episodeTitle == seriesTitle ": ", remove the redundant part.


Work around va_list and CLongDouble issues on Linux and arm64

--- GLib-2.0.awk
+++ GLib-2.0.awk
@@ -2,7 +2,7 @@
 #
 # Patch the generated wrapper Swift code to handle special cases
 #
-BEGIN { etpInit = 0 ; vaptrptr = 0 }
+BEGIN { etpInit = 0 ; vaptrptr = 0 ; longdouble = 0 }
 /public convenience init.T: ErrorTypeProtocol./ {
 	etpInit = 1
 	print "    /// Convenience copy constructor, creating a unique copy"
@@ -31,17 +31,23 @@
 }
 /Pointer<va_list>/ {
 	vaptrptr = 1
-	print "#if !os(Linux)"
+	print "#if !os(Linux) && !arch(arm64)"
+}
+/CLongDouble/ {
+	longdouble = 1
+	print "#if !(os(Linux) && arch(arm64))"
 }
 /^$/ {
-	if (vaptrptr) {
+	if (vaptrptr || longdouble) {
 		print "#endif"
+		longdouble = 0
 		vaptrptr = 0
 	}
 }
 /\/\/\// {
-	if (vaptrptr) {
+	if (vaptrptr || longdouble) {
 		print "#endif"
+		longdouble = 0
 		vaptrptr = 0
 	}
 }


Oops, extra }

Oops, extra }

--- getBBoxSeasonsFrom-webscraper.awk
+++ getBBoxSeasonsFrom-webscraper.awk
@@ -53,7 +53,6 @@
     # unless it's never used without the "The" included, such as "The Queen"
     if (showTitle !~ /^The Queen/ && showTitle !~ /^The Shard/ && match (showTitle, /^The /))
         showTitle = substr(showTitle, 5) ", The"
-    }

     # Some shows that need special processing
     if (baseURL ~ /Maigret_15974$/) {


added ns for dbpedia http://dbpedia.org/resource/

--- bin/util/header2params2.awk
+++ bin/util/header2params2.awk
@@ -45,6 +45,7 @@
       print "@prefix time:       <http://www.w3.org/2006/time#> ."
       print "@prefix wgs:        <http://www.w3.org/2003/01/geo/wgs84_pos#> ."
       print "@prefix geonames:   <http://www.geonames.org/ontology#> ."
+      print "@prefix dbpedia:    <http://dbpedia.org/resource/> ."
       print "@prefix con:        <http://www.w3.org/2000/10/swap/pim/contact#> ."
       print "@prefix muo:        <http://purl.oclc.org/NET/muo/muo#> ."
    }


Languages: add two more aliases: zh-CHS and zh-CHT

--- include/Languages.awk
+++ include/Languages.awk
@@ -1777,6 +1777,8 @@
     LocaleAlias["srp"]     = "sr-Cyrl"
     LocaleAlias["serbian"] = "sr-Cyrl"
     LocaleAlias["zh"]      = "zh-CN" # Chinese: default to Chinese Simplified
+    LocaleAlias["zh-CHS"]  = "zh-CN"
+    LocaleAlias["zh-CHT"]  = "zh-TW"
     LocaleAlias["zho"]     = "zh-CN"
     LocaleAlias["chinese"] = "zh-CN"
     LocaleAlias["tlh-Latn"] = "tlh"


Languages: add Romansh language

Languages: add Romansh language

--- include/Languages.awk
+++ include/Languages.awk
@@ -248,6 +248,19 @@
     Locale["ps"]["glotto"]             = "pash1269"
     Locale["ps"]["script"]             = "Arab"
     Locale["ps"]["rtl"]                = "true" # RTL language
+
+    #? Romansh
+    Locale["rm"]["name"]               = "Romansh"
+    Locale["rm"]["endonym"]            = "Rumantsch"
+    #Locale["rm"]["translations-of"]
+    #Locale["rm"]["definitions-of"]
+    #Locale["rm"]["synonyms"]
+    #Locale["rm"]["examples"]
+    #Locale["rm"]["see-also"]
+    Locale["rm"]["family"]             = "Indo-European"
+    Locale["rm"]["iso"]                = "roh"
+    Locale["rm"]["glotto"]             = "roma1326"
+    Locale["rm"]["script"]             = "Latn"

     #1 Afrikaans
     Locale["af"]["name"]               = "Afrikaans"


TestCommons: update

TestCommons: update

--- test/TestCommons.awk
+++ test/TestCommons.awk
@@ -38,7 +38,7 @@
         delete array; array[0] = "foo"
         delete expected; expected[0] = "foo"; expected[1] = "bar"
         append(array, "bar")
-        assertTrue(identical(array, expected))
+        assertEqual(array, expected)
     }

     # Strings
@@ -85,7 +85,7 @@
         delete array
         delete expected; expected[1] = "f"; expected[2] = "o"; expected[3] = "o"
         explode("foo", array)
-        assertTrue(identical(array, expected))
+        assertEqual(array, expected)
     }
     T("escapeChar()", 8)
     {


Work on adding episode types

Work on adding episode types

--- getMHzFrom-episodePages.awk
+++ getMHzFrom-episodePages.awk
@@ -78,15 +78,23 @@
     next
 }

-# Extract the episode URL, the episode title, and the seasonNumber
+# Extract the episode URL, the episode type, the episode title, and the seasonNumber
 /<strong title="/ {
     gsub (/'/,"'")
     split ($0,fld,"\"")
     episodeURL = fld[2]
+    if (episodeURL ~ /-c-.[[:digit:]]{3,4}$/)
+        episodeNumberFromURL = substr (episodeURL, length(episodeURL)-1, 2) + 0
     shortURL = episodeURL
     sub (/.*watch/,"watch",shortURL)
-    if (episodeURL ~ /-c-[[:digit:]]{5}$/)
-        episodeNumberFromURL = substr (episodeURL, length(episodeURL)-1, 2)
+    # Default episodeType to "E"
+    episodeType = "E"
+    # If episode is a Trailer or Finale (i.e. First look), set episodeType to "T"
+    if (episodeURL ~ /-trailer-|-finale-/)
+        episodeType = "T"
+    # If episode is a BONUS:, set episodeType to "X"
+    if (episodeURL ~ /-c-x[[:digit:]]{3,4}$/)
+        episodeType = "X"
     episodeTitle = fld[4]
     gsub (/"/,"\"\"",episodeTitle)
     gsub (/&/,"\\&",episodeTitle)
@@ -96,16 +104,20 @@
     next
 }

-# Extract the episode number
+# Extract the episode number, and correct if necessary
 /<h4 class="/ {
     sub (/.*Episode /,"")
     sub (/<\/span>.*/,"")
-    episodeNumber = $0
-    if (seriesTitle == "Detective Montalbano" && page2 == "yes") {
-        oldEpisodeNumber = episodeNumber
-        episodeNumber += 24
-        printf ("==> Corrected E%02d to E%02d: %s\n", oldEpisodeNumber, episodeNumber, \
+    episodeNumber = $0 + 0
+    if (episodeType == "T") {
+        printf ("==> Corrected %s%02d to T01: %s\n", episodeType, episodeNumber, \
                 shortURL) >> ERROR_FILE
+        episodeNumber = 1
+    }
+    if ((episodeURL ~ /-c-.[[:digit:]]{3,4}$/) && episodeNumber != episodeNumberFromURL) {
+        printf ("==> Corrected %s%02d to %s%02d: %s\n", episodeType, episodeNumber, episodeType, \
+                episodeNumberFromURL, shortURL) >> ERROR_FILE
+        episodeNumber = episodeNumberFromURL
     }
     next
 }
@@ -114,17 +126,18 @@
 # Extract the episode description and print the composed info
 /<div class="transparent padding-top-medium"/,/<\/div>/ {
     if ($0 ~ /
 Corrected %s00 to %s%02d: %s\n", episodeType, episodeType,
+                        episodeNumberFromURL, shortURL) >> ERROR_FILE
                 episodeNumber = episodeNumberFromURL
-                printf ("==> Corrected E00 to E%02d: %s\n", episodeNumber, shortURL) >> ERROR_FILE
             } else {
                 printf ("==> Episode number is 00: %s\n", shortURL) >> ERROR_FILE
             }
         }
-        printf ("%d\t=HYPERLINK(\"%s\";\"%s, S%02dE%02d, %s\"\)\t\t\t%s\t\t\t\t\t", \
-            SERIES_NUMBER, episodeURL, seriesTitle, seasonNumber, episodeNumber, episodeTitle, \
-            episodeDuration) >> EPISODE_INFO_FILE
+        printf ("%d\t=HYPERLINK(\"%s\";\"%s, S%02d%s%02d, %s\"\)\t\t\t%s\t\t\t\t\t", \
+                SERIES_NUMBER, episodeURL, seriesTitle, seasonNumber, episodeType, episodeNumber, \
+                episodeTitle, episodeDuration) >> EPISODE_INFO_FILE
         # Need to account for multiple lines of description
         descriptionLinesFound = 0
         episodeDescription = ""


Commons: add initAnsiCode()

Commons: add initAnsiCode()

--- lib/Commons.awk
+++ lib/Commons.awk
@@ -39,6 +39,42 @@
     UrlEncoding["~"]  = "%7E"
 }

+# Initialize ANSI escape codes (ANSI X3.64 Standard Control Sequences).
+# See: <https://en.wikipedia.org/wiki/ANSI_escape_code>
+function initAnsiCode() {
+    # Dumb terminal: no ANSI escape code whatsoever
+    if(ENVIRON["TERM"] == "dumb") return
+
+    AnsiCode["reset"]         = AnsiCode[0] = "\33[0m"
+
+    AnsiCode["bold"]          = "\33[1m"
+    AnsiCode["underline"]     = "\33[4m"
+    AnsiCode["negative"]      = "\33[7m"
+    AnsiCode["no bold"]       = "\33[21m"
+    AnsiCode["no underline"]  = "\33[24m"
+    AnsiCode["positive"]      = "\33[27m"
+
+    AnsiCode["black"]         = "\33[30m"
+    AnsiCode["red"]           = "\33[31m"
+    AnsiCode["green"]         = "\33[32m"
+    AnsiCode["yellow"]        = "\33[33m"
+    AnsiCode["blue"]          = "\33[34m"
+    AnsiCode["magenta"]       = "\33[35m"
+    AnsiCode["cyan"]          = "\33[36m"
+    AnsiCode["gray"]          = "\33[37m"
+
+    AnsiCode["default"]       = "\33[39m"
+
+    AnsiCode["dark gray"]     = "\33[90m"
+    AnsiCode["light red"]     = "\33[91m"
+    AnsiCode["light green"]   = "\33[92m"
+    AnsiCode["light yellow"]  = "\33[93m"
+    AnsiCode["light blue"]    = "\33[94m"
+    AnsiCode["light magenta"] = "\33[95m"
+    AnsiCode["light cyan"]    = "\33[96m"
+    AnsiCode["white"]         = "\33[97m"
+}
+
 # Naive assertion.
 function assert(x, message) {
     if (!message)


Changes in marksession.awk awk script to have a better session ID, especially when Frames do not have Call-ID (before: session ID was previous one, after: session-ID is {0}

git-svn-id: 392d0e5ce652024192c571322d40dcc23d6d83b0@17 8a65f31f-a56f-4bd6-98e8-2755f64920ec

--- awk-scripts/marksession.awk
+++ awk-scripts/marksession.awk
@@ -1,33 +1,44 @@
 BEGIN {
-   session_count = 0;
+  session_count = 0;
 }

 {
-   if ($1 ~ "[0-9]+") {
-	  /* See if the current line is already in the table */
-	  frame_file = destDir "/frames/Frame"$1".html";
-	  "grep -i \"" session_token "\" " frame_file | getline session_line;
-	  found = 0;
-	  split(session_line, array);
-	  session = array[2];
+  if ($1 ~ "[0-9]+") {
+    # See if the current line is already in the table
+    frame_file = destDir "/frames/Frame"$1".html"
+    session_line = ""
+    "grep -i \"" session_token "\" " frame_file | getline session_line
+
+    if (session_line == "" ) {
+      $4 = "{0}"
+      print $0

-	  for (i=0; i < session_count; i++) {
-		 if (sessions[i] == session) {
-			found = 1;
-			$4 = "{" i+1 "}";
-			print $0;
-			break;
-		 }
-	  }
-	  if (found == 0) {
-		 $4 = "{" session_count+1 "}";
-		 sessions[session_count++] = session;
-		 print $0;
-		 s = sprintf("echo 'New session in frame %s: %s' >&2", $1, session);
-		 system(s);
-	  }
+    } else {
+      found = 0;
+      split(session_line, array)
+      session = array[2]
+      for (i=0; i < session_count; i++) {
+        if (sessions[i] == session) {
+          found = 1
+          $4 = "{" i+1 "}"
+          print $0
+          break
+        }
+      }

-   } else {
-	  print $0;
-   }
+      if (found == 0) {
+        $4 = "{" session_count+1 "}"
+        sessions[session_count++] = session
+        print $0
+        s = sprintf("echo 'New session in frame %s: %s' >&2", $1, session)
+        system(s)
+      }
+    }
+
+  } else {
+    # Comment line, line starting with "#".
+    # Requires no processing, just print it
+    print $0
+  }
 }
+


Document the head of the script

Document the head of the script

--- src/makeplist.awk
+++ src/makeplist.awk
@@ -1,3 +1,22 @@
+#!/usr/bin/awk -f
+#
+# Combine multiple pkg-plist files into a single pkg-plist.
+#
+# This takes a list of all options as command line arguments. The
+# order of the options determines the order option specific plist
+# entries appear in the combined output.
+#
+# The plists must be fed into stdin and preceded by a line starting
+# with `OPTIONS:` followed by a white space separated list of the
+# active options.
+#
+# Files that appear with all options are listed first, followed by
+# the option specific output.
+#
+# @param ARGV
+#	A sorted list of options
+#
+
 # Get the order of options
 BEGIN {
 	OPTION_STR["DOCS"] =     "%%PORTDOCS%%"
@@ -15,6 +34,7 @@
 	}
 	CNT_FILES = 0
 }
+
 # Get the options the following files were staged with
 /^OPTIONS:/ {
 	delete aoptions
@@ -26,6 +46,7 @@
 	++CONFIGS
 	next
 }
+
 # Collect files
 {
 	# Record order of file
@@ -45,6 +66,7 @@
 		++OPT_FILES[option, $0]
 	}
 }
+
 # Print files
 END {
 	# Print files common to all configurations


Improve regex portability

Improve regex portability


Update min/max length to be inclusive

Update min/max length to be inclusive

see: https://trello.com/c/RU4BWrYA/340-as-a-data-manager-adding-min-max-values-in-the-jts-they-should-be-inclusive

--- bin/bawlk.awk
+++ bin/bawlk.awk
@@ -158,7 +158,7 @@
         msg         = field " in \" CSVFILENAME \" line \" NR \" should match the following pattern " pattern " and was \" " field " \" "

     } else if (rule_type ~ /^minLength|maxLength$/) {
-        comparator  = $2 == "maxLength" ? ">" : "<"
+        comparator  = $2 == "maxLength" ? ">=" : "<="
         limit       = params[2]
         term        = $2 == "maxLength" ? "less" : "greater"


Remove no longer needed kludge

Remove no longer needed kludge

--- getMHzFrom-episodePages.awk
+++ getMHzFrom-episodePages.awk
@@ -86,9 +86,6 @@
     if (episodeURL ~ /-c-[[:digit:]]{5}$/)
         episodeNumberFromURL = substr (episodeURL, length(episodeURL)-1, 2)
     episodeTitle = fld[4]
-    # kludge for missing episode number in mammon/season:1/videos/the-murder
-    if (episodeTitle ~ /Sn 1 Ep 5/)
-        episodeNumberFromURL = "05"
     gsub (/"/,"\"\"",episodeTitle)
     gsub (/&/,"\\&",episodeTitle)
     sub (/.*season:/,"")


minor: whitespace

minor: whitespace

--- process-ngrams.awk
+++ process-ngrams.awk
@@ -6,7 +6,7 @@
 # * Assumes the input corpus is sorted.
 #
 {
-    if ($1 ~ /^[a-zA-Z' ]+$/) {
+    if ( $1 ~ /^[a-zA-Z' ]+$/ ) {
         if ( $1 == last ) {
             count+=$3
         } else if ( last != "" ) {


Add the SENSES option to linked-isas.awk

--- misc/linked-isas.awk
+++ misc/linked-isas.awk
@@ -1,6 +1,7 @@
 #!/usr/bin/awk -f
 BEGIN {
     FS = OFS = "\t";
+    if (length(SENSES) == 0) SENSES = 0;
 }
 {
     nsenses = split($3, senses, ", ");
@@ -10,8 +11,12 @@

     for (sense in senses) {
         for (isa in isas) {
-            sub(/#[[:digit:]]+$/, "", senses[sense]);
-            sub(/#[[:digit:]]+(:|$)/, OFS, isas[isa]);
+            if (SENSES) {
+                sub(/(:|$)/, OFS, isas[isa]);
+            } else {
+                sub(/#[[:digit:]]+$/, "", senses[sense]);
+                sub(/#[[:digit:]]+(:|$)/, OFS, isas[isa]);
+            }
             print senses[sense], isas[isa] | "sort --parallel=$(nproc) -t \"\t\" -S1G -s -g -k3r | cut -f1,2";
         }
     }


Revert.

Revert.

git-svn-id: 293778eaa97c8c94097d610b1bd5133a8f478f36@38824 4f837ed2-42f5-46e7-a7a5-fa17313484d4

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -8,7 +8,7 @@

 {
   # add a loop to add line only if ending year is gt or eq to contract year
-  current_year = 2015
+  current_year = 2014
   end_year = 0
   incontract = 0
   test_year = ""


Compute the CloudFront records dynamically.

--- src/cloudfront.awk
+++ src/cloudfront.awk
@@ -1,7 +1,3 @@
-BEGIN {
-    print "[";
-}
-
 function printUrlQueryString(queryString)
 {
     split(queryString, pairs, "&", seps)
@@ -32,40 +28,30 @@
     return url;
 }

-/^#/ {
-  # Ignore log comment lines
-}
-
-/^[1-9][0-9]*/ {
-    date = $1                         # date
-    time = $2                         # time
-    x_edge_location = $3              # x-edge-location
-    sc_bytes = $4                     # sc-bytes
-    c_ip = $5                         # c-ip
-    cs_method = $6                    # cs-method
-    cs_Host = $7                      # cs(Host)
-    cs_uri_stem = $8                  # cs-uri-stem
-    sc_status = $9                    # sc-status
-    cs_Referer = $10                  # cs(Referer)
-    cs_User_Agent = $11               # cs(User-Agent)
-    cs_uri_query = $12                # cs-uri-query
-    cs_Cookie = $13                   # cs(Cookie)
-    x_edge_result_type = $14          # x-edge-result-type
-    x_edge_request_id = $15           # x-edge-request-id
-    x_host_header = $16               # x-host-header
-    cs_protocol = $17                 # cs-protocol
-    cs_bytes = $18                    # cs-bytes
-    time_taken = $19                  # time-taken
-    x_forwarded_for = $20             # x-forwarded-for
-    ssl_protocol = $21                # ssl-protocol
-    ssl_cipher = $22                  # ssl-cipher
-    x_edge_response_result_type = $23 # x-edge-response-result-type
-    printf "{\n\t\"date\": \"%s\",\n\t\"time\":\"%s\",\n\t\"x-edge-location\":\"\%s\",\n\t\"sc-bytes\": \"%s\",\n\t\"c-ip\": \"%s\",\n\t\"cs-method\": \"%s\",\n\t\"cs(Host)\": \"%s\",\n\t\"cs-uri-stream\": \"%s\",\n\t\"sc-status\": \"%s\",\n\t\"cs(Referer)\": \"%s\",\n\t\"cs(User-Agent)\": \"%s\",\n\t\"cs(Cookie)\": \"%s\",\n\t\"x-edge-result-type\": \"%s\",\n\t\"x-edge-request-id\": \"%s\",\n\t\"x-host-header\": \"%s\"\n\t\"cs-protocol\": \"%s\",\n\t\"cs-bytes\": \"%s\",\n\t\"time-taken\": \"%s\",\n\t\"x-forwarded-for\": \"%s\",\n\t\"ssl-protocol\": \"%s\",\n\t\"ssl-cipher\": \"%s\",\n\t\"x-edge-response-result-type\": \"%s\",\n", date, time, x_edge_location, sc_bytes, c_ip, cs_method, cs_Host, cs_uri_stem, sc_status, cs_Referer, urlDecode(urlDecode(cs_User_Agent)), cs_Cookie, x_edge_result_type, x_edge_request_id, x_host_header, cs_protocol, cs_bytes, time_taken, x_forwarded_for, ssl_protocol, ssl_cipher, x_edge_response_result_type
-  printf "\t\"cs-uri-query\": {\n"
-  printUrlQueryString(cs_uri_query)
-  printf "\t}\n"
+BEGIN {
+    print "{";
 }

 END {
-  print "]";
+    print "}"
 }
+
+/^#Version: / {
+    printf "\t\"version\": \"%s\",\n", substr($0, length("#Version: ") + 1)
+}
+
+/^#Fields: / {
+    rest = substr($0, length("#Fields: ") + 1)
+    split(rest, fields, " ", seps)
+    numFields = length(fields)
+}
+
+! /^#/ {
+    split($0, fieldsThisLine, " ", sepsThrowAway)
+    print "\t{"
+    for(i = 1; i < numFields; i++)
+    {
+        printf "\t\t\"%s\": \"%s\",\n", fields[i], fieldsThisLine[i]
+    }
+    print "\t},"
+}


add a diff line so you can check your commit before hitting enter...

--- tools/tools/mfc/mfc.awk
+++ tools/tools/mfc/mfc.awk
@@ -22,9 +22,12 @@
 	if (!(match($2, "\\+[0-9]") && match($3, "-[0-9]")))
 		next
 	printf("cvs -d %s update %s -j 1.%d -j 1.%d %s\n", CVSROOT, UPDATEOPTS, $1 - 1, $1, $4)
-	files = files " " $4
+	files[$4] = 1
 }

 END {
-	printf("cvs -d %s commit %s\n", CVSROOT, files);
+	for (i in files)
+		fl = fl " " i
+	printf("cvs -d %s diff -kk %s | less\n", CVSROOT, fl);
+	printf("cvs -d %s commit %s\n", CVSROOT, fl);
 }


Only link classes and insert paragraph breaks.

--- utils/pydoc2html.awk
+++ utils/pydoc2html.awk
@@ -98,7 +98,9 @@
           if (!isBullet) print "
";
           target = substr($2, 0, length($2) -1);
           if (target == "inventor") print "
" $2 "";
-          else print "
" $2 "";
+          else if (match(target, /^[A-Z]/)) print "
" $2 "";
+          else print "
" $2;
+
           sub(/^[ ]*\- [a-zA-Z0-9_, ]+: /, "");
           print;
           isBullet = 1; next;
@@ -131,11 +133,18 @@
               }
               else print $0;
             }
+            else print "
";
           }
           else if (!eatEmptyLines || length($0) > 0)
           {
             print;
-          }
+          }
+
+          if (!isBullet && !eatEmptyLines && length($0) == 0)
+          {
+            print "
";
+          }
+
           if (length($0) > 0) eatEmptyLines = 0; else if (isBullet)
           {
             print "
";


hinter: use same hint for all occurrences of match

This patch changes the hinter to use the same hint for all occurrences
of a match, thereby reducing the need to use multi-character hints and
also eliminating redundant hints to simplify the user's hint decision.

--- scripts/hinter.awk
+++ scripts/hinter.awk
@@ -1,7 +1,5 @@
 BEGIN {
   n_matches = 0;
-  line_pos = 0;
-  col_pos = 0;
   COMPACT_HINTS = ENVIRON["COMPACT_HINTS"];

   HINTS[0] = "p"
@@ -121,50 +119,37 @@
 }

 {
-  line = $0;
-  pos = 0;
-  col_pos = 0;
-  col_pos_correction = 0;
+  output_line = $0;

-  output_line = line;
+  # insert hints into `output_line` and accumulate hints in `hint_lookup`
+  line = output_line;
+  pos = col_pos_correction = 0;
+  while (match(line, finger_patterns)) {
+    pos += RSTART;
+    col_pos = pos + col_pos_correction
+    pre_match = substr(output_line, 0, col_pos - 1);
+    post_match = substr(output_line, col_pos + RLENGTH, length(line) - 1);
+    line_match = substr(line, RSTART, RLENGTH);

-  while (match(line, finger_patterns)) {
-    n_matches += 1;
-
-    hint = HINTS[n_matches - 1]
-    pos += RSTART;
-
-    col_pos = pos;
-
-    line_match = substr(line, RSTART, RLENGTH);
-    full_line_match = line_match
+    hint = hint_by_match[line_match]
+    if (!hint) {
+      hint = HINTS[n_matches++]
+      hint_by_match[line_match] = hint
+    }
+    hint_lookup = hint_lookup hint ":" line_match "\n"

     if (COMPACT_HINTS) {
       hint_len = length(hint)
       line_match = substr(line_match, hint_len + 1, length(line_match) - hint_len);
-    }
-
-    col_pos = col_pos + col_pos_correction
-
-    line_pos = NR;
-
-    pre_match = substr(output_line, 0, col_pos - 1);
-
-    if (COMPACT_HINTS) {
       hint_match = sprintf(compound_format, hint, line_match);
     } else {
       hint_match = sprintf(compound_format, line_match, hint);
     }
-
-    post_match = substr(output_line, col_pos + RLENGTH, length(line) - 1);
-
     output_line = pre_match hint_match post_match;
-
-    line = post_match;

     col_pos_correction += length(sprintf(highlight_format, line_match)) + length(sprintf(hint_format, hint)) - 1;

-    hint_lookup = hint_lookup hint ":" full_line_match "\n"
+    line = post_match;
   }

   printf "\n%s", output_line


KNF the output.

KNF the output.

--- dev/hil/devlist2h.awk
+++ dev/hil/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.1 2003/02/11 19:39:30 miod Exp $
+#	$OpenBSD: devlist2h.awk,v 1.2 2005/05/07 22:39:43 miod Exp $
 #
 # Copyright (c) 2003, Miodrag Vallat.
 # All rights reserved.
@@ -74,6 +74,6 @@
 		print $0
 }
 END {
-	printf("\t{ -1, -1, -1, NULL }")
+	printf("\t{ -1, -1, -1, NULL }\n")
 	printf("};\n")
 }


Better names

Better names

--- getBritBoxFrom-scrapy_xml.awk
+++ getBritBoxFrom-scrapy_xml.awk
@@ -13,7 +13,6 @@
 /\/us\// {
     URL = $3
     showTitle = $7
-    subtitle = $11

     # Titles starting with "The" should not sort based on "The"
     if (match (showTitle, /^The /)) {
@@ -24,6 +23,7 @@
 # <URL>/us/episode/Vera_S3_E1_13502</URL><Title>Vera</Title><Subtitle>Season 3, Castles in The Air</Subtitle>\
 # <Duration>88 min</Duration><Year>2013</Year><Rating>TV-MA</Rating>
 /\/us\/episode\// {
+    episodeTitle = $11
     episodeDuration = $15
     episodeYear = $19
     episodeRating = $23
@@ -37,25 +37,22 @@

     # Get rid of perfunctory "Season <n>, " from episode title
     episodePrefix = "Season " seasonNumber ", "
-    sub (episodePrefix, "", subtitle)
+    sub (episodePrefix, "", episodeTitle)

     if (episodeNumber != "") {
         printf \
             ("%s S%02dE%02d\t=HYPERLINK(\"https://www.britbox.com%s\";\"%s, S%02dE%02d, %s\"\)\t\t%s\t%s\t%s\t%s\n", \
              showTitle, seasonNumber, episodeNumber, URL, showTitle, seasonNumber, episodeNumber, \
-             subtitle, episodeDuration, episodeYear, episodeRating, episodeDescription)
+             episodeTitle, episodeDuration, episodeYear, episodeRating, episodeDescription)
     }
 }

 # <URL>/us/season/Vera_S8_15720</URL><Title>Vera</Title><SeasonNumber>8</SeasonNumber>\
 # <Year>2018</Year><NumEpisodes>4</NumEpisodes>
 /\/us\/season\// {
+    seasonNumber = $11
     seasonYear = $15
     seasonEpisodes = $19
-
-    nfields = split (URL,fld,"_")
-    seasonNumber = fld[nfields - 1]
-    sub (/S/,"",seasonNumber)

     if (seasonNumber != "") {
         printf \


Theme: add comments

Theme: add comments

--- include/Theme.awk
+++ include/Theme.awk
@@ -2,6 +2,7 @@
 # Theme.awk                                                        #
 ####################################################################

+# Prettify a string using corresponding SGR option.
 function prettify(name, string,    i, temp) {
     temp = string
     if ("sgr-" name in Option)
@@ -13,6 +14,7 @@
     return temp
 }

+# Return a string representing a random color.
 function randomColor(    i) {
     i = int(5 * rand())
     switch (i) {
@@ -25,6 +27,7 @@
     }
 }

+# Set theme to: random.
 function setRandomTheme(    i, n, temp) {
     srand(systime())
     for (i = 0; i < 3; i++) {
@@ -82,6 +85,7 @@
     Option["sgr-brief-translation"][2] = Option["sgr-brief-translation-phonetics"][2] = "bold"
 }

+# Set theme to: default.
 function setDefaultTheme() {
     Option["sgr-translation"] = Option["sgr-translation-phonetics"] = "bold"
     Option["sgr-prompt-message-original"] = "underline"
@@ -98,6 +102,7 @@
     Option["sgr-alternatives-translations-item"] = "bold"
 }

+# Set theme using corresponding option.
 function setTheme(    file, line, script) {
     if (Option["theme"] && Option["theme"] != "default") {
         file = Option["theme"]


Utils: parameterize data in curlPost()

Utils: parameterize data in curlPost()

--- include/Utils.awk
+++ include/Utils.awk
@@ -178,7 +178,7 @@
     command = Curl " --location --silent"
     if (Option["user-agent"])
         command = command " --user-agent " parameterize(Option["user-agent"])
-    command = command " --request POST --data " data
+    command = command " --request POST --data " parameterize(data)
     command = command " " parameterize(url)
     if (output) {
         command = command " --output " parameterize(output)


Commons: add PIPE

Commons: add PIPE

--- include/Commons.awk
+++ include/Commons.awk
@@ -12,6 +12,7 @@

     SUPOUT = " > /dev/null "  # suppress output
     SUPERR = " 2> /dev/null " # suppress error
+    PIPE = " | "
 }

 # Initialize `UrlEncoding`.


The bindings should include the BRLAPI_ERROR_... constants. (dm)

git-svn-id: 30a5f035a20f1bc647618dbad7eea2a951b61b7c@3382 91a5dbb7-01b9-0310-9b5f-b28072856b6e

--- Programs/brlapi.awk
+++ Programs/brlapi.awk
@@ -19,7 +19,7 @@
   apiRangeTypeCount = 0
 }

-/#define[ \t]*BRLAPI_(CURSOR|DISPLAY|TTY)_/ {
+/#define[ \t]*BRLAPI_(CURSOR|DISPLAY|ERROR|TTY)_/ {
   apiConstant(substr($2, 8), $2, getDefineValue(), "")
   next
 }


Update isNumber regex to be more accurate

--- bin/bawlk.awk
+++ bin/bawlk.awk
@@ -31,7 +31,7 @@
     print "function are_headers_valid(valid_headers) { v=0; split($0, h, \",\"); split(valid_headers, vh, \"|\"); return eql(h, vh); }"
     print "function is_unique(i, val) { if (vals[i,val]) { return 0; } else { vals[i,val] = 1; return 1; } }"
     print "function is_integer(x) { return x ~ /^-?[0-9]+$/ }"
-    print "function is_number(x) { return x ~ /^-?[0-9]+\.[0-9]+$/ }"
+    print "function is_number(x) { return x ~ /^-?[0-9]+(\.[0-9]+)?$/ }"
     print "function print_cats(categories) { for (category in categories) { if (categories[category]) print \"      \" category \": \" categories[category]; } }"
     print "function log_err(cat) { cats[cat]++; err_count++; }"
     print RS


Refactor BritBox season processing

Refactor BritBox season processing

--- getBritBoxSeasonsFrom-webscraper.awk
+++ getBritBoxSeasonsFrom-webscraper.awk
@@ -7,25 +7,37 @@

 BEGIN {
     FS="\t"
+    print "Sortkey\tURL\tYears\tEpisodes\tDescription"
 }

-# Only print the preceding line if the current line has a new Program_Title
+# Only print the preceding line if the current line has a different Program_Title
 # or the preceding line had a non-blank SsnURL-href
 NR > 1 {
-    SsnURL_href =$6
-    Program_Title = $9
-    if (Program_Title != oldProgram_Title || oldSsnURL_href != "")
-        print oldline
+    if (oldProgram_Title != $9 || oldSsnURL_href != "")
+        print savedLine
 }

-# Always save the current line so it can be printed after chaecking the following line
+# Save fields from the current line so they can be printed after checking the following line
 {
-    oldline = $0
+    # Raw fields for comparison
     oldSsnURL_href = $6
     oldProgram_Title = $9
+
+    # Fields to print from current line
+    sortkey = NR
+    $6  == "" ? URL = $4 : URL = $6
+    showTitle = $9
+    $10 == "" ? seasonTitle = "Season 1" : seasonTitle = $10
+    Years = $11
+    Episodes = $12
+    $14 != "" ? Description = $14 : Description = $13
+    savedLine = sprintf \
+        ("%s - %s\t=HYPERLINK(\"%s\";\"%s, %s\"\)\t%s\t%s\t%s",\
+         showTitle, sortkey, URL, showTitle, seasonTitle, Years, Episodes, Description)
+
     next
 }

 END {
-    print NR-1 " - "oldline
+    print savedLine
 }


r2795/sofa-dev : WARNING: Removing binary dependencies and headers from SVN. Please use system-specific packages available at https://gforge.inria.fr/frs/?group_id=483
This implements task 2610.

 //partial sync (1/22 changes)//

--- scripts/filter-code.awk
+++ scripts/filter-code.awk
@@ -1,8 +1,6 @@
 #!/usr/bin/awk -f
 # This script removes parts flagged by SOFA_DEV inside C source code files
-# The file with the relevant parts removed is output to the standard output,
-# while files mentionned inside removed parts are output to the standard error.
-# This can be used to remove then from the repository by svn rm'ing them.
+# The file with the relevant parts removed is output to the standard output.

 # If you never used awk, a good introduction is available at http://www.cs.hmc.edu/qref/awk.html


PLParser: header comment

PLParser: header comment


output more heavy headings; checkpoint

output more heavy headings; checkpoint

--- tools/hierarchy.awk
+++ tools/hierarchy.awk
@@ -6,8 +6,9 @@
     hier[heading] = $0
     sub(/<\/a>/, "", hier[heading])
     sub(/<\/a>/, "", hier[heading])
-    print "#############" hier[heading]
+    print hier[heading]
     hunt = 0
+    next
 }

 /
/ {
@@ -19,22 +20,26 @@
 }

 /<\/h[1-9]>/ {
-    heading -= 1
+    heading = 0
     print
     next
 }

-/
/ && heading == 1 {
+/
/ && heading == 0 {
     print "
"
     print "
"
-    print "
" hier[heading] "
"
+    print "
" hier[1] "
"
     heading = 2
     hunt = 1
     print
     next
 }

-/
/ && heading == 2 {
+/
/ && heading == 0 {
+    print "
"
+    print "
"
+    print "
" hier[1] "
"
+    print "
" hier[2] "
"
     heading = 3
     hunt = 1
     print


- use kabi whitelists

- use kabi whitelists

--- scripts/modpost.awk
+++ scripts/modpost.awk
@@ -1380,9 +1380,35 @@
 	    set_symset(set, hash, pos, ssym, scrc, own, src, "syssymset")
 	}
 	# TODO: revalidate the hash by regenerating it
+	close(tar)
     }
     print_vinfo(1,"r: syssymset, syms " count_syms ", sets " count_sets)
-    close(tar)
+    return n
+}
+# read and process kabi_whitelist_<cpu> file
+function read_whitelist(file, own, src,	    n, command, list, count_lists)
+{
+    count_syms = 0; count_lists = 0
+    print_vinfo(1,"r: whitelist, file = \"" file "\"")
+    n = 0
+    if (system("test -r " file) == 0) {
+	command = cat_command(file)
+	while ((command | getline) == 1) {
+	    if ($1~/^[[][^][]*[]]$/) {
+		list = $1
+		sub(/^[[]/,"",list)
+		sub(/[]]$/,"",list)
+		count_lists = count_lists + 1
+		continue
+	    } else {
+		set_symbol($1, "", "", "", "", 0, "", src ":" list, 1, own)
+		kabi[$1] = 1
+		n++
+	    }
+	}
+	close(command)
+    }
+    print_vinfo(1,"r: whitelist, syms " count_syms ", lists " count_lists)
     return n
 }
 function path_symvers(path,	n,files,file,i)
@@ -1928,6 +1954,7 @@
     }
     if ("kversion" in ENVIRON) { kversion = ENVIRON["kversion"] }
     else                       { kversion = getline_command("uname -r") }
+    cpu = getline_command("uname -m")
     # MODPOST_SYSVER  contains all the system  defined symbol versions
     # MODPOST_MODVER  contains all the package defined symbol versions
     # MODPOST_SYMSETS contains the new symbol sets (jltz)
@@ -1944,6 +1971,7 @@
     longopts["pkgabi"       ] = "P:" ; environs["pkgabi"       ] = "MODPOST_PKGABI"		 ; defaults["pkgabi"       ] = "package.abi"					; descrips["pkgabi"       ] = "input file containing package ABI definitions"
     longopts["symsets"      ] = "S:" ; environs["symsets"      ] = "MODPOST_SYMSETS"		 ; defaults["symsets"      ] = "symsets-openss7-" kversion ".tar.gz"		; descrips["symsets"      ] = "output file for symsets"
     longopts["ksymsets"     ] = "K:" ; environs["ksymsets"     ] = "MODPOST_KSYMSETS"		 ; defaults["ksymsets"     ] = "/boot/symsets-" kversion ".tar.gz"		; descrips["ksymsets"     ] = "input system symsets file"
+    longopts["whitelist"    ] = "L:" ; environs["whitelist"    ] = "MODPOST_WHITELIST"		 ; defaults["whitelist"    ] = "/lib/modules/kabi/kabi_whitelist_" cpu		; descrips["whitelist"    ] = "input kabi whitelist file"
     longopts["missing"      ] = "g"  ;								   defaults["missing"      ] = 0						; descrips["missing"      ] = "create missing system symsets (ksyms missing from kabi)"
     longopts["rip-symbols"  ] = "r"  ;								   defaults["rip-symbols"  ] = 1						; descrips["rip-symbols"  ] = "attempt to rip undefined symbols from system map (requires -F, implies -U)"
     longopts["rip-weak"     ] = "R"  ;								   defaults["rip-weak"     ] = 1						; descrips["rip-weak"     ] = "attempt to rip weak undefined symbols from system map (requires -F, implies -U)"
@@ -1995,7 +2023,7 @@
     values["silent"       ] = defaults["silent"       ]
     values["debug"        ] = defaults["debug"        ]
     values["verbose"      ] = defaults["verbose"      ]
-    optstring = "M:c:k:d:F:i:o:s:*P:K:S:grRbUwWHf:umaxp:enqD::v::hVC"
+    optstring = "M:c:k:d:F:i:o:s:*P:K:L:S:grRbUwWHf:umaxp:enqD::v::hVC"
     optind = 0
     #opts = ""; for (i=1;i<ARGC;i++) { if (i == 1) { opts = ARGV[i] } else { opts = opts " " ARGV[i] } }
     #print me ": D: o: command line: " opts > stderr; written[stderr] = 1
@@ -2004,7 +2032,7 @@
 	c = getopt_long(ARGC, ARGV, optstring, longopts)
 	#if (c != -1) { print me ": D: o: option -" c ", longopt --" option ", optset = " optset ", optarg = " optarg > stderr; written[stderr] = 1 }
 	if (c == -1) break
-	else if (c ~ /[MckdFiosPKSfp]/)			{ values[option] = optarg }
+	else if (c ~ /[MckdFiosPKLSfp]/)		{ values[option] = optarg }
 	else if (c ~ /[grRbUwWHumaxenq]/)		{ values[option] = optset }
 	else if (c~/[Dv]/) { if (optarg != "")		{ values[option] = optarg } else { if (optset)  { values[option]++ } else { values[option] = optset } } }
 	else if (c~/[hVC]/)	{ command = option }
@@ -2096,16 +2124,24 @@
 	    else
 		print_error("r: moduledir, directory not found")
 	}
+	values["kabi"] = 0
 	if (("ksymsets" in values) && values["ksymsets"])
 	    values["kabi"] = read_symsets(values["ksymsets"], "kabi", "syssymset")
 	else {
-	    values["kabi"] = 0
 	    file = "symsets-" kversion ".tar.gz"
 	    if (system("test -r /boot/" file) == 0) {
 		values["kabi"] = values["kabi"] + read_symsets("/boot/" file, "kabi", "syssymset")
 	    }
 	    if (system("test -r /lib/modules/" kversion "/build/" file) == 0) {
 		values["kabi"] = values["kabi"] + read_symsets("/lib/modules/" kversion "/build/" file, "kabi", "syssymset")
+	    }
+	}
+	if (("whitelist" in values) && values["whitelist"])
+	    values["kabi"] = read_whitelist(values["whitelist"], "kabi", "whitelist")
+	else {
+	    file = "kabi_whitelist_" cpu
+	    if (system("test -r /lib/modules/kabi/" file) == 0) {
+		values["kabi"] = read_whitelist("/lib/modules/kabi/" file, "kabi", "whitelist")
 	    }
 	}
     }


Regress because of errors.

Regress because of errors.

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -4,8 +4,8 @@
 BEGIN {
   FS="\t"
   pn = 0
-    str = "date +%m-%d-%Y";
-    str | getline date;
+    #str = "date +%m-%d-%Y";
+    #str | getline date;
     #close str;
 }
 $3>date
@@ -125,7 +125,7 @@
     }

   printf "\n"
-  printf "%s", date
-  printf "\n"
+  #printf "%s", date
+  #printf "\n"
 }


Fix comment

Fix comment

--- scripts/PostalImportPostgreSQL.awk
+++ scripts/PostalImportPostgreSQL.awk
@@ -1,5 +1,4 @@
-# Take CSV and turn it into Procedure Calls PorgreSQL
-# Copyright (c) 2014 Stephen A Jazdzewski
+# Take TSV and turn it into Procedure Calls PorgreSQL
 BEGIN {
  FS = OFS = "\t";
  # $1 Country Code


add html tags

add html tags


correcting use getReply

correcting use getReply

--- gawk/ch04/ch04.awk
+++ gawk/ch04/ch04.awk
@@ -164,6 +164,6 @@
       zremrangebyrank(p,"viewed:"token, 0, -26)
       zincrby(p,"viewed:", -1, item)
     }
-    while((getReply(p,REPLY))!=-1 && ERRNO=="")
-       { }
+    for(ERRNO="" ; ERRNO="" ; var=getReply(p,REPLY)) ;
+    ERRNO==""
 }


[1] Fixed day one bug in peruse awk script. TESTING

--- Hazer/bin/peruse.awk
+++ Hazer/bin/peruse.awk
@@ -1,9 +1,9 @@
-# Copyright 2020 Digital Aggregates Corporation, Colorado, USA
+# Copyright 2021 Digital Aggregates Corporation, Colorado, USA
 # Licensed under the terms in LICENSE.txt
 # Chip Overclock <coverclock@diag.com>
 # https://github.com/coverclock/com-diag-hazer
-begin   { inp="INP [   ]"; out="OUT [   ]"; arm=1; }
+BEGIN   { inp="INP [  0]"; out="OUT [  0]"; arm=1; }
 /^INP / { inp=substr($0,0,79); arm=1; next; }
 /^OUT / { out=substr($0,0,79); arm=1; next; }
         { if (arm!=0) { print inp; print out; arm=0; } print $0; next; }
-end     { if (arm!=0) { print inp; print out; arm=0; } }
+END     { if (arm!=0) { print inp; print out; arm=0; } }


Simplify ft handling in snip

Simplify ft handling in snip

--- bin/snip.awk
+++ bin/snip.awk
@@ -51,14 +51,8 @@
   }
 }

-# no ft, skip
-ft == "" {
-  print
-  next
-}
-
 # exact matches, w/ ft
-{
+ft {
   result = FIXED[ft ":" $0]
   if (result) {
     print result
@@ -67,7 +61,7 @@
 }

 # prefix matches, w/ ft
-{
+ft {
   for (k in PREFIX) {
     if (index(k, ft ":" $0) == 1) {
       print PREFIX[k]


pack (unused) structures like pcidevs is

--- dev/cardbus/devlist2h.awk
+++ dev/cardbus/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.3 2000/05/15 06:31:37 niklas Exp $
+#	$OpenBSD: devlist2h.awk,v 1.4 2001/01/27 21:15:27 deraadt Exp $
 #	$NetBSD: devlist2h.awk,v 1.1 1999/10/15 06:07:22 haya Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -161,28 +161,13 @@

 	printf("\n") > dfile

-	printf("struct cardbus_knowndev cardbus_knowndevs[] = {\n") > dfile
+	printf("struct cardbus_known_product cardbus_known_product[] = {\n") \
+	    > dfile
 	for (i = 1; i <= nproducts; i++) {
 		printf("\t{\n") > dfile
 		printf("\t    CARDBUS_VENDOR_%s, CARDBUS_PRODUCT_%s_%s,\n",
 		    products[i, 1], products[i, 1], products[i, 2]) \
 		    > dfile
-		printf("\t    ") > dfile
-		printf("0") > dfile
-		printf(",\n") > dfile
-
-		vendi = vendorindex[products[i, 1]];
-		printf("\t    \"") > dfile
-		j = 3;
-		needspace = 0;
-		while (vendors[vendi, j] != "") {
-			if (needspace)
-				printf(" ") > dfile
-			printf("%s", vendors[vendi, j]) > dfile
-			needspace = 1
-			j++
-		}
-		printf("\",\n") > dfile

 		printf("\t    \"") > dfile
 		j = 4;
@@ -197,11 +182,13 @@
 		printf("\",\n") > dfile
 		printf("\t},\n") > dfile
 	}
+	printf("\t{ 0, 0, NULL }\n") > dfile
+	printf("};\n\n") > dfile
+
+	printf("struct cardbus_known_vendor cardbus_known_vendors[] = {\n") > dfile
 	for (i = 1; i <= nvendors; i++) {
 		printf("\t{\n") > dfile
 		printf("\t    CARDBUS_VENDOR_%s, 0,\n", vendors[i, 1]) \
-		    > dfile
-		printf("\t    CARDBUS_KNOWNDEV_NOPROD,\n") \
 		    > dfile
 		printf("\t    \"") > dfile
 		j = 3;
@@ -214,9 +201,8 @@
 			j++
 		}
 		printf("\",\n") > dfile
-		printf("\t    NULL,\n") > dfile
 		printf("\t},\n") > dfile
 	}
-	printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
+	printf("\t{ 0, 0, NULL }\n") > dfile
 	printf("};\n") > dfile
 }


new vendor id for Phoenix Technologies

new vendor id for Phoenix Technologies

Appeared with Acer Aspire V5-571's BIOS vendor.

--- scripts/lib/awk/fwts/bios_info.awk
+++ scripts/lib/awk/fwts/bios_info.awk
@@ -106,6 +106,10 @@
   vendor = tolower(vendor);

   switch (vendor) {
+    # Phoenix Technologies Ltd.
+    case /phoenix/:
+      return "phoenix"
+
     # Intel Corp.
     case /intel/:
       return "intel";


Drop now hidden ioctl(2) operations for NetBSD

POWER_IOC_GET_TYPE_WITH_LOSSAGE is no longer accessible from userland.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@345572 91177308-0d34-0410-b5e6-96231b3b80d8

--- utils/generate_netbsd_ioctls.awk
+++ utils/generate_netbsd_ioctls.awk
@@ -314,6 +314,7 @@
       $0 ~ /PRIQ_IF_DETACH/ ||
       $0 ~ /PRIQ_ENABLE/ ||
       $0 ~ /WFQ_IF_ATTACH/ ||
+      $0 ~ /POWER_IOC_GET_TYPE_WITH_LOSSAGE/ ||
       $0 ~ /HFSC_DEL_FILTER/) {
     # There are entries with duplicate codes.. disable the less used ones
     next
@@ -345,17 +346,12 @@

   # This !NONE check allows to skip some unparsable entries
   if (ioctl_mode[ioctl_table_max] != "NONE") {
-    # special cases first
-    if ($0 ~ /POWER_IOC_GET_TYPE_WITH_LOSSAGE/) {
-      ioctl_type[ioctl_table_max] = "sizeof(uptr)"
-    } else {
-      n = split($0, a, ",")
-      if (n == 3) {
-        gsub(/^[ ]+/, "", a[3])
-        match(a[3], /[a-zA-Z0-9_* ]+/)
-        type = get_type(substr(a[3], 0, RLENGTH))
-        ioctl_type[ioctl_table_max] = type
-      }
+    n = split($0, a, ",")
+    if (n == 3) {
+      gsub(/^[ ]+/, "", a[3])
+      match(a[3], /[a-zA-Z0-9_* ]+/)
+      type = get_type(substr(a[3], 0, RLENGTH))
+      ioctl_type[ioctl_table_max] = type
     }
   }


Drop unused functions.

Drop unused functions.

--- src/cloudfront.awk
+++ src/cloudfront.awk
@@ -1,21 +1,3 @@
-function printUrlQueryString(queryString, j)
-{
-    split(queryString, pairs, "&")
-    for (j = 1; j < len; ++j) {
-        split(pairs[j], keyValue, "=")
-        k = keyValue[1]
-        v = keyValue[2]
-        result[k] = v
-    }
-    return result
-}
-
-function base64Decode(thing)
-{
-  "echo "$thing" | base64 --decode" | getline x
-  return x
-}
-
 function urlDecode(url, i) {
     for (i = 0x20; i < 0x40; ++i) {
         repl = sprintf("%c", i);


-discontinuity mode

-discontinuity mode

--- packager/bin/anal_nginx_log_packager.awk
+++ packager/bin/anal_nginx_log_packager.awk
@@ -89,7 +89,7 @@
     if(segment_index){
         if(segment_index == tmp1 - 1){
             if(segment_start_time+segment_duration != tmp2){
-                printf (" chunk %d adjucent chunks  differ: diff: %d prev={ %d  %d}  cur={%d %d}",tmp1,
+                printf (" chunk %d adjucent chunks  differ: diff: %d prev={ %d  %d}  cur={%d %d}\n",tmp1,
                 (tmp2-segment_start_time+segment_duration),
                 segment_start_time,
                 segment_duration,


Enable the generated fzn-python file to take different restart parameters.

--- fzn/fzn2py.awk
+++ fzn/fzn2py.awk
@@ -265,7 +265,7 @@
 	print "model, output_vars = get_model()";
 	print output_vars " = output_vars";
 	print "solvers = ['Mistral', 'SCIP', 'MiniSat', 'Toulbar2', 'Gurobi']";
-	print "default = dict([('solver', 'Mistral'), ('verbose', 0), ('tcutoff', 900), ('var', 'DomainOverWDegree'), ('val', 'Lex'), ('rand', 2), ('threads', 1)])";
+	print "default = dict([('solver', 'Mistral'), ('verbose', 0), ('tcutoff', 900), ('var', 'DomainOverWDegree'), ('val', 'Lex'), ('rand', 2), ('threads', 1), ('restart', GEOMETRIC), ('base', 256), ('factor', 1.3)])";
 	print "param = input(default)";
 	print "solver = model.load(param['solver'])";
 	print "solver.setVerbosity(param['verbose'])";
@@ -274,7 +274,10 @@
 	print "if param['solver'] == 'Gurobi':";
 	print "    solver.setThreadCount(param['threads'])";
 	print "if param['solver'] == 'Mistral':";
-	print "    solver.solveAndRestart(GEOMETRIC, 256, 1.3)";
+	print "    # LUBY, GEOMETRIC = 0, 1"
+	print "    # print 'running %d %d %.1f' % (param['restart'], param['base'], param['factor'])";
+	#print "    solver.solveAndRestart(GEOMETRIC, 256, 1.3)";
+	print "    solver.solveAndRestart(param['restart'], param['base'], param['factor'])";
 	print "else:";
 	print "    solver.solve()";
 	print "if solver.is_sat():"
@@ -301,6 +304,7 @@
 	print "    print '=====UNKNOWN====='"
 	print "print '% SolveTime', solver.getTime()";
 	print "print '% Nodes', solver.getNodes()";
+	print "print '% Failures', solver.getFailures()";
 	if (objective) print "if solver.is_sat(): print '% Objective', (solver.getOptimum() if param['solver'] == 'Toulbar2' else " objective ".get_value())";
 	}
 }


fix stringize.awk to work with gawk-4.0.0 and gawk-3.1.8 - fix suggested by arnold@skeeve.com


Put decent prefixes in the symbolic constants for GIO IDs in the generated files, for them to become useful.

--- arch/sgi/gio/devlist2h.awk
+++ arch/sgi/gio/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.1 2012/03/28 20:44:23 miod Exp $
+#	$OpenBSD: devlist2h.awk,v 1.2 2012/04/18 17:18:10 miod Exp $
 #	$NetBSD: devlist2h.awk,v 1.5 2008/05/02 18:11:05 martin Exp $
 #
 # Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -140,10 +140,11 @@

 	printf("\n") > hfile
 	for (i = 1; i <= nproducts; i++) {
-		printf("#define %s\t%s\t/* %s */\n", products[i, 1], products[i,2], products[i, 3]) > hfile
+		printf("#define GIO_PRODUCT_%s\t%s\t/* %s */\n",
+		    products[i, 1], products[i,2], products[i, 3]) > hfile

-		printf("\t{ %s, \"%s\" },\n",
-		    products[i, 2], products[i, 3]) > dfile
+		printf("\t{ GIO_PRODUCT_%s, \"%s\" },\n",
+		    products[i, 1], products[i, 3]) > dfile
 	}
 	printf("\t{ 0, NULL }\n") > dfile
 	printf("};\n") > dfile


Fix a problem with recent wireshark versions.  Those seem to add
a column after the frame number.

git-svn-id: 392d0e5ce652024192c571322d40dcc23d6d83b0@120 8a65f31f-a56f-4bd6-98e8-2755f64920ec

--- scripts/long2html.awk
+++ scripts/long2html.awk
@@ -7,7 +7,7 @@
 #  printf "
\n" >filename;
 #  discard = 0;
 #}
-/^Frame [0-9]+ (.*)/ {
+/^Frame [0-9]+: (.*)/ {
   # New frame, closing
 and html> from previous frame before compute new filename
   if (first==0){
     print "
" >filename;
@@ -15,7 +15,9 @@
   else{
     first=0;
   }
-  filename = destDir "/frames/Frame" $2 ".html";
+  nbr = $2
+  sub (":", "", nbr)
+  filename = destDir "/frames/Frame" nbr ".html";
   printf "\n" >filename;
   printf "
\n" >filename;
   print $0 >filename;


Substitute "[:space:]" with the character constants it expands to.
This was a silent 'failure' when using Bell-Labs awk.

Submitted by:	David Wolfskill <david@catwhisker.org>

--- sys/boot/ficl/softwords/softcore.awk
+++ sys/boot/ficl/softwords/softcore.awk
@@ -6,9 +6,6 @@
 #
 # 02-oct-1999:  Cleaned up awk slightly; added some additional logic
 #               suggested by dcs to compress the stored forth program.
-#
-# Note! This script uses strftime() which is a gawk-ism, and the
-# POSIX [[:space:]] character class.
 #
 # $FreeBSD$

@@ -37,7 +34,7 @@
 {
   gsub(/\t/, "    ");			# replace each tab with 4 spaces
   gsub(/\"/, "\\\"");			# escape quotes
-  gsub(/\\[[:space:]]+$/, "");		# toss empty comments
+  gsub(/\\[ 	]+$/, "");		# toss empty comments
 }

 # strip out empty lines
@@ -47,9 +44,9 @@
 }

 # emit / ** lines as multi-line C comments
-/^\\[[:space:]]\*\*/ \
+/^\\[ 	]\*\*/ \
 {
-  sub(/^\\[[:space:]]/, "");
+  sub(/^\\[ 	]/, "");
   if (commenting == 0) printf "/*\n";
   printf "%s\n", $0;
   commenting = 1;
@@ -57,7 +54,7 @@
 }

 # strip blank lines
-/^[[:space:]]*$/ \
+/^[ 	]*$/ \
 {
   next;
 }
@@ -70,10 +67,10 @@
 }

 # pass commented preprocessor directives
-/^\\[[:space:]]#/ \
+/^\\[ 	]#/ \
 {
   if (commenting) end_comments();
-  sub(/^\\[[:space:]]/, "");
+  sub(/^\\[ 	]/, "");
   printf "%s\n", $0;
   next;
 }
@@ -86,31 +83,31 @@
 }

 # lop off trailing \ comments
-/\\[[:space:]]+/ \
+/\\[ 	]+/ \
 {
-  sub(/\\[[:space:]]+.*$/, "");
+  sub(/\\[ 	]+.*$/, "");
 }

 # expunge ( ) comments
-/[[:space:]]+\([[:space:]][^)]*\)/ \
+/[ 	]+\([ 	][^)]*\)/ \
 {
-  sub(/[[:space:]]+\([[:space:]][^)]*\)/, "");
+  sub(/[ 	]+\([ 	][^)]*\)/, "");
 }

 # remove leading spaces
-/^[[:space:]]+/ \
+/^[ 	]+/ \
 {
-  sub(/^[[:space:]]+/, "");
+  sub(/^[ 	]+/, "");
 }

 # removing trailing spaces
-/[[:space:]]+$/ \
+/[ 	]+$/ \
 {
-  sub(/[[:space:]]+$/, "");
+  sub(/[ 	]+$/, "");
 }

 # strip out empty lines again (preceding rules may have generated some)
-/^[[:space:]]*$/ \
+/^[ 	]*$/ \
 {
   if (commenting) end_comments();
   next;


Fix world-breaking bug, add $FreeBSD$ tag.

This happened to be my first "for real" broken world. I had broken
it once before, but nobody noticed, so it didn't count.

So, how do I get the "I broke world and all I got was the lousy t-shirt"
t-shirt?

--- sys/boot/ficl/softwords/softcore.awk
+++ sys/boot/ficl/softwords/softcore.awk
@@ -1,6 +1,7 @@
 #!/usr/bin/awk -f
 # Convert forth source files to a giant C string
 # Joe Abley <jabley@patho.gen.nz>, 12 January 1999
+# $FreeBSD$

 BEGIN \
 {
@@ -91,6 +92,6 @@
   printf "    \"quit \";\n";
   printf "\n\nvoid ficlCompileSoftCore(FICL_VM *pVM)\n";
   printf "{\n";
-  printf "    assert(ficlExec(pVM, softWords, -1) != VM_ERREXIT);\n";
+  printf "    assert(ficlExec(pVM, softWords) != VM_ERREXIT);\n";
   printf "}\n";
 }


Check named_enable rather than just named_flags. PR:		3893 (sort of)

--- usr.sbin/ndc/ndcedit.awk
+++ usr.sbin/ndc/ndcedit.awk
@@ -1,4 +1,4 @@
-# $Id: ndcedit.awk,v 1.4 1997/02/22 16:08:19 peter Exp $
+# $Id: ndcedit.awk,v 1.5 1997/05/27 07:19:57 jkh Exp $
 NR == 3 {
 	print "#"
 	print "# This file is generated automatically, do not edit it here!"
@@ -13,8 +13,8 @@
 }
 {
 	if ($1 == "named") {
-		printf "\t\t# $namedflags is imported from /etc/rc.conf\n"
-		printf "\t\tif [ \"X${named_flags}\" != X\"NO\" ]; then\n"
+		printf "\t\t# $named_flags is imported from /etc/rc.conf\n"
+		printf "\t\tif [ \"X${named_enable}\" = X\"YES\" ]; then\n"
 		printf "\t\t\tnamed ${named_flags} && {\n"
 		getline
 		printf "\t%s\n", $0


get @BASE prefix working

get @BASE prefix working

--- scripts/ntriple2dot.awk
+++ scripts/ntriple2dot.awk
@@ -19,7 +19,7 @@

 ##########################################################
 # remove first and last chars from input string <>
-function trim(str){
+function trim(str){
 	return substr(str,2,length(str)-2)
 }

@@ -27,7 +27,7 @@
 # remove final(ish) element in paths with various delimiters
 # this leaves the namespace of a removed identifier

-# this may need to be called more than once since
+# this may need to be called more than once since
 # some identifiers may have embedded delimiters
 function stripid(uri){
 	# <_:blanknode> are not allowed in ntriples (but may happen anyway)
@@ -44,13 +44,14 @@
 			delim[char] = RLENGTH
 		}
 	}
-	if(max<=0) # we don't know what it is, a literal perhaps or uri fragment
+	if(max<=0 || char=="")
+		# we don't know what it is, a literal perhaps or uri fragment
 		return uri
-	else
+	else
 		return substr(uri,1,delim[char])  # the probably truncated uri
 }

-# keep underscore, letters & numbers
+# keep underscore, letters & numbers
 # change the rest to (a single) underscore sans leading & trailing
 # this passes valid node labels from dot's perspective
 function simplify(str){
@@ -66,15 +67,14 @@
 	# shorten till longest uri in curi map is found (or not)
 	while(!(u in prefix) && (0 < length(u)))
 		u = stripid(substr(u,1,length(u)-1))
-
 	if(u in prefix)
 		return prefix[u]
-	else
+	else
 		for(ex in exception){
-			if(0 < match(uri, ex))
-				return exception[substr(uri, 1, RLENGTH)]
+			if((0 < match(uri, ex)) && exception[substr(uri,1,RLENGTH)])
+				return exception[substr(uri,1,RLENGTH)]
 		}
-		return "___" simplify(uri)
+		return "___" simplify(uri)
 }

 # get the final (incl fragment identifier) portion of a slashed path
@@ -88,7 +88,10 @@
 }

 BEGIN{
-	prefix["BNODE"] = "BNODE"  # is a fixed point
+	prefix["BNODE"]="BNODE"  # is a fixed point
+	prefix["https://monarchinitiative.org/_"]="BNODE"
+	# just until skolemized bnodes get in the curie map?
+	exception["https://monarchinitiative.org/.well-known/genid"]="BNODE"
 	# revisit if exceptions are still necessary
 	exception["http://www.w3.org/1999/02/22-rdf-syntax-ns#"]="rdf"
 	exception["http://www.w3.org/2000/01/rdf-schema#"]="rdfs"
@@ -97,10 +100,9 @@
 	exception["https://www.mousephenotype.org"]="IMPC"
 	# in panther
 	exception["http://identifiers.org/wormbase"]="WormBase"
-	# just until skolemized bnodes get in the curie map?
-	exception["https://monarchinitiave.org/.well-known/genid"]="BNODE"
 	# till all non httpS: are purged
-	exception["http://monarchinitiave.org"]="MONARCH"
+	exception["http://monarchinitiative.org/"]="BASE"
+	exception["https://monarchinitiative.org/MONARCH_"]="MONARCH"
 }

 # main loop
@@ -110,6 +112,8 @@
 # (FNR == NR) && /^'[^']*' *: 'http[^']*'.*/ { # loosing some?
 (FNR == NR) && /^'.*/ {
 	split($0, arr, "'")
+	if(arr[2]=="")
+		arr[2]="BASE"
 	prefix[arr[4]]=arr[2]
 }
 # process the ntriple file(s)  which are not the first file
@@ -153,6 +157,5 @@
 	datestamp = strftime("%Y%m%d", systime())
 	print "label=\"" substr(title,1,length(title)-3) " (" datestamp ")\";"
 	print "}"
-
 }


ahrf.awk: Rework paragraph. Each word is now handled separately (was only managing lines before). It is much more efficient and allow us more flexibility.

--- ahrf.awk
+++ ahrf.awk
@@ -28,15 +28,21 @@
 # Paragraph
 /^[A-Za-z0-9_("]+/ {
 	printf("
")
-	for (p=1; p<NF; p++) {
-		if ($p ~ / +$/) {
-			gsub(/ +$/,"",$p)
-			printf("%s
\n", $p)
-		} else {
-			printf("%s\n", $p)
+	for (p=1; p<=NF; p++) {
+		# Line break
+		gsub(/ +$/,"
\n",$p)
+		x = split($p,word," ")
+		for (w=1; w<=x; w++) {
+			printf("%s", word[w])
+			# If EOL is not reached, add a space
+			if (w != x)
+				printf(" ")
 		}
+		# If it's the last paragraph line, close the paragraph
+		if (p == NF)
+			printf("
")
+		printf("\n")
 	}
-	printf("%s
\n", $p)
 	next
 }


prefer LC_CTYPE to LANG * fix Debian#762138 (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=762138)

--- include/Languages.awk
+++ include/Languages.awk
@@ -520,8 +520,12 @@

 # Initialize `UserLang`.
 function initUserLang() {
-    UserLang = ENVIRON["LANG"] ? parseLang(ENVIRON["LANG"]) : "en"
-
-    if (!(ENVIRON["LANG"] ~ /UTF-8$/))
-        w("[WARNING] Your codeset of locale (" ENVIRON["LANG"] ") is not UTF-8. You have been warned.")
-}
+    UserLang = ENVIRON["LC_CTYPE"] ?
+        parseLang(ENVIRON["LC_CTYPE"]) :
+        (ENVIRON["LANG"] ?
+         parseLang(ENVIRON["LANG"]) :
+         "en")
+
+    if (ENVIRON["LANG"] !~ /UTF-8$/ && ENVIRON["LC_CTYPE"] !~ /UTF-8$/)
+        w("[WARNING] Your locale codeset (" ENVIRON["LANG"] ") is not UTF-8. You have been warned.")
+}


get terminal columns if COLUMNS not found

--- include/Main.awk
+++ include/Main.awk
@@ -31,7 +31,12 @@
     Option["debug"] = 0

     Option["verbose"] = 1
-    Option["width"] = ENVIRON["COLUMNS"] ? ENVIRON["COLUMNS"] : 64
+    if (ENVIRON["COLUMNS"])
+        Option["width"] = ENVIRON["COLUMNS"]
+    else {
+        "tput cols 2>/dev/null" |& getline Option["width"]
+        if (!Option["width"]) Option["width"] = 64
+    }

     Option["browser"] = ENVIRON["BROWSER"]


Do not increment stale count to infinity

--- RPi_system/asic_data_cache.awk
+++ RPi_system/asic_data_cache.awk
@@ -115,6 +115,7 @@
       asic_type_cnt[asic] = 0;
     } else {
       if (++asic_type_cnt[asic] > STALE_COUNT) {
+        asic_type_cnt[asic] = STALE_COUNT + 1;
         type = "OFF";
       } else {
         type = asic_type_cache[asic];
@@ -125,6 +126,7 @@
       asic_temp_cnt[asic] = 0;
     } else {
       if (++asic_temp_cnt[asic] > STALE_COUNT) {
+        asic_temp_cnt[asic] = STALE_COUNT + 1;
         temp = 0.0;
       } else {
         temp = asic_temp_cache[asic];
@@ -136,6 +138,7 @@
         asic_freq_cnt[asic, die] = 0;
       } else {
         if (++asic_freq_cnt[asic, die] > STALE_COUNT) {
+          asic_freq_cnt[asic, die] = STALE_COUNT + 1;
           freq[die] = 0.0;
         } else {
           freq[die] = asic_freq_cache[asic, die];
@@ -146,6 +149,7 @@
         asic_volt_cnt[asic, die] = 0;
       } else {
         if (++asic_volt_cnt[asic, die] > STALE_COUNT) {
+          asic_volt_cnt[asic, die] = STALE_COUNT + 1;
           volt[die] = 0.0;
         } else {
           volt[die] = asic_volt_cache[asic, die];
@@ -158,6 +162,7 @@
 	asic_dcdctemp_cnt[asic, dcdc] = 0;
       } else {
         if (++asic_dcdctemp_cnt[asic, dcdc] > STALE_COUNT) {
+          asic_dcdctemp_cnt[asic, dcdc] = STALE_COUNT + 1;
           dcdctemp[dcdc] = 0.0;
         } else {
           dcdctemp[dcdc] = asic_dcdctemp_cache[asic, dcdc];
@@ -168,6 +173,7 @@
 	asic_dcdcVout_cnt[asic, dcdc] = 0;
       } else {
         if (++asic_dcdcVout_cnt[asic, dcdc] > STALE_COUNT) {
+          asic_dcdcVout_cnt[asic, dcdc] = STALE_COUNT + 1;
           dcdcVout[dcdc] = 0.0;
         } else {
           dcdcVout[dcdc] = asic_dcdcVout_cache[asic, dcdc];
@@ -178,6 +184,7 @@
 	asic_dcdcIout_cnt[asic, dcdc] = 0;
       } else {
         if (++asic_dcdcIout_cnt[asic, dcdc] > STALE_COUNT) {
+          asic_dcdcIout_cnt[asic, dcdc] = STALE_COUNT + 1;
           dcdcIout[dcdc] = 0.0;
         } else {
           dcdcIout[dcdc] = asic_dcdcIout_cache[asic, dcdc];


Translators/GoogleTranslate: switch to fallback API, fix (partly) #123

--- include/Translators/GoogleTranslate.awk
+++ include/Translators/GoogleTranslate.awk
@@ -48,21 +48,21 @@

 function googleInit() {
     HttpProtocol = "http://"
-    HttpHost = "translate.google.com"
+    HttpHost = "translate.googleapis.com"
     HttpPort = 80
 }

 function googleRequestUrl(text, sl, tl, hl) {
-    return HttpPathPrefix "/translate_a/single?client=t"                \
+    return HttpPathPrefix "/translate_a/single?client=gtx"              \
         "&ie=UTF-8&oe=UTF-8"                                            \
         "&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at"  \
         "&sl=" sl "&tl=" tl "&hl=" hl                                   \
-        "&tk=" genTK(text) "&q=" preprocess(text)
+        "&q=" preprocess(text)
 }

 function googleTTSUrl(text, tl) {
-    return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=t"	\
-        "&tl=" tl "&tk=" genTK(text) "&q=" preprocess(text)
+    return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=gtx"	\
+        "&tl=" tl "&q=" preprocess(text)
 }

 function googleWebTranslateUrl(uri, sl, tl, hl) {


Update filter_en_uk.awk

Update filter_en_uk.awk

Added spacing using a JavaScript online service I hope nothing breaks

--- filter_en_uk.awk
+++ filter_en_uk.awk
@@ -1,45 +1,109 @@
 BEGIN {}
 /^macro:[:alpha: ]+/ {
-    macroLine=""
-    # I check every field from the second one (the first one is "macro:")
-    for(x=2;x<=NF;x++){
-        do{
+    macroLine = ""
+    # I check every field from the second one(the first one is "macro:")
+    for (x = 2; x <= NF; x++) {
+        do {
             # I found a keys being kept pressed or just released, I print it as it is
             # This works because (probably) I don't want to keep pressed keys that need to be translated such as symbols
-            if(length($x)>1&&(substr($x,1,1)=="+"||substr($x,1,1)=="-")){macroLine=macroLine $x; break;}
-            # An upper-case key, I need to press shift to do it. Using the !=toupper I avoid triggering things like ","==tolower(",") and ","==toupper(",")
-            if($x!=tolower($x)){macroLine=macroLine "+lshift," "+" tolower($x) ",-" tolower($x) ",-lshift"; break;}
-            if($x=="`"){ macroLine=macroLine "+grave,-grave"; break;}
-            if($x=="-"){ macroLine=macroLine "+minus,-minus"; break;}
-            if($x=="["){ macroLine=macroLine "+lbrace,-lbrace"; break;}
-            if($x=="]"){ macroLine=macroLine "+rbrace,-rbrace"; break;}
-            if($x==";"){ macroLine=macroLine "+colon,-colon"; break;}
-            if($x=="'"){ macroLine=macroLine "+quote,-quote"; break;}
-            if($x=="\\"){ macroLine=macroLine "+bslash_iso,-bslash_iso"; break;}
-            if($x==","){ macroLine=macroLine "+comma,-comma"; break;}
-            if($x=="."){ macroLine=macroLine "+dot,-dot"; break;}
-            if($x=="#"){ macroLine=macroLine "+hash,-hash"; break;}
-            if($x=="="){ macroLine=macroLine "+equal,-equal"; break;}
-            if($x=="/"){ macroLine=macroLine "+slash,-slash"; break;}
-            #if($x=="/"){ macroLine=macroLine "+numslash,-numslash"; break;}
-            #if($x=="!"){ macroLine=macroLine "+exclam,-exclam"; break;}
-            if($x=="!"){ macroLine=macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+1,-1,-u,-lshift,-lctrl"; break;}
-            if($x=="?"){ macroLine=macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+3,-3,+f,-f,-u,-lshift,-lctrl"; break;}
-            if($x=="("){ macroLine=macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+8,-8,-u,-lshift,-lctrl"; break;}
-            if($x==")"){ macroLine=macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+9,-9,-u,-lshift,-lctrl"; break;}
-            if($x=="\""){ macroLine=macroLine "+lctrl,+lshift,+u,+2,-2,+0,-0,+1,-1,+c,-c,-u,-lshift,-lctrl"; break;}
+            if (length($x) > 1 && (substr($x, 1, 1) == "+" || substr($x, 1, 1) == "-")) {
+                macroLine = macroLine $x;
+                break;
+            }
+            # An upper-case key, I need to press shift to do it. Using the != toupper I avoid triggering things like "," == tolower(",") and "," == toupper(",")
+            if ($x != tolower($x)) {
+                macroLine = macroLine "+lshift,+" tolower($x) ",-" tolower($x) ",-lshift";
+                break;
+            }
+            if ($x == "`") {
+                macroLine = macroLine "+grave,-grave";
+                break;
+            }
+            if ($x == "-") {
+                macroLine = macroLine "+minus,-minus";
+                break;
+            }
+            if ($x == "[") {
+                macroLine = macroLine "+lbrace,-lbrace";
+                break;
+            }
+            if ($x == "]") {
+                macroLine = macroLine "+rbrace,-rbrace";
+                break;
+            }
+            if ($x == ";") {
+                macroLine = macroLine "+colon,-colon";
+                break;
+            }
+            if ($x == "'") {
+                macroLine = macroLine "+quote,-quote";
+                break;
+            }
+            if ($x == "\\") {
+                macroLine = macroLine "+bslash_iso,-bslash_iso";
+                break;
+            }
+            if ($x == ",") {
+                macroLine = macroLine "+comma,-comma";
+                break;
+            }
+            if ($x == ".") {
+                macroLine = macroLine "+dot,-dot";
+                break;
+            }
+            if ($x == "#") {
+                macroLine = macroLine "+hash,-hash";
+                break;
+            }
+            if ($x == "=") {
+                macroLine = macroLine "+equal,-equal";
+                break;
+            }
+            if ($x == "/") {
+                macroLine = macroLine "+slash,-slash";
+                break;
+            }#
+            if ($x == "/") {
+                macroLine = macroLine "+numslash,-numslash";
+                break;
+            }#
+            if ($x == "!") {
+                macroLine = macroLine "+exclam,-exclam";
+                break;
+            }
+            if ($x == "!") {
+                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+1,-1,-u,-lshift,-lctrl";
+                break;
+            }
+            if ($x == "?") {
+                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+3,-3,+f,-f,-u,-lshift,-lctrl";
+                break;
+            }
+            if ($x == "(") {
+                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+8,-8,-u,-lshift,-lctrl";
+                break;
+            }
+            if ($x == ")") {
+                macroLine = macroLine "+lctrl,+lshift,+u,+0,-0,+0,-0,+2,-2,+9,-9,-u,-lshift,-lctrl";
+                break;
+            }
+            if ($x == "\"") {
+                macroLine = macroLine "+lctrl,+lshift,+u,+2,-2,+0,-0,+1,-1,+c,-c,-u,-lshift,-lctrl";
+                break;
+            }

             # A normal key, press and release it, catches all the remaining cases
-            macroLine=macroLine "+" $x ",-" $x
+            macroLine = macroLine "+" $x ",-" $x
         }
-        while(0)  # 0 means it runs only once instead of endlessly looping in case of errors
-
-        if(x<NF)
-        # I add a comma between this key and the next unless I'm at the last one
-            macroLine=macroLine ","
+        while (0)
+        # 0 means it runs only once instead of endlessly looping in case oferrors
+
+        # I add a comma between this key and the next unless I 'm at the last one
+        if (x < NF)
+            macroLine = macroLine ","
         else
-        # sending the macro to the output
+            # Finished reading the macro, sending it macro to the output
             print macroLine
-        }
+    }
 }
 END {}


fix gawk warning

fix gawk warning

--- tools/slidy.awk
+++ tools/slidy.awk
@@ -3,7 +3,7 @@
 }

 {
-    sub(/<title>Haskell: Functional Programming, Solid Code, Big Data<\/title>/, "<title>Intro \"Functional Programming\"<\/title>")
+    sub(/<title>Haskell: Functional Programming, Solid Code, Big Data<\/title>/, "<title>Intro \"Functional Programming\"</title>")
     sub(/<meta name="date" content="2011-09-18" \/>/, "<meta name=\"date\" content=\"2011-10-19\" />")
     sub(/<meta name="author" content="Bryan O'Sullivan" \/>/, "<meta name=\"author\" content=\"Gabor Greif\" />")
 }


Main: cleanup

Main: cleanup

--- include/Main.awk
+++ include/Main.awk
@@ -7,7 +7,7 @@
     initGawk()
     initBiDi()

-    # Languages.awk
+    # (Languages.awk)
     initLocale()
     initUserLang()

@@ -37,7 +37,7 @@
     Option["play"] = 0
     Option["player"] = ENVIRON["PLAYER"]

-    # Terminal paging and web
+    # Terminal paging and browsing
     Option["view"] = 0
     Option["pager"] = ENVIRON["PAGER"]
     Option["browser"] = ENVIRON["BROWSER"]
@@ -79,7 +79,7 @@
         script = script "\n" line
     loadOptions(script)

-    # Hack: Option["tl"] must be an array
+    # HACK: Option["tl"] must be an array
     if (!isarray(Option["tl"])) {
         temp = Option["tl"]
         delete Option["tl"]
@@ -89,7 +89,7 @@

 # Miscellany initialization.
 function initMisc(    group) {
-    # Translate.awk
+    # (Translate.awk)
     initHttpService()

     # Disable ANSI escape codes if required


use the source language code specified by user if it exists in the identified language list; otherwise use the first one in the identified language list (fix #24)

--- include/Translate.awk
+++ include/Translate.awk
@@ -68,7 +68,7 @@
                         isVerbose, toSpeech, returnPlaylist,
                         ####
                         altTranslations, article, ast, content,
-                        explanation, group, i, il,
+                        explanation, group, i, il, ils,
                         isPhonetic, j, original, phonetics,
                         r, rtl, saveSortedIn, segments,
                         temp, tokens, translation, translations,
@@ -128,13 +128,13 @@

         # Identified source languages
         if (i ~ "^0" SUBSEP "8" SUBSEP "0" SUBSEP "[[:digit:]]+$")
-            append(il, literal(ast[i]))
+            append(ils, literal(ast[i]))
     }
     PROCINFO["sorted_in"] = saveSortedIn

     translation = join(translations)

-    if (!anything(il)) il[0] = sl
+    il = belongsTo(sl, ils) ? sl : ils[0]

     # Generate output
     if (!isVerbose) {
@@ -159,19 +159,19 @@
         if (isarray(altTranslations[0]) && anything(altTranslations[0])) {
             # List alternative translations

-            if (Locale[getCode(hl)]["rtl"] || Locale[getCode(il[0])]["rtl"])
+            if (Locale[getCode(hl)]["rtl"] || Locale[getCode(il)]["rtl"])
                 r = r "\n\n" s(sprintf(Locale[getCode(hl)]["message"], join(original))) # caution: mixed languages, BiDi invoked must be implemented correctly (i.e. FriBidi is required)
             else
                 r = r "\n\n" sprintf(Locale[getCode(hl)]["message"], join(original))
-            if (Locale[getCode(il[0])]["rtl"] || Locale[getCode(tl)]["rtl"])
-                r = r "\n" s("(" Locale[getCode(il[0])]["endonym"] " ➔ " Locale[getCode(tl)]["endonym"] ")") # caution: mixed languages
+            if (Locale[getCode(il)]["rtl"] || Locale[getCode(tl)]["rtl"])
+                r = r "\n" s("(" Locale[getCode(il)]["endonym"] " ➔ " Locale[getCode(tl)]["endonym"] ")") # caution: mixed languages
             else
-                r = r "\n" "(" Locale[getCode(il[0])]["endonym"] " ➔ " Locale[getCode(tl)]["endonym"] ")"
+                r = r "\n" "(" Locale[getCode(il)]["endonym"] " ➔ " Locale[getCode(tl)]["endonym"] ")"

             temp = segments[0] "(" join(altTranslations[0], "/") ")"
             for (i = 1; i < length(altTranslations); i++)
                 temp = temp " " segments[i] "(" join(altTranslations[i], "/") ")"
-            if (Locale[getCode(il[0])]["rtl"] || Locale[getCode(tl)]["rtl"])
+            if (Locale[getCode(il)]["rtl"] || Locale[getCode(tl)]["rtl"])
                 r = r "\n" AnsiCode["bold"] s(temp) AnsiCode["no bold"] # caution: mixed languages
             else
                 r = r "\n" AnsiCode["bold"] temp AnsiCode["no bold"]
@@ -191,12 +191,12 @@
                         r = r "\n" AnsiCode["bold"] sprintf("%" Option["width"] - 4 "s", s((article ?
                                                                                "(" article ")" :
                                                                                "") " " word, tl, Option["width"] - 4)) AnsiCode["no bold"] # target language
-                        r = r "\n" s(explanation, il[0], Option["width"] - 8) # identified source language
+                        r = r "\n" s(explanation, il, Option["width"] - 8) # identified source language
                     } else {
                         r = r "\n" "    " AnsiCode["bold"] show((article ?
                                                                  "(" article ") " :
                                                                  "") word, tl) AnsiCode["no bold"] # target language
-                        r = r "\n" "        " s(explanation, il[0], Option["width"] - 8) # identified source language
+                        r = r "\n" "        " s(explanation, il, Option["width"] - 8) # identified source language
                     }
                 }
             }
@@ -207,10 +207,10 @@
                 returnPlaylist[0]["text"] = sprintf(Locale[getCode(hl)]["message"], "")
                 returnPlaylist[0]["tl"] = hl
                 returnPlaylist[1]["text"] = join(original)
-                returnPlaylist[1]["tl"] = il[0]
+                returnPlaylist[1]["tl"] = il
             } else {
                 returnPlaylist[0]["text"] = join(original)
-                returnPlaylist[0]["tl"] = il[0]
+                returnPlaylist[0]["tl"] = il
                 returnPlaylist[1]["text"] = sprintf(Locale[getCode(hl)]["message"], "")
                 returnPlaylist[1]["tl"] = hl
             }


Script: fix unexpected EOF while looking for matching `"' during upgrade()

--- include/Script.awk
+++ include/Script.awk
@@ -73,8 +73,9 @@
     if (newerVersion(newVersion, Version)) {
         trans = curl(TransExecutable)
         if (trans) {
+            print "Successfully upgraded to " newVersion "." > STDERR
             print trans > ENVIRON["TRANS_ABSPATH"]
-            print "Successfully upgraded to " newVersion "." > STDERR
+            exit 0
         } else
             e("[ERROR] Upgrading failed due to network errors.")
     } else


結果数上限に達したら検索を打ち切る

結果数上限に達したら検索を打ち切る

--- www/search.awk
+++ www/search.awk
@@ -20,5 +20,8 @@
 	print
 	R_LIMIT = R_LIMIT - 1
     }
+    if(R_LIMIT <= 0) {
+        exit 0
+    }
     R_OFFSET = R_OFFSET - 1
 }


TINKERPOP-2002 fix tab rendering for static codez

--- docs/preprocessor/awk/tabify.awk
+++ docs/preprocessor/awk/tabify.awk
@@ -26,14 +26,14 @@
   print "++++"
   print "
"

-  for (i in tabs) {
+  for (i = 1; i <= num_tabs; i++) {
     title = tabs[i]
     print "  <input id=\"tab-" id_part "-" x "\" type=\"radio\" name=\"radio-set-" id_part "-" next_id "\" class=\"tab-selector-" i "\"" (i == 1 ? " checked=\"checked\"" : "") " />"
     print "  " title ""
     x++
   }

-  for (i in blocks) {
+  for (i = 1; i<= num_tabs; i++) {
     print "
"
     print "
"
     print "++++\n"


[cc2] Simplifies the error generation script


Fixed gawk internal error in msg_parser.awk.

It looks like some gawk versions had problems when a function argument
was an unitialized variable.

darcs-hash:20060125155720-65a35-06a9a77dbe9abbcf4d305215b2c35f9c1ea36285.gz

--- libsofia-sip-ua/msg/msg_parser.awk
+++ libsofia-sip-ua/msg/msg_parser.awk
@@ -54,6 +54,11 @@
   split("", NAMES);
   split("", Comments);
   split("", COMMENTS);
+
+  template="";
+  template1="";
+  template2="";
+  template3=="";
 }

 function name_hash (name)
@@ -234,8 +239,7 @@

     if (PR) {
       if (TEMPLATE == "") { TEMPLATE = PR ".in"; }
-      RS0=RS; RS="-\n";
+      RS0=RS; RS="\f\n";
       getline theader < TEMPLATE;
       getline header < TEMPLATE;
       getline template < TEMPLATE;


Utils: make sure no mess-up with args

Utils: make sure no mess-up with args


Match Xcode 5's "not testable" string

Match Xcode 5's "not testable" string

--- xcodebuild.awk
+++ xcodebuild.awk
@@ -13,7 +13,7 @@
     fflush(stdout);
 }

-/is not valid for Testing/ {
+/is not testable/ {
     exit 2;
 }


Don't use OFS when outputting errors

Don't use OFS when outputting errors

--- xcodebuild.awk
+++ xcodebuild.awk
@@ -8,7 +8,7 @@
 }

 /(TEST|BUILD) FAILED/ {
-    print "\n", errors
+    print "\n" errors
     fflush(stdout)

     # SYS_SOFTWARE


fix: getline support for OSX

fix: getline support for OSX

--- scripts/atom.awk
+++ scripts/atom.awk
@@ -42,7 +42,8 @@

   # full text -- also converting relative Markdown links to absolute
   printf "    <![CDATA["
-  system("./tools/Markdown_1.0.1/Markdown.pl content" orig " | sed -e 's#href=\"/#href=\"" fqbase "/#g'") |& getline
+#  system("./tools/Markdown_1.0.1/Markdown.pl content" orig " | sed -e 's#href=\"/#href=\"" fqbase "/#g'") |& getline
+  system("./tools/Markdown_1.0.1/Markdown.pl content" orig " | sed -e 's#href=\"/#href=\"" fqbase "/#g'")
   printf "    ]]>\n"

   printf "  </content>\n"