put code handling to the top

put code handling to the top

--- tools/wiki2latex.awk
+++ tools/wiki2latex.awk
@@ -22,6 +22,34 @@
   print "%";
 }

+## HANDLE CODING
+## make sure that control sequences are always at the front
+/ *{{{/ { sub(/ */, "") }
+/ *}}}/ { sub(/ */, "") }
+
+!coding && /^{{{/ {
+  print "\\begin{verbatim}";
+  coding = 1;
+  next;
+}
+
+coding && /^}}}/ {
+  print "\\end{verbatim}";
+  coding = 0;
+  next;
+}
+
+coding {
+  sub(/^/, "{\\small ");
+  print;
+  print "}";
+  next;
+}
+
+## NO CODING BELOW THIS POINT
+coding { print "###code???####"; }
+
+
 ## pragmas do not count
 !coding && /\#labels/ {
   next;
@@ -29,8 +57,6 @@

 ## make sure that control sequences are always at the front
-/ *{{{/ { sub(/ */, "") }
-/ *}}}/ { sub(/ */, "") }
 / *=/ { sub(/ */, "") }

@@ -45,6 +71,8 @@
   print;
   next;
 }
+
+

 quoting && !/^  / {
   print "\\end{quotation}";
@@ -92,28 +120,6 @@
 }

-## tracking code
-
-!coding && /^{{{/ {
-  print "\\begin{verbatim}";
-  coding = 1;
-  next;
-}
-
-coding && /^}}}/ {
-  print "\\end{verbatim}";
-  coding = 0;
-  next;
-}
-
-coding {
-  sub(/^/, "{\\small ");
-  print;
-  print "}";
-  next;
-}
-
-
 !coding && /^  / {
   print "\\begin{quotation}";
   quoting = 1;


msg_parser.awk: now parsing #### EXTRA HEADER LIST #### too.

Added #version# to the template, too.

darcs-hash:20061005165950-65a35-707a6e412da51d6ea5fdecc799a580dde6771c6e.gz

--- libsofia-sip-ua/msg/msg_parser.awk
+++ libsofia-sip-ua/msg/msg_parser.awk
@@ -63,6 +63,8 @@
   tprefix="";
   failed=0;
   success=0;
+
+  ERRNO="error";
 }

 function name_hash (name)
@@ -92,7 +94,7 @@
 #
 # Replace magic patterns in template p with header-specific values
 #
-function protos (name, comment, hash)
+function protos (name, comment, hash, since)
 {
   NAME=toupper(name);
   sub(/.*[\/][*][*][<][ 	]*/, "", comment);
@@ -143,15 +145,18 @@
   symbols[name] = comment;

   if (PR) {
-    replace(template, hash, name, NAME, comment, Comment, COMMENT);
-    replace(template1, hash, name, NAME, comment, Comment, COMMENT);
-    replace(template2, hash, name, NAME, comment, Comment, COMMENT);
-    replace(template3, hash, name, NAME, comment, Comment, COMMENT);
-  }
-}
-
-function replace (p, hash, name, NAME, comment, Comment, COMMENT)
+    replace(template, hash, name, NAME, comment, Comment, COMMENT, since);
+    replace(template1, hash, name, NAME, comment, Comment, COMMENT, since);
+    replace(template2, hash, name, NAME, comment, Comment, COMMENT, since);
+    replace(template3, hash, name, NAME, comment, Comment, COMMENT, since);
+  }
+}
+
+function replace (p, hash, name, NAME, comment, Comment, COMMENT, since)
 {
+  #
+  # Replace various forms of header name in template, print it out
+  #
   if (p) {
     gsub(/#hash#/, hash, p);
     gsub(/#xxxxxx#/, name, p);
@@ -159,6 +164,14 @@
     gsub(/#xxxxxxx_xxxxxxx#/, comment, p);
     gsub(/#Xxxxxxx_Xxxxxxx#/, Comment, p);
     gsub(/#XXXXXXX_XXXXXXX#/, COMMENT, p);
+
+    if (since) {
+      gsub(/#version#/, since, p);
+    }
+    else {
+      # Remove line with #version#
+      gsub(/\n[^\n]*#version#[^\n]*\n/, "\n", p);
+    }

     print p > PR;
   }
@@ -232,10 +245,11 @@
   close(flagfile);
 }

-/^ *\/\* === Headers start here \*\// {
-
-  in_header_list=1;
-
+#
+# Read in templates
+#
+function templates ()
+{
   if (!auto) {
     auto = FILENAME;

@@ -248,27 +262,43 @@
     if (PR) {
       if (TEMPLATE == "") { TEMPLATE = PR ".in"; }
       RS0=RS; RS="\f\n";
-      getline theader < TEMPLATE;
+      if ((getline theader < TEMPLATE) < 0) {
+	print ( TEMPLATE ": " ERRNO );
+	failed=1;
+        exit(1);
+      }
       getline header < TEMPLATE;
       getline template < TEMPLATE;
       getline footer < TEMPLATE;

       if (TEMPLATE1) {
-	getline dummy < TEMPLATE1;
+	if ((getline dummy < TEMPLATE1) < 0) {
+	  print(TEMPLATE1 ": " ERRNO);
+	  failed=1;
+          exit(1);
+        }
 	getline dummy < TEMPLATE1;
 	getline template1 < TEMPLATE1;
 	getline dummy < TEMPLATE1;
       }

       if (TEMPLATE2) {
-	getline dummy < TEMPLATE2;
+	if ((getline dummy < TEMPLATE2) < 0) {
+	  print( TEMPLATE2 ": " ERRNO );
+	  failed=1;
+	  exit(1);
+	}
 	getline dummy < TEMPLATE2;
 	getline template2 < TEMPLATE2;
 	getline dummy < TEMPLATE2;
       }

       if (TEMPLATE3) {
-	getline dummy < TEMPLATE3;
+	if ((getline dummy < TEMPLATE3) < 0) {
+	  print( TEMPLATE3 ": " ERRNO );
+	  failed=1;
+	  exit(1);
+	}
 	getline dummy < TEMPLATE3;
 	getline template3 < TEMPLATE3;
 	getline dummy < TEMPLATE3;
@@ -291,9 +321,15 @@
   }
 }

-in_header_list && /^ *\/\* === Headers end here \*\// { in_header_list=0;}
-
-in_header_list && PT && /^ *\/\* === Hash headers end here \*\// { in_header_list=0;}
+/^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); }
+HLIST && /^[a-z]/ { protos($1, $0, 0, $2); }
+/^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0;  }
+
+
+/^ *\/\* === Headers start here \*\// { in_header_list=1;  templates(); }
+/^ *\/\* === Headers end here \*\// { in_header_list=0; }
+
+PT && /^ *\/\* === Hash headers end here \*\// { in_header_list=0;}

 in_header_list && /^  (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ {
   n=$0


Conver & to plain & in title & description

--- getBBoxCatalogFrom-sitemap.awk
+++ getBBoxCatalogFrom-sitemap.awk
@@ -78,6 +78,7 @@
     split ($0,fld,"[<>]")
     title = fld[3]
     # print "title = " title > "/dev/stderr"
+    gsub (/&/,"\\&",title)
 }

 # Grab genre
@@ -94,6 +95,7 @@
     split ($0,fld,"[<>]")
     description = fld[3]
     # print "description = " description > "/dev/stderr"
+    gsub (/&/,"\\&",description)
 }

 # Grab rating


aux/sys/base/tac.awk: no -r: bugfix: properly escape backslash

--- lib/modernish/aux/sys/base/tac.awk
+++ lib/modernish/aux/sys/base/tac.awk
@@ -45,7 +45,7 @@
 		if (length(FS) == 1)
 			FS = ("(")(FS)(")");		# force parsing as RE
 	} else {
-		gsub(/[\.[(*+?{|^$]/, "\\\\&", FS);	# literal FS: escape ERE characters
+		gsub(/[\\.[(*+?{|^$]/, "\\\\&", FS);	# literal FS: escape awk RE characters
 	}
 	n = split(text, field);


msg_parser.awk: removed extra "const"

msg_parser.awk: removed extra "const"

darcs-hash:20071010173045-65a35-a4def5c5b443d994c2ffbc63f476849a04b88bba.gz

--- libsofia-sip-ua/msg/msg_parser.awk
+++ libsofia-sip-ua/msg/msg_parser.awk
@@ -644,7 +644,7 @@
     }

     if (basic < total) {
-      printf("msg_hclass_t const * const %s_extensions[] = {\n", module) > PT;
+      printf("msg_hclass_t * const %s_extensions[] = {\n", module) > PT;
       for (i = basic; i < total; i++) {
 	if (i == without_experimental) {
 	  print "#if SU_HAVE_EXPERIMENTAL" > PT;


We are OpenBSD

We are OpenBSD

--- dev/cardbus/devlist2h.awk
+++ dev/cardbus/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.1 2000/03/02 23:03:26 aaron Exp $
+#	$OpenBSD: devlist2h.awk,v 1.2 2000/05/15 06:29:09 niklas Exp $
 #	$NetBSD: devlist2h.awk,v 1.1 1999/10/15 06:07:22 haya Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -39,7 +39,7 @@
 	VERSION = $0
 	gsub("\\$", "", VERSION)

-	printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
+	printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
 	printf("/*\n") > dfile
 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
 	    > dfile
@@ -48,7 +48,7 @@
 	printf(" *\t%s\n", VERSION) > dfile
 	printf(" */\n") > dfile

-	printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
+	printf("/*\t\OpenBSD\$\t*/\n\n") > hfile
 	printf("/*\n") > hfile
 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
 	    > hfile


Removed debugging feature from msg_parser.awk making it fail with BSD awk.

darcs-hash:20060224081416-65a35-16d5d37c9d56c34559483d63d0be6d9c0d59e36b.gz

--- libsofia-sip-ua/msg/msg_parser.awk
+++ libsofia-sip-ua/msg/msg_parser.awk
@@ -156,7 +156,7 @@
     gsub(/#Xxxxxxx_Xxxxxxx#/, Comment, p);
     gsub(/#XXXXXXX_XXXXXXX#/, COMMENT, p);

-    print p > PR NEW;
+    print p > PR;
   }
 }

@@ -173,7 +173,7 @@
       text = substr(text, 1, n);
     }
     if (n > 0)
-      print text > PR NEW;
+      print text > PR;
     return;
   }

@@ -190,10 +190,10 @@
 	gsub(/#XXXXXXX_XXXXXXX#/, COMMENTS[j], l);
 	gsub(/#xxxxxx#/, names[j], l);
 	gsub(/#XXXXXX#/, NAMES[j], l);
-	print l > PR NEW;
+	print l > PR;
       }
     } else {
-      print l > PR NEW;
+      print l > PR;
     }
   }
 }
@@ -271,7 +271,7 @@
       gsub(/#DATE#/, "@date Generated: " date, header);
       if (PACKAGE_NAME) gsub(/#PACKAGE_NAME#/, PACKAGE_NAME, header);
       if (PACKAGE_VERSION) gsub(/#PACKAGE_VERSION#/, PACKAGE_VERSION, header);
-      print header > PR NEW;
+      print header > PR;

       RS=RS0;
     }
@@ -339,12 +339,12 @@
     sub(/.*[\/]/, "", TEMPLATE);
     gsub(/#AUTO#/, auto, header);
     gsub(/#DATE#/, "@date Generated: " date, header);
-    print header > PT NEW;
+    print header > PT;

     if (MC_SHORT_SIZE) {
       printf("static msg_href_t const " \
 	     "%s_short_forms[MC_SHORT_SIZE] = \n{\n",
-	     module) > PT NEW;
+	     module) > PT;

       for (i = 1; i <= MC_SHORT_SIZE; i = i + 1) {
 	c = (i == MC_SHORT_SIZE) ? "" : ",";
@@ -355,54 +355,54 @@
 	  printf("  { /* %s */ %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n",
 		 substr(lower_case, i, 1),
 		 tprefix, n, module, prefix, n, flags, c)	\
-	    > PT NEW;
+	    > PT;
 	}
 	else {
 	  printf("  { NULL }%s\n", c) \
-	    > PT NEW;
+	    > PT;
 	}
       }
-      printf("};\n\n") > PT NEW;
-    }
-
-    # printf("extern msg_hclass_t msg_multipart_class[];\n\n") > PT NEW;
-
-    printf("msg_mclass_t const %s_mclass[1] = \n{{\n", module) > PT NEW;
-    printf("# if defined (%s_HCLASS)\n", toupper(module)) > PT NEW;
-    printf("  %s_HCLASS,\n", toupper(module)) > PT NEW;
-    printf("#else\n") > PT NEW;
-    printf("  {{ 0 }},\n") > PT NEW;
-    printf("#endif\n") > PT NEW;
-    printf("  %s_VERSION_CURRENT,\n", toupper(module)) > PT NEW;
-    printf("  %s_PROTOCOL_TAG,\n", toupper(module)) > PT NEW;
-    printf("#if defined (%s_PARSER_FLAGS)\n", toupper(module)) > PT NEW;
-    printf("  %s_PARSER_FLAGS,\n", toupper(module)) > PT NEW;
-    printf("#else\n") > PT NEW;
-    printf("  0,\n") > PT NEW;
-    printf("#endif\n") > PT NEW;
-    printf("  sizeof(%s_t),\n", module) > PT NEW;
-    printf("  %s_extract_body,\n", module) > PT NEW;
+      printf("};\n\n") > PT;
+    }
+
+    # printf("extern msg_hclass_t msg_multipart_class[];\n\n") > PT;
+
+    printf("msg_mclass_t const %s_mclass[1] = \n{{\n", module) > PT;
+    printf("# if defined (%s_HCLASS)\n", toupper(module)) > PT;
+    printf("  %s_HCLASS,\n", toupper(module)) > PT;
+    printf("#else\n") > PT;
+    printf("  {{ 0 }},\n") > PT;
+    printf("#endif\n") > PT;
+    printf("  %s_VERSION_CURRENT,\n", toupper(module)) > PT;
+    printf("  %s_PROTOCOL_TAG,\n", toupper(module)) > PT;
+    printf("#if defined (%s_PARSER_FLAGS)\n", toupper(module)) > PT;
+    printf("  %s_PARSER_FLAGS,\n", toupper(module)) > PT;
+    printf("#else\n") > PT;
+    printf("  0,\n") > PT;
+    printf("#endif\n") > PT;
+    printf("  sizeof(%s_t),\n", module) > PT;
+    printf("  %s_extract_body,\n", module) > PT;

     len = split("request status separator payload unknown error", unnamed, " ");

     for (i = 1; i <= len; i++) {
       printf("  {{ %s_%s_class, offsetof(%s_t, %s_%s) }},\n",
-	     tprefix, unnamed[i], module, prefix, unnamed[i]) > PT NEW;
+	     tprefix, unnamed[i], module, prefix, unnamed[i]) > PT;
     }
     if (multipart) {
       printf("  {{ %s_class, offsetof(%s_t, %s_multipart) }},\n",
-	     multipart, module, prefix) > PT NEW;
+	     multipart, module, prefix) > PT;
     } else {
-      printf("  {{ NULL, 0 }},\n") > PT NEW;
+      printf("  {{ NULL, 0 }},\n") > PT;
     }
     if (MC_SHORT_SIZE) {
-      printf("  %s_short_forms, \n", module) > PT NEW;
+      printf("  %s_short_forms, \n", module) > PT;
     }
     else {
-      printf("  NULL, \n") > PT NEW;
-    }
-    printf("  %d, %d, \n", MC_HASH_SIZE, total) > PT NEW;
-    printf("  {\n") > PT NEW;
+      printf("  NULL, \n") > PT;
+    }
+    printf("  %d, %d, \n", MC_HASH_SIZE, total) > PT;
+    printf("  {\n") > PT;

     for (i = 0; i < total; i++) {
       n = headers[i];
@@ -427,12 +427,12 @@
         flags = header_flags[n]; if (flags) flags = ",\n      " flags;

 	printf("    { %s_%s_class, offsetof(%s_t, %s_%s)%s }%s\n",
-	       tprefix, n, module, prefix, n, flags, c) > PT NEW;
+	       tprefix, n, module, prefix, n, flags, c) > PT;
       }
       else {
-	printf("    { NULL, 0 }%s\n", c) > PT NEW;
-      }
-    }
-    printf("  }\n}};\n\n") > PT NEW;
-  }
-}
+	printf("    { NULL, 0 }%s\n", c) > PT;
+      }
+    }
+    printf("  }\n}};\n\n") > PT;
+  }
+}


2.13.awk


Add "print to stderr" in awk #chunks

Add "print to stderr" in awk #chunks

--- chunks/chunks.awk
+++ chunks/chunks.awk
@@ -5,3 +5,5 @@
 #
 # sub(regexp, replacement [, target])

+print "something" > "/dev/stderr"
+


TestUtils: add test case for curlPost() (thanks to httpbin.org)

--- test/TestUtils.awk
+++ test/TestUtils.awk
@@ -39,6 +39,15 @@
                     "https://httpbin.org/get")
     }

+    T("curlPost()", 1)
+    {
+        delete tokens; delete ast
+        tokenize(tokens, curlPost("https://httpbin.org/post", "fizz=buzz"))
+        parseJson(ast, tokens)
+        assertEqual(unparameterize(ast[0 SUBSEP "url"]),
+                    "https://httpbin.org/post")
+    }
+
     T("dump()", 3)
     {
         delete group


rng2rnc.awk: Various improvements

rng2rnc.awk: Various improvements

--- rnc2rng.awk
+++ rnc2rng.awk
@@ -49,6 +49,8 @@
   }
   sub(/^ */, "", name);
   sub(/ *$/, "", name);
+  if (name == "")
+    name = maybe_define;
   if (name == "start")
     define = "<start"
   else
@@ -58,6 +60,7 @@
   define = define ">"
   stack[++stack_i] = define;
   mode = "pattern";
+  maybe_define = "";
   if (length(line) >= nameix + 1)
     parse_pattern(substr(line, nameix + 1))
 }
@@ -259,12 +262,7 @@
     }
   }
   else if (match(line, /^[A-Za-z_.-]/)) {
-    c = stack[paren[paren_i]];
-    if (postop == 0 && (c == "||" || c == "&&" || c == ",,")) {
-      stack[paren[paren_i]] = "(" substr(c, 1, 1);
-      parse_pattern(")");
-      mode = "grammar";
-      parse_define(line);
+    if (popop(line)) {
       next;
     }
     name = substr(line, 1);
@@ -285,7 +283,19 @@
     }
   }
 }
-
+function popop (line) {
+  op = stack[paren[paren_i]];
+  if (postop == 0 && (op == "||" || op == "&&" || op == ",,")) {
+    stack[paren[paren_i]] = "(" substr(op, 1, 1);
+    parse_pattern(")");
+    mode = "grammar";
+    if (line != "") {
+      parse_define(line);
+    }
+    return 1;
+  }
+  return 0;
+}
 function parse_name_class (line) {
   sub(/^ */, "", line)
   if (length(line) == 0) return;
@@ -366,12 +376,22 @@
     else
       aft = "";
     if (length(aft) >= 2 && substr(aft, 1, 2) == ":*") {
-      for (i = 1; i <= namespaces_i; i++) {
-        if (nsnames[i] == name) {
-          stack[++stack_i] = sprintf("<nsName ns='%s'/>", namespaces[i])
-          break;
-        }
-      }
+      namespace_uri = "";
+      if (name == "xml") {
+        namespace_uri = "http://www.w3.org/XML/1998/namespace";
+      }
+      else {
+        for (i = 1; i <= namespaces_i; i++) {
+          if (nsnames[i] == name) {
+            namespace_uri = namespaces[i];
+            break;
+          }
+        }
+      }
+      if (namespace_uri == "")
+        stack[++stack_i] = "<nsName/>";
+      else
+        stack[++stack_i] = sprintf("<nsName ns='%s'/>", namespace_uri);
       if (length(aft) >= 3)
         aft = substr(aft, 3);
       else
@@ -429,7 +449,7 @@
     }
     print "-->";
   }
-  if (substr(stack[pos], 1, 6) == "<start") {
+  else if (substr(stack[pos], 1, 6) == "<start") {
     print stack[pos];
     pos++;
     printstackone();
@@ -455,9 +475,11 @@
   include_i = 0;
   postop = 0;
   error = 0;
+  maybe_define = "";
 }

 END {
+  popop("");
   if (!error) {
     print "<grammar xmlns='http://relaxng.org/ns/structure/1.0'";
     pos = 1;
@@ -467,12 +489,17 @@
       }
       pos++;
     }
-    printf " ns='%s'>\n", default_namespace;
+    if (default_namespace != "") {
+      printf " ns='%s'>\n", default_namespace;
+    }
+    else {
+      print ">";
+    }
     printstack()
     print "</grammar>"
   }
 }
-/^[^#]/ {
+/^[^#]/ || /^$/ {
   if (substr(stack[stack_i], 1, 1) == "#") {
     stack[++stack_i] = " "
   }
@@ -525,6 +552,11 @@
     stack[++stack_i] = "<include href=\"" href "\"/>";
   }
 }
+mode == "grammar" && /^ *[A-Za-z_.-]/ {
+  maybe_define = substr($0, 1, length($0));
+  sub(/^ */, "", maybe_define);
+  sub(/ *$/, "", maybe_define);
+}
 include_i != 0 && paren_i == 0 && /}/ {
   if (substr(stack[include_i], 1, 8) == "<include") {
     stack[++stack_i] = "</include>";
@@ -538,11 +570,11 @@
   include_i = 0;
   next;
 }
-mode == "pattern" {
+mode == "pattern" && /^[^#]/ {
   parse_pattern($0);
   next;
 }
-mode == "name_class" {
+mode == "name_class" && /^[^#]/ {
   parse_name_class($0);
   next;
 }
@@ -551,5 +583,7 @@
 # more clever about output. But it handles comments that start
 # a line outside a pattern. Enough for me.
 /#.*/ {
+  popop("");
   stack[++stack_i] = $0
-}
+  next;
+}


Also repair zeroEpisodes shows

Also repair zeroEpisodes shows

--- verifyBBoxInfoFrom-webscraper.awk
+++ verifyBBoxInfoFrom-webscraper.awk
@@ -18,15 +18,16 @@
         print "    Bad input line " NR ":\n          " $0
         next
     }
+    gsub ("'", "", $3)
     title = $3
     numEpisodes = $5
-    gsub ("'", "", $0)
     if (numEpisodes != 1)
         print "    " substr ($0,11)
 }

 / show / {
     numShows += 1
+    gsub ("'", "", $3)
     title = $3
     numEpisodes = $5
     numSeasons = $8
@@ -34,13 +35,13 @@
         print "    Bad input line " NR ":\n          " $0
         next
     }
-    gsub ("'", "", $0)
+
     if (numEpisodes == 0) {
         zeroEpisodes += 1
         print "    " substr ($0,11)
+        print title >> REPAIR_FILE
     }

-    gsub ("'", "", title)
     showTitle[numShows] = title
     seas[numShows] = numSeasons
     shouldHave[numShows] = numEpisodes


Utils: add initCurl() and curl(url)

Utils: add initCurl() and curl(url)

--- include/Utils.awk
+++ include/Utils.awk
@@ -33,6 +33,11 @@
 # Detect emacs.
 function initEmacs() {
     Emacs = detectProgram("emacs", "--version")
+}
+
+# Detect curl.
+function initCurl() {
+    Curl = detectProgram("curl", "--version")
 }

 # Log any value if debugging is enabled.
@@ -118,3 +123,20 @@
         }
     }
 }
+
+# Fetch the content of a URL. Return a null string if failed.
+function curl(url,    command, content, line) {
+    initCurl()
+
+    if (!Curl) {
+        l(">> not found: curl")
+        w("[WARNING] curl is not found.")
+        return NULLSTR
+    } else {
+        command = Curl " --location --silent " url
+        content = NULLSTR
+        while ((command |& getline line) > 0)
+            content = content line "\n"
+        return content
+    }
+}


Languages: update Assamese (Google support)

--- include/Languages.awk
+++ include/Languages.awk
@@ -79,6 +79,19 @@
     Locale["hy"]["iso"]                = "hye"
     Locale["hy"]["glotto"]             = "nucl1235"
     Locale["hy"]["script"]             = "Armn"
+
+    # Assamese
+    Locale["as"]["name"]               = "Assamese"
+    Locale["as"]["endonym"]            = "অসমীয়া"
+    #Locale["as"]["translations-of"]
+    #Locale["as"]["definitions-of"]
+    #Locale["as"]["synonyms"]
+    #Locale["as"]["examples"]
+    #Locale["as"]["see-also"]
+    Locale["as"]["family"]             = "Indo-European"
+    Locale["as"]["iso"]                = "asm"
+    Locale["as"]["glotto"]             = "assa1263"
+    Locale["as"]["script"]             = "Beng"

     #6 Azerbaijani (North Azerbaijani)
     Locale["az"]["name"]               = "Azerbaijani"
@@ -1589,20 +1602,6 @@
     Locale["kmr"]["iso"]               = "kmr"
     Locale["kmr"]["glotto"]            = "nort2641"
     Locale["kmr"]["script"]            = "Latn"
-
-    #? Assamese
-    Locale["as"]["support"]            = "unstable"
-    Locale["as"]["name"]               = "Assamese"
-    Locale["as"]["endonym"]            = "অসমীয়া"
-    #Locale["as"]["translations-of"]
-    #Locale["as"]["definitions-of"]
-    #Locale["as"]["synonyms"]
-    #Locale["as"]["examples"]
-    #Locale["as"]["see-also"]
-    Locale["as"]["family"]             = "Indo-European"
-    Locale["as"]["iso"]                = "asm"
-    Locale["as"]["glotto"]             = "assa1263"
-    Locale["as"]["script"]             = "Beng"

     #? Bashkir
     Locale["ba"]["support"]            = "yandex-only"


更新src/font-data-cpp.awk

更新src/font-data-cpp.awk

--- src/font-data-cpp.awk
+++ src/font-data-cpp.awk
@@ -1,12 +1,10 @@
 BEGIN {
-	valid_line_number = 0
 	print "{"
 }
 /^[01]/ {
-	valid_line_number++
 	printf "0b%s,\n", $0
 }
-/^[01]/ && valid_line_number % 12 == 0 {
+/^$/ {
 	print "}, {"
 }
 END {


fix formatting so header is in-line with resource


Handle 3 digit episodes in BBox

Handle 3 digit episodes in BBox

--- getBBoxEpisodesFrom-webscraper.awk
+++ getBBoxEpisodesFrom-webscraper.awk
@@ -38,7 +38,7 @@
     if (URL ~ /_S[[:digit:]]*_E[[:digit:]]*_[[:digit:]]*$/) {
         seasonNumber = substr(fld[nflds-2], 2)
         episodeNumber = substr(fld[nflds-1], 2)
-        sortkey = sprintf ("%s%02dE%02d", showtype, seasonNumber, episodeNumber)
+        sortkey = sprintf ("%s%02dE%03d", showtype, seasonNumber, episodeNumber)
     } else {
         URL ~ /^\/us\/movie\// ? showtype = "M" : showtype = "E"
         sortkey = sprintf ("%s%05d", showtype, fld[nflds])


gnumake3: fixing deliver for solaris nawk

--- solenv/gbuild/processdelivered.awk
+++ solenv/gbuild/processdelivered.awk
@@ -30,6 +30,7 @@
     FS=":"
 }

-NF == 2 {
-    print "COPY " $1 " " $2;
+{
+    if( NF == 2 )
+        print "COPY " $1 " " $2;
 }


Setup variable showType and episodeType

Setup variable showType and episodeType

Assists proper grouping/sorting

--- getAcornFrom-showPages.awk
+++ getAcornFrom-showPages.awk
@@ -158,11 +158,28 @@
     split ($0,fld,"[<>]")
     episodeNumber = fld[5]
     # print "==> episodeNumber = " episodeNumber " " shortEpisodeURL > "/dev/stderr"
+    #
+    # Setup showType so shows group/sort properly
+    # Default showType to "S"
+    showType = "S"
+    # If show is a Prequel, use "P" e.g. Doc Martin
+    if (episodeURL ~ /\/prequel/)
+        showType = "P"
+    #
+    # Setup episodeType so episodes group/sort properly
+    # Default episodeType to "E"
+    episodeType = "E"
+    # Default bonus and christmas specials episodeType to "X"
+    if (episodeURL ~ /\/bonus|christmas[-]?special/)
+        episodeType = "X"
+    # If episode is a Trailer, set episodeType to "T" - even though not all these have episodes
+    if (episodeURL ~ /_cs\//)
+        episodeType = "T"
+    #
     # Wrap up this episode
-    episodeType = "E"
     # =HYPERLINK("https://acorn.tv/1900island/series1/week-one";"1900 Island, S01E01, Week One")
-    episodeLink = sprintf ("=HYPERLINK(\"%s\";\"%s, S%02d%s%02d, %s\"\)", episodeURL, showTitle,
-                    seasonNumber, episodeType, episodeNumber, episodeTitle)
+    episodeLink = sprintf ("=HYPERLINK(\"%s\";\"%s, %s%02d%s%02d, %s\"\)", episodeURL, showTitle,
+                    showType, seasonNumber, episodeType, episodeNumber, episodeTitle)
     # Print "episode" line
     # =HYPERLINK("https://acorn.tv/1900island/series1/week-one";"1900 Island, S01E01, Week One") \
     # \t\t\t 00:59:17 \t As they arrive


Commons: improve squeeze(line)

Commons: improve squeeze(line)

--- include/Commons.awk
+++ include/Commons.awk
@@ -138,6 +138,7 @@
     gsub(/#[^"]*$/, "", line)
     # Remove trailing spaces
     gsub(/[[:space:]]+$/, "", line)
+    gsub(/[[:space:]]+\\$/, "\\", line)

     return line
 }


support extract when ADDing a tar.gz

support extract when ADDing a tar.gz

--- docker_cmd_parser.awk
+++ docker_cmd_parser.awk
@@ -6,6 +6,11 @@
     cmd = "cp " $0
     # system(cmd)
     print cmd
+    # if ($1 ~ /"tar.gz"/ ) {
+    cmd = "tar xvfz " $1 " --directory " $2
+    # system(cmd)
+    print cmd
+    # }
 }

 /^RUN/ {


Fix processing

Fix processing

--- fitness/gpxfilter.awk
+++ fitness/gpxfilter.awk
@@ -8,6 +8,10 @@
       }
       cur = $0;
   }
+  if ($0 ~ /trkseg/) {
+    skipping = 0;
+    cur = "INVALID_STRING";
+  }
   if (skipping) {
   } else {
       print $0;


MONDRIAN: Only check for NON-NLS in mondrian; extra excluded file for checkFile in mondrian-lagunitas branch.

[git-p4: depot-paths = "//open/mondrian/": change = 14355]

--- bin/checkFile.awk
+++ bin/checkFile.awk
@@ -22,6 +22,9 @@
 function _isJava(fname) {
     return fname ~ /\.(java|jj)$/;
 }
+function _isMondrian(fname) {
+    return fname ~ /mondrian/;
+}
 function push(val) {
     switchStack[switchStackLen++] = val;
 }
@@ -92,6 +95,7 @@
     matchFile = _matchFile(fname);
     isCpp = _isCpp(fname);
     isJava = _isJava(fname);
+    mondrian = _isMondrian(fname);
 }
 {
     if (previousLineEndedInCloseBrace > 0) {
@@ -130,7 +134,7 @@
         # mask out /* */ comments
         gsub(/\/\*.*\*\//, "/* comment */", s);
     }
-    if (s ~ /\/\/\$NON-NLS/) {
+    if (mondrian && s ~ /\/\/\$NON-NLS/) {
         error(fname, FNR, "NON-NLS not allowed");
     }
     # mask out // comments


avoid undefined symbol warnings

avoid undefined symbol warnings

--- scripts/modpost.awk
+++ scripts/modpost.awk
@@ -1498,7 +1498,10 @@
 	if (sym in crcs && crcs[sym] && crcs[sym]!~/^0x$/)
 	{ line = crcs[sym] } else
 	{ line = "0x00000000" }
-	line = line "\t" sym "\t" mod "\t" exps[sym]
+	if (sym in exps)
+	    line = line "\t" sym "\t" mod "\t" exps[sym]
+	else
+	    line = line "\t" sym "\t" mod
 	count_syms++
 	print line > file
     }
@@ -1526,7 +1529,10 @@
 	if (sym in crcs && crcs[sym] && crcs[sym]!~/^0x$/)
 	{ line = crcs[sym] } else
 	{ line = "0x00000000" }
-	line = line "\t" sym "\t" mod "\t" exps[sym]
+	if (sym in exps)
+	    line = line "\t" sym "\t" mod "\t" exps[sym]
+	else
+	    line = line "\t" sym "\t" mod
 	count_syms++
 	print line > file
     }


Translators/YandexTranslate: split il

Translators/YandexTranslate: split il

--- include/Translators/YandexTranslate.awk
+++ include/Translators/YandexTranslate.awk
@@ -205,7 +205,8 @@
         # Transliteration (original)
         wShowOriginalPhonetics = Option["show-original-phonetics"]
         if (wShowTranslationPhonetics) {
-            data = yandexPostRequestBody(text, il, il, _hl, "translit")
+            split(il, group, "-")
+            data = yandexPostRequestBody(text, group[1], group[1], _hl, "translit")
             content = curlPost("https://translate.yandex.net/translit/translit", data)
             oPhonetics = (content ~ /not supported$/) ? "" : unparameterize(content)
         }
@@ -214,7 +215,7 @@
         if (!phonetics) wShowTranslationPhonetics = 0

         if (wShowOriginal) {
-            # Display: original text
+            # Display: original text & phonetics
             if (r) r = r RS RS
             r = r m("-- display original text & phonetics")
             r = r prettify("original", s(text, il))


Wrong indices.

Wrong indices.

--- src/cloudfront.awk
+++ src/cloudfront.awk
@@ -11,7 +11,8 @@
 }

 BEGIN {
-
+    numFiles = 0
+    print "["
 }

 function enrich(property, n, j)
@@ -22,7 +23,7 @@
         parsed = urlDecode(queryString)
         split(queryString, pairs, "&")
         len = length(pairs)
-        for (j = 1; j < len; ++j) {
+        for (j = 1; j <= len; j++) {
             split(pairs[j], keyValue, "=")
             k = keyValue[1]
             v = keyValue[2]
@@ -41,8 +42,7 @@
     for (lineNr in logs)
     {
         printf "{\n";
-        j = 1
-        for (j = 1; j < numFields; j++)
+        for (j = 1; j <= numFields; j++)
         {
             field = fields[j]
             enrich(field, lineNr)
@@ -58,11 +58,11 @@
                     k++
                     printf "\n"
                 }
-                print "}"
+                printf "}"
             } else {
                 printf "\"%s\": \"%s\"", field, logs[lineNr][field]
             }
-            if (j + 1 < numFields) {
+            if (j < numFields) {
                 printf ","
             }
             printf "\n"
@@ -75,7 +75,16 @@
         i++
     }
     print "]"
-    print "}"
+    printf "}"
+    if (numFiles + 1 < ARGC) {
+        printf ","
+    }
+    printf "\n"
+    print "]"
+}
+
+ENDFILE {
+    numFiles++
 }

 /^#Version: / {
@@ -95,7 +104,7 @@
 ! /^#/ {
     split($0, fieldsThisLine, " ")
     numFieldsThisLine = length(fieldsThisLine)
-    for (i = 1; i < numFieldsThisLine; i++)
+    for (i = 1; i <= numFieldsThisLine; i++)
     {
          logs[NR][fields[i]] = fieldsThisLine[i]
     }


allow capital hex digits

allow capital hex digits


Fix NULL string implementation

Fix NULL string implementation

PG COPY uses \N as the default NULL placeholder.
http://www.postgresql.org/docs/9.3/static/sql-copy.html

--- bin/bawlk.awk
+++ bin/bawlk.awk
@@ -77,8 +77,6 @@
     defaults["mode"]    = "text"
     defaults["summary"] = "true"
     defaults["dcat"]    = "warning"
-    defaults["dvalnum"] = "NULL"
-    defaults["dvalstr"] = "NULL"
     for (option in defaults) {
         if (!options[option]) options[option] = defaults[option]
     }
@@ -196,6 +194,7 @@
         sql_type    = sql_types[field]
         field_index = header_index[field]
         dval        = sql_type == "numeric" ? options["dvalnum"] : options["dvalstr"]
+        dval        = dval ? dval : "\\\\N"

         print "    if (" field " == \"\") $" field_index " = \"" dval "\""
     }


update copyright

update copyright

--- bin/gps.awk
+++ bin/gps.awk
@@ -1,6 +1,6 @@
 #!/usr/bin/awk -f
 #
-# Copyright (c) 1995-2016 Cyrille Lefevre (Cyrille.Lefevre@laposte.net). All rights reserved.
+# Copyright (c) 2016 Cyrille Lefevre (Cyrille.Lefevre@laposte.net). All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions


Debug for source plugins.

Debug for source plugins.

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -14,11 +14,11 @@
   if (week<26) {
   	current_year=current_year-1
   }
-  printf "Current-Year:%s Current-Week:%s", current_year, week;
+  #printf "DEBUG: Current-Year:%s Current-Week:%s\n", current_year, week;
   FS="\t"
   pn = 0
 }
-$3>date
+#$3>date

 {
   # add a loop to add line only if either status is (wanted or testing) or ending year is gt or eq to contract year
@@ -47,7 +47,7 @@
   if (length($4) > 3) {
     end_year = substr($4,length($4)-3,4)
   }
-  printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", $1,$2,$3,$4,$7,end_year,test_year
+  #printf "DEBUG: %s\t%s\t%s\t%s\t%s\t%s\t%s\n", $1,$2,$3,$4,$7,end_year,test_year
   # Is the AU year >= the contract year or the back year. And then decide what to do with the current year.
   if ($6 == "wanted" || $6 == "testing") {
       incontract = 1;


BrlAPI: Constant generation needs to parse the BRLAPI_PARAM_TYPE_ definitions. (dm)

--- Programs/brlapi.awk
+++ Programs/brlapi.awk
@@ -18,7 +18,7 @@

 BEGIN {
   apiRangeTypeCount = 0
-  apiParameterNext = 0
+  apiParameterTypeCount = 0
 }

 /#define[ \t]*BRLAPI_(CURSOR|DISPLAY|ERROR|TTY)_/ {
@@ -57,19 +57,14 @@
   next
 }

-/^ *BRLAPI_PARAM_[^ ]+ += +[0-9]+,?/ {
-  gsub(",", "", $3)
-  apiParameterNext = strtonum($3)
-  apiParameter($0, $1)
+/^ *BRLAPI_PARAM_TYPE_[^ ,]+,?/ {
+  gsub(",", "", $1)
+  apiConstant(substr($1, 8), $1, apiParameterTypeCount++, getComment($0))
   next
 }

-/^ *BRLAPI_PARAM_[^ ,]+,?/ {
-  gsub(",", "", $1)
-  apiParameter($0, $1)
+/^ *BRLAPI_PARAM_[^ ]+ += +[0-9]+,?/ {
+  gsub(",", "", $3)
+  apiConstant(substr($1, 8), $1, strtonum($3), getComment($0))
   next
 }
-
-function apiParameter(line, symbol) {
-  apiConstant(substr(symbol, 8), symbol, apiParameterNext++, getComment(line))
-}


Help: update getVersion()

Help: update getVersion()

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


- correction

- correction

--- scripts/modpost.awk
+++ scripts/modpost.awk
@@ -1210,8 +1210,7 @@
     for (i = 1; i in modules; i++)
 	print modules[i] > "modvers.list"
     close("modvers.list")
-    #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"
+    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"
     read_modobject(command, ".", values["pkgdirectory"], src)
     system("rm -f modvers.list")
     system("rm -f /var/tmp/*.ko")


Translators/BingTranslator: handle redirection in bingSetIG()

--- include/Translators/BingTranslator.awk
+++ include/Translators/BingTranslator.awk
@@ -12,7 +12,8 @@
 }

 # Retrieve the Cookie and set IG.
-function bingSetCookie(    content, cookie, group, header, isBody, url) {
+function bingSetIG(    content, cookie, group, header, isBody,
+                       url, status, location) {
     url = HttpPathPrefix "/translator"

     header = "GET " url " HTTP/1.1\r\n"                                 \
@@ -32,9 +33,19 @@
             content = content ? content "\r\n" $0 : $0
         else if (length($0) <= 1)
             isBody = 1
+        else { # interesting fields in header
+            match($0, /^HTTP[^ ]* ([^ ]*)/, group)
+            if (RSTART) status = group[1]
+            match($0, /^Location: (.*)/, group)
+            if (RSTART) location = squeeze(group[1]) # squeeze the URL!
+        }
         l(sprintf("%4s bytes > %s", length($0), length($0) < 1024 ? $0 : "..."))
     }
     close(HttpService)
+
+    if ((status == "301" || status == "302") && location)
+        content = curl(location)
+    # FIXME: cookie

     Cookie = cookie
     match(content, /IG:"([^"]+)"/, group)
@@ -173,7 +184,7 @@
     _tl = getCode(tl); if (!_tl) _tl = tl
     _hl = getCode(hl); if (!_hl) _hl = hl

-    bingSetCookie() # set IG
+    bingSetIG() # set IG

     # Language identification
     il = postResponse(text, _sl, _tl, _hl, "detect")


FIx season number mismatches

FIx season number mismatches

Only for Poirot, Rebus, and Vera. Others were caused by bonus or Christmas episodes which incremented Acorn's seasonNumber.

--- getAcornFrom-seriesPages.awk
+++ getAcornFrom-seriesPages.awk
@@ -142,6 +142,8 @@
 }

 # Extract the seasonNumber
+# Note that Acorn "season" numbers may not correspond to actual season numbers.
+# They simply refer to the number of seasons available on Acorn.
 /<meta itemprop="seasonNumber" content="/ {
     split ($0,fld,"\"")
     seasonNumber = fld[4]
@@ -229,9 +231,22 @@
     # neither should single episode series
     if (totalEpisodes == 1)
         next
+    # The season number should match that in the URL
+    # Poirot, Rebus, and Vera have kn own problems
+    if (episodeURL ~ \
+           /\/poirot\/series[0-9]{1,2}\/|\/rebus\/series[0-9]{1,2}\/|\/vera\/series[0-9]{1,2}\//) {
+        split (episodeURL, part, "/")
+        URLseasonNumber = part[5]
+        sub (/[[:alpha:]]*/,"",URLseasonNumber)
+        if (URLseasonNumber != seasonNumber) {
+            printf ("==> Corrected mismatch: https://acorn.tv/%s/%s was series %d\n", \
+               part[4], part[5], seasonNumber) >> ERROR_FILE
+            seasonNumber = URLseasonNumber
+        }
+    }
     printf ("%d\t=HYPERLINK(\"%s\";\"%s, %s%02dE%02d, %s\"\)\t\t\t%s\n", \
         SERIES_NUMBER, episodeURL, seriesTitle, showType, seasonNumber, episodeNumber, \
-        episodeTitle, episodeDuration) >>EPISODE_INFO_FILE
+        episodeTitle, episodeDuration) >> EPISODE_INFO_FILE
     next
 }


Remove port number.

Remove port number.

--- gfwlist2dnsmasq.awk
+++ gfwlist2dnsmasq.awk
@@ -10,6 +10,7 @@
 function extract(line, original_line) {
 	sub(/.*:\/\//, "", line) # remove everything till ://, such as http:// https://
 	sub(/\/.*/, "", line)    # remove everything from /
+	sub(/:.*/, "", line)     # remove everything from :
 	sub(/\*/, "", line)      # remove *
 	sub(/^\./, "", line)     # remove leading dot


Bugfix if changing static to dhcp/manual

--- changeInterface.awk
+++ changeInterface.awk
@@ -221,6 +221,12 @@
                 print $0;
             }
         }
+
+        if ($1 == "auto" || $1 == "allow-hotplug" || $1 == "")
+        {
+            print
+        }
+
         next;
     }


gawk's lshift() function is a gnu extension. (dm)

--- Programs/brlcmds.awk
+++ Programs/brlcmds.awk
@@ -65,7 +65,7 @@
   value = getDefineValue()
   sub("^.*\\(", "", value)
   sub("\\).*$", "", value)
-  value = lshift(1, (value - 1))
+  value = 2 ^ (value - 1)
   brlDot(substr($2, 8), $2, value, getComment($0))
   next
 }


some substitutions

some substitutions


- modpost improvement

- modpost improvement

--- scripts/modpost.awk
+++ scripts/modpost.awk
@@ -2015,6 +2015,9 @@
 	    command = cat_command("/boot/System.map-" kversion ".bz2")
 	    if (command) { read_systemmap(command, "vmlinux", "kernel", "systemmap") }
 	    else {
+	    command = cat_command("/lib/modules/" kversion "/build/System.map")
+	    if (command) { read_systemmap(command, "vmlinux", "kernel", "systemmap") }
+	    else {
 	    print_error("r: systemmap, file not found") } } }
 	}
 	if (("infile" in values) && values["infile"]) {


Main: update

Main: update

--- include/Main.awk
+++ include/Main.awk
@@ -63,9 +63,6 @@

 # Initialization script.
 function initScript(    file, line, script, temp) {
-    if (belongsTo("-no-init", ARGV) || belongsTo("--no-init", ARGV))
-        return
-
     # Find the initialization file
     file = ".trans"
     if (!fileExists(file)) {
@@ -136,65 +133,71 @@
 # Main entry point.
 BEGIN {
     init()
-    initScript() # initialization script overrides default setting
+
+    if (!(belongsTo("-no-init", ARGV) || belongsTo("--no-init", ARGV)))
+        initScript() # initialization script overrides default setting

     # Command-line options override initialization script
     pos = 0
     while (ARGV[++pos]) {
-        # -, -no-op
-        match(ARGV[pos], /^-(-?no-op)?$/)
-        if (RSTART) continue
+        ## Information options

         # -V, -version
-        match(ARGV[pos], /^--?(vers(i(on?)?)?|V)$/)
-        if (RSTART) {
-            print getVersion()
-            print
-            printf("%-22s%s\n", "gawk (GNU Awk)", PROCINFO["version"])
-            printf("%s\n", FriBidi ? FriBidi : "fribidi (GNU FriBidi) [NOT INSTALLED]")
-            printf("%-22s%s\n", "User Language", getName(UserLang) " (" getDisplay(UserLang) ")")
-            exit
-        }
-
-        # -H, -h, -help
-        match(ARGV[pos], /^--?(h(e(lp?)?)?|H)$/)
-        if (RSTART) {
-            print getHelp()
-            exit
-        }
-
-        # -M, -m, -manual
-        match(ARGV[pos], /^--?(m(a(n(u(al?)?)?)?)?|M)$/)
-        if (RSTART) {
-            man()
-            exit
-        }
-
-        # -r, -reference
-        match(ARGV[pos], /^--?r(e(f(e(r(e(n(ce?)?)?)?)?)?)?)?$/)
-        if (RSTART) {
-            print getReference("endonym")
-            exit
+        match(ARGV[pos], /^--?(V|vers(i(on?)?)?)$/)
+        if (RSTART) {
+            InfoOnly = "version"
+            continue
+        }
+
+        # -H, -help
+        match(ARGV[pos], /^--?(H|h(e(lp?)?)?)$/)
+        if (RSTART) {
+            InfoOnly = "help"
+            continue
+        }
+
+        # -M, -manual
+        match(ARGV[pos], /^--?(M|m(a(n(u(al?)?)?)?)?)$/)
+        if (RSTART) {
+            InfoOnly = "manual"
+            continue
+        }
+
+        # -T, -reference
+        match(ARGV[pos], /^--?(T|ref(e(r(e(n(ce?)?)?)?)?)?)$/)
+        if (RSTART) {
+            InfoOnly = "reference"
+            continue
+        }
+
+        # FIXME[1.0]: to be removed
+        match(ARGV[pos], /^--?r$/)
+        if (RSTART) {
+            w("[WARNING] Option '-r' has been deprecated since version 0.9.\n" \
+              "          Use option '-T' or '-reference' instead.")
+            exit 1
         }

         # -R, -reference-english
-        match(ARGV[pos], /^--?(reference-(e(n(g(l(i(sh?)?)?)?)?)?)?|R)$/)
-        if (RSTART) {
-            print getReference("name")
-            exit
-        }
-
-        # -D, -debug
-        match(ARGV[pos], /^--?(debug|D)$/)
-        if (RSTART) {
-            Option["debug"] = 1
-            continue
-        }
+        match(ARGV[pos], /^--?(R|reference-e(n(g(l(i(sh?)?)?)?)?)?)$/)
+        if (RSTART) {
+            InfoOnly = "reference-english"
+            continue
+        }
+
+        ## Display options

         # -verbose
         match(ARGV[pos], /^--?verbose$/)
         if (RSTART) {
             Option["verbose"] = 1 # default value
+            continue
+        }
+
+        # -b, -brief
+        match(ARGV[pos], /^--?b(r(i(ef?)?)?)?$/)
+        if (RSTART) {
+            Option["verbose"] = 0
             continue
         }

@@ -207,77 +210,102 @@
             continue
         }

-        # -b, -brief
-        match(ARGV[pos], /^--?b(r(i(ef?)?)?)?$/)
-        if (RSTART) {
-            Option["verbose"] = 0
-            continue
-        }
-
-        # -show-original [yes|no]
+        # -show-original Y|n
         match(ARGV[pos], /^--?show-original(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-original"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-original-phonetics [yes|no]
+        # -show-original-phonetics Y|n
         match(ARGV[pos], /^--?show-original-phonetics(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-original-phonetics"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-translation [yes|no]
+        # -show-translation Y|n
         match(ARGV[pos], /^--?show-translation(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-translation"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-translation-phonetics [yes|no]
+        # -show-translation-phonetics Y|n
         match(ARGV[pos], /^--?show-translation-phonetics(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-translation-phonetics"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-prompt-message [yes|no]
+        # -show-prompt-message Y|n
         match(ARGV[pos], /^--?show-prompt-message(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-prompt-message"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-languages [yes|no]
+        # -show-languages Y|n
         match(ARGV[pos], /^--?show-languages(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-languages"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-original-dictionary [yes|no]
+        # -show-original-dictionary y|N
         match(ARGV[pos], /^--?show-original-dictionary(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-original-dictionary"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-dictionary [yes|no]
+        # -show-dictionary Y|n
         match(ARGV[pos], /^--?show-dictionary(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-dictionary"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -show-alternatives [yes|no]
+        # -show-alternatives Y|n
         match(ARGV[pos], /^--?show-alternatives(=(.*)?)?$/, group)
         if (RSTART) {
             Option["show-alternatives"] = yn(group[1] ? group[2] : ARGV[++pos])
             continue
         }

-        # -theme [theme]
+        # -w NUM, -width NUM
+        match(ARGV[pos], /^--?w(i(d(th?)?)?)?(=(.*)?)?$/, group)
+        if (RSTART) {
+            Option["width"] = group[4] ?
+                (group[5] ? group[5] : Option["width"]) :
+                ARGV[++pos]
+            continue
+        }
+
+        # -indent NUM
+        match(ARGV[pos], /^--?indent(=(.*)?)?$/, group)
+        if (RSTART) {
+            Option["indent"] = group[1] ?
+                (group[2] ? group[2] : Option["indent"]) :
+                ARGV[++pos]
+            continue
+        }
+
+        # -no-ansi
+        match(ARGV[pos], /^--?no-ansi$/)
+        if (RSTART) {
+            Option["no-ansi"] = 1
+            continue
+        }
+
+        # -no-theme
+        match(ARGV[pos], /^--?no-theme$/)
+        if (RSTART) {
+            Option["theme"] = NULLSTR
+            continue
+        }
+
+        # -theme FILENAME
         match(ARGV[pos], /^--?theme(=(.*)?)?$/, group)
         if (RSTART) {
             Option["theme"] = group[1] ?
@@ -286,28 +314,38 @@
             continue
         }

-        # -no-ansi
-        match(ARGV[pos], /^--?no-ansi$/)
-        if (RSTART) {
-            Option["no-ansi"] = 1
-            continue
-        }
-
-        # -w [num], -width [num]
-        match(ARGV[pos], /^--?w(i(d(th?)?)?)?(=(.*)?)?$/, group)
-        if (RSTART) {
-            Option["width"] = group[4] ?
-                (group[5] ? group[5] : Option["width"]) :
-                ARGV[++pos]
-            continue
-        }
-
-        # -indent [num]
-        match(ARGV[pos], /^--?indent(=(.*)?)?$/, group)
-        if (RSTART) {
-            Option["indent"] = group[1] ?
-                (group[2] ? group[2] : Option["indent"]) :
-                ARGV[++pos]
+        ## Audio options
+
+        # -no-play
+        match(ARGV[pos], /^--?no-play$/)
+        if (RSTART) {
+            Option["play"] = 0
+            continue
+        }
+
+        # -p, -play
+        match(ARGV[pos], /^--?p(l(ay?)?)?$/)
+        if (RSTART) {
+            Option["play"] = 1
+            continue
+        }
+
+        # -player PROGRAM
+        match(ARGV[pos], /^--?player(=(.*)?)?$/, group)
+        if (RSTART) {
+            Option["play"] = 1
+            Option["player"] = group[1] ?
+                (group[2] ? group[2] : Option["player"]) :
+                ARGV[++pos]
+            continue
+        }
+
+        ## Terminal paging and web options
+
+        # -no-view
+        match(ARGV[pos], /^--?no-view$/)
+        if (RSTART) {
+            Option["view"] = 0
             continue
         }

@@ -318,7 +356,7 @@
             continue
         }

-        # -pager [program]
+        # -pager PROGRAM
         match(ARGV[pos], /^--?pager(=(.*)?)?$/, group)
         if (RSTART) {
             Option["view"] = 1
@@ -328,7 +366,7 @@
             continue
         }

-        # -browser [program]
+        # -browser PROGRAM
         match(ARGV[pos], /^--?browser(=(.*)?)?$/, group)
         if (RSTART) {
             Option["browser"] = group[1] ?
@@ -337,25 +375,10 @@
             continue
         }

-        # -p, -play
-        match(ARGV[pos], /^--?p(l(ay?)?)?$/)
-        if (RSTART) {
-            Option["play"] = 1
-            continue
-        }
-
-        # -player [program]
-        match(ARGV[pos], /^--?player(=(.*)?)?$/, group)
-        if (RSTART) {
-            Option["play"] = 1
-            Option["player"] = group[1] ?
-                (group[2] ? group[2] : Option["player"]) :
-                ARGV[++pos]
-            continue
-        }
-
-        # -x [proxy], -proxy [proxy]
-        match(ARGV[pos], /^--?(proxy|x)(=(.*)?)?$/, group)
+        ## Networking options
+
+        # -x HOST:PORT, -proxy HOST:PORT
+        match(ARGV[pos], /^--?(x|proxy)(=(.*)?)?$/, group)
         if (RSTART) {
             Option["proxy"] = group[2] ?
                 (group[3] ? group[3] : Option["proxy"]) :
@@ -363,8 +386,8 @@
             continue
         }

-        # -u [agent], -user-agent [agent]
-        match(ARGV[pos], /^--?(user-agent|u)(=(.*)?)?$/, group)
+        # -u STRING, -user-agent STRING
+        match(ARGV[pos], /^--?(u|user-agent)(=(.*)?)?$/, group)
         if (RSTART) {
             Option["user-agent"] = group[2] ?
                 (group[3] ? group[3] : Option["user-agent"]) :
@@ -372,12 +395,7 @@
             continue
         }

-        # -I, -interactive, -shell
-        match(ARGV[pos], /^--?(int(e(r(a(c(t(i(ve?)?)?)?)?)?)?)?|shell|I)$/)
-        if (RSTART) {
-            Option["interactive"] = 1
-            continue
-        }
+        ## Interactive shell options

         # -no-rlwrap
         match(ARGV[pos], /^--?no-rlwrap$/)
@@ -386,15 +404,22 @@
             continue
         }

+        # -I, -interactive, -shell
+        match(ARGV[pos], /^--?(I|int(e(r(a(c(t(i(ve?)?)?)?)?)?)?)?|shell)$/)
+        if (RSTART) {
+            Option["interactive"] = 1
+            continue
+        }
+
         # -E, -emacs
-        match(ARGV[pos], /^--?(emacs|E)$/)
+        match(ARGV[pos], /^--?(E|emacs)$/)
         if (RSTART) {
             Option["emacs"] = 1
             continue
         }

         # FIXME[1.0]: to be removed
-        # -prompt [prompt_string]
+        # -prompt PROMPT_STRING
         match(ARGV[pos], /^--?prompt(=(.*)?)?$/, group)
         if (RSTART) {
             w("[ERROR] Option '-prompt' has been deprecated since version 0.9.\n" \
@@ -403,7 +428,7 @@
         }

         # FIXME[1.0]: to be removed
-        # -prompt-color [color_code]
+        # -prompt-color COLOR_CODE
         match(ARGV[pos], /^--?prompt-color(=(.*)?)?$/, group)
         if (RSTART) {
             w("[ERROR] Option '-prompt-color' has been deprecated since version 0.9.\n" \
@@ -411,7 +436,9 @@
             exit 1
         }

-        # -i [file], -input [file]
+        ## I/O options
+
+        # -i FILENAME, -input FILENAME
         match(ARGV[pos], /^--?i(n(p(ut?)?)?)?(=(.*)?)?$/, group)
         if (RSTART) {
             Option["input"] = group[4] ?
@@ -420,7 +447,7 @@
             continue
         }

-        # -o [file], -output [file]
+        # -o FILENAME, -output FILENAME
         match(ARGV[pos], /^--?o(u(t(p(ut?)?)?)?)?(=(.*)?)?$/, group)
         if (RSTART) {
             Option["output"] = group[5] ?
@@ -429,7 +456,9 @@
             continue
         }

-        # -l [code], -lang [code]
+        ## Language preference options
+
+        # -l CODE, -lang CODE
         match(ARGV[pos], /^--?l(a(ng?)?)?(=(.*)?)?$/, group)
         if (RSTART) {
             Option["hl"] = group[3] ?
@@ -438,7 +467,7 @@
             continue
         }

-        # -s [code], -source [code]
+        # -s CODE, -source CODE
         match(ARGV[pos], /^--?s(o(u(r(ce?)?)?)?)?(=(.*)?)?$/, group)
         if (RSTART) {
             Option["sl"] = group[5] ?
@@ -447,7 +476,7 @@
             continue
         }

-        # -t [codes], -target [codes]
+        # -t CODE(S), -target CODE(S)
         match(ARGV[pos], /^--?t(a(r(g(et?)?)?)?)?(=(.*)?)?$/, group)
         if (RSTART) {
             if (group[5]) {
@@ -458,7 +487,7 @@
         }

         # Shortcut format
-        # '[code]:[code]+...' or '[code]=[code]+...'
+        # 'CODE:CODE+...' or 'CODE=CODE+...'
         match(ARGV[pos], /^[{(\[]?([[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?(:|=)((@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?\+)*(@?[[:alpha:]][[:alpha:]][[:alpha:]]?(-[[:alpha:]][[:alpha:]])?)?)[})\]]?$/, group)
         if (RSTART) {
             if (group[1]) Option["sl"] = group[1]
@@ -466,9 +495,22 @@
             continue
         }

+        ## Other options
+
+        # -D, -debug
+        match(ARGV[pos], /^--?(D|debug)$/)
+        if (RSTART) {
+            Option["debug"] = 1
+            continue
+        }
+
         # -no-init
         match(ARGV[pos], /^--?no-init/)
-        if (RSTART) continue
+        if (RSTART) continue # skip
+
+        # -, -no-op
+        match(ARGV[pos], /^-(-?no-op)?$/)
+        if (RSTART) continue # no operation, skip

         # --
         match(ARGV[pos], /^--$/)
@@ -482,6 +524,7 @@

     setTheme() # theme overrides command-line options

+    # Handle interactive shell
     if (Option["interactive"] && !Option["no-rlwrap"])
         rlwrapMe() # interactive mode
     else if (Option["emacs"] && !Option["interactive"] && !Option["no-rlwrap"])
@@ -492,6 +535,29 @@

     initMisc()

+    # Handle information options
+    switch (InfoOnly) {
+    case "version":
+        print getVersion()
+        print
+        printf("%-22s%s\n", "gawk (GNU Awk)", PROCINFO["version"])
+        printf("%s\n", FriBidi ? FriBidi : "fribidi (GNU FriBidi) [NOT INSTALLED]")
+        printf("%-22s%s\n", "User Language", getName(UserLang) " (" getDisplay(UserLang) ")")
+        exit
+    case "help":
+        print getHelp()
+        exit
+    case "manual":
+        man()
+        exit
+    case "reference":
+        print getReference("endonym")
+        exit
+    case "reference-english":
+        print getReference("name")
+        exit
+    }
+
     if (Option["interactive"])
         welcome()


REPL: get things right

REPL: get things right

--- include/REPL.awk
+++ include/REPL.awk
@@ -143,15 +143,16 @@
     } else if (command ~ /^:set$/) {
         name = words[2]
         value = words[3]
-        Option[name] = value
         # :set sl and :set tl should work as intended
         # TODO: support multiple language codes
         if (name == "sl") {
             delete Option["sls"]
-            Option["sls"][1] = Option["sl"]
+            Option["sls"][1] = value
         } else if (name == "tl") {
             delete Option["tl"]
             Option["tl"][1] = value
+        } else {
+            Option[name] = value
         }
     } else if (command ~ /^:show$/) {
         name = words[2]


Add copyright header to gen_domain_state_inc.awk

--- runtime/gen_domain_state_inc.awk
+++ runtime/gen_domain_state_inc.awk
@@ -1,3 +1,18 @@
+#**************************************************************************
+#*                                                                        *
+#*                                 OCaml                                  *
+#*                                                                        *
+#*         Damien Doligez, projet Gallium, INRIA Rocquencourt             *
+#*                                                                        *
+#*   Copyright 2013 Institut National de Recherche en Informatique et     *
+#*     en Automatique.                                                    *
+#*                                                                        *
+#*   All rights reserved.  This file is distributed under the terms of    *
+#*   the GNU Lesser General Public License version 2.1, with the          *
+#*   special exception on linking described in the file LICENSE.          *
+#*                                                                        *
+#**************************************************************************
+
 BEGIN{FS=",";count=0};
 /DOMAIN_STATE/{
   print "Store_" substr($2,2,length($2)-2) " MACRO reg";


Translators/BingTranslator: switch to API v3 (fix #311)

--- include/Translators/BingTranslator.awk
+++ include/Translators/BingTranslator.awk
@@ -2,7 +2,7 @@
 # BingTranslator.awk                                               #
 ####################################################################
 #
-# Last Updated: 23 Dec 2018
+# Last Updated: 24 Jul 2019
 BEGIN { provides("bing") }

 function bingInit() {
@@ -133,15 +133,14 @@
         "from=" sl "&to=" tl "&text=" preprocess(text)
 }

+# Main Bing Translator API (via HTTP POST).
 function bingPostRequestUrl(text, sl, tl, hl, type) {
-    if (type == "translate")
-        return HttpPathPrefix "/ttranslate"
-    else if (type == "translationlookup")
-        return HttpPathPrefix "/ttranslationlookup"
+    if (type == "lookup")
+        return HttpPathPrefix "/tlookupv3"
     else if (type == "transliterate")
-        return HttpPathPrefix "/ttransliterate"
-    else # type == "detect"
-        return HttpPathPrefix "/tdetect"
+        return HttpPathPrefix "/ttransliteratev3"
+    else # type == "translate"
+        return HttpPathPrefix "/ttranslatev3"
 }

 function bingPostRequestContentType(text, sl, tl, hl, type) {
@@ -149,14 +148,12 @@
 }

 function bingPostRequestBody(text, sl, tl, hl, type) {
-    if (type == "translate")
-        return "&text=" quote(text) "&from=" sl "&to=" tl
-    else if (type == "translationlookup")
-        return "&text=" quote(text) "&from=" sl "&to=" tl
+    if (type == "lookup")
+        return "&text=" quote(text) "&fromLang=" sl "&to=" tl  # FIXME!
     else if (type == "transliterate")
-        return "&text=" quote(text) "&language=" sl "&toScript=" "latn"
-    else # type == "detect"
-        return "&text=" quote(text)
+        return "&text=" quote(text) "&language=" sl "&toScript=" "latn"  # FIXME!
+    else # type == "translate"
+        return "&text=" quote(text) "&fromLang=" sl "&to=" tl
 }

 # Get the translation of a string.
@@ -186,28 +183,15 @@

     #bingSetIG() # set IG (no longer needed)

-    # Language identification
-    il = postResponse(text, _sl, _tl, _hl, "detect")
-    if (!il) {
-        e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
-        ExitCode = 1
-        return
-    }
-    returnIl[0] = il
-    if (Option["verbose"] < -1)
-        return il
-    if (Option["verbose"] < 0)
-        return getList(il)
-
     # Hot-patches for Bing's own translator language codes
     # See: <https://msdn.microsoft.com/en-us/library/hh456380.aspx>
-    if (_sl == "auto")  _sl = il
-    if (_sl == "bs")    _sl = "bs-Latn" # 'bs' is not recognized as valid code
-    if (_sl == "zh-CN") _sl = "zh-CHS"
-    if (_sl == "zh-TW") _sl = "zh-CHT"
+    if (_sl == "auto")  _sl = "auto-detect"
+    if (_sl == "bs")    _sl = "bs-Latn" # 'bs' is not recognized as valid code  # FIXME
+    if (_sl == "zh-CN") _sl = "zh-Hans"
+    if (_sl == "zh-TW") _sl = "zh-Hant"
     if (_tl == "bs")    _tl = "bs-Latn"
-    if (_tl == "zh-CN") _tl = "zh-CHS"
-    if (_tl == "zh-TW") _tl = "zh-CHT"
+    if (_tl == "zh-CN") _tl = "zh-Hans"
+    if (_tl == "zh-TW") _tl = "zh-Hant"

     # Translation
     content = postResponse(text, _sl, _tl, _hl, "translate")
@@ -223,20 +207,25 @@
         e("[ERROR] Oops! Something went wrong and I can't translate it for you :(")
         ExitCode = 1
         return
-    } else if (ast[0 SUBSEP "statusCode"] != "200") {
-        e("[ERROR] statusCode: " ast[0 SUBSEP "statusCode"])
-        ExitCode = 1
-        return
-    }
-
-    translation = unparameterize(ast[0 SUBSEP "translationResponse"])
+    }
+
+    translation = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 SUBSEP "text"])
+
+    returnIl[0] = il = _sl == "auto-detect" ?
+        unparameterize(ast[0 SUBSEP 0 SUBSEP "detectedLanguage" SUBSEP "language"]) : _sl
+    if (Option["verbose"] < -1)
+        return il
+    if (Option["verbose"] < 0)
+        return getList(il)

     # Transliteration
     wShowTranslationPhonetics = Option["show-translation-phonetics"]
     if (wShowTranslationPhonetics) {
         split(_tl, group, "-")
-        content = postResponse(translation, group[1], group[1], _hl, "transliterate")
-        phonetics = unparameterize(content)
+        #content = postResponse(translation, group[1], group[1], _hl, "transliterate")
+        #phonetics = unparameterize(content)
+        phonetics = unparameterize(ast[0 SUBSEP 0 SUBSEP "translations" SUBSEP 0 SUBSEP "transliteration" \
+                                       SUBSEP "text"])
         if (phonetics == translation) phonetics = ""
     }

@@ -260,8 +249,9 @@
         wShowOriginalPhonetics = Option["show-original-phonetics"]
         if (wShowOriginalPhonetics) {
             split(_sl, group, "-")
-            content = postResponse(text, group[1], group[1], _hl, "transliterate")
-            oPhonetics = unparameterize(content)
+            #content = postResponse(text, group[1], group[1], _hl, "transliterate")
+            #oPhonetics = unparameterize(content)
+            # TODO
             if (oPhonetics == text) oPhonetics = ""
         }

@@ -295,9 +285,9 @@
             split(temp, group, /(%s|%S|%t|%T)/)
             r = r prettify("languages", group[1])
             if (temp ~ /%s/)
-                r = r prettify("languages-sl", getDisplay(_sl))
+                r = r prettify("languages-sl", getDisplay(il))
             if (temp ~ /%S/)
-                r = r prettify("languages-sl", getName(_sl))
+                r = r prettify("languages-sl", getName(il))
             r = r prettify("languages", group[2])
             if (temp ~ /%t/)
                 r = r prettify("languages-tl", getDisplay(tl))


allow for extra spaces between the "#" and the  preprocessor directive name

--- tools/OAD_support/cb2mGetModules.awk
+++ tools/OAD_support/cb2mGetModules.awk
@@ -1,7 +1,7 @@
 BEGIN { commonDecl = 0}
 /^      .*/ {commonDecl = 0 }
-/^[^ ]/ && !/^#ifdef / && !/^#endif/ && !/^#if / && !/^#else/ && !/^c.*/ && !/^C.*/ {commonDecl = 0 }
+/^[^ ]/ && !/^# *ifdef / && !/^# *endif/ && !/^# *if / && !/^# *else/ && !/^c.*/ && !/^C.*/ {commonDecl = 0 }
 /^       *COMMON/ || /^       *common/ { commonDecl = 1 }
-/^#ifdef / || /^#endif/ || /^#if / || /^#else/ { if (commonDecl == 1) {print} }
+/^# *ifdef / || /^# *endif/ || /^# *if / || /^# *else/ { if (commonDecl == 1) {print} }
 {if (commonDecl ==0 ) print }
 END {}


add another case for the license text

add another case for the license text

--- utils/remove_license_block-helper.awk
+++ utils/remove_license_block-helper.awk
@@ -17,7 +17,7 @@
 	BLOCK[BLOCK_END++] = X "Version [^ ]*";
 	BLOCK[BLOCK_END++] = X;
 	BLOCK[BLOCK_END++] = X "COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHTS.*";
-	BLOCK[BLOCK_END++] = X "US government users are permitted unrestricted rights as";
+	BLOCK[BLOCK_END++] = X "US government users are permitted (un)?restricted rights as";
 	BLOCK[BLOCK_END++] = X "defined in the FAR.";
 	BLOCK[BLOCK_END++] = X;
 	BLOCK[BLOCK_END++] = X "This software is distributed on an \"AS IS\" basis, WITHOUT";


- syntax error

- syntax error

--- scripts/modpost.awk
+++ scripts/modpost.awk
@@ -2018,7 +2018,7 @@
 	    command = cat_command("/lib/modules/" kversion "/build/System.map")
 	    if (command) { read_systemmap(command, "vmlinux", "kernel", "systemmap") }
 	    else {
-	    print_error("r: systemmap, file not found") } } }
+	    print_error("r: systemmap, file not found") } } } }
 	}
 	if (("infile" in values) && values["infile"]) {
 	    command = cat_command(values["infile"])


taking care of two hads

taking care of two hads

--- src/awk/checkdouble.awk
+++ src/awk/checkdouble.awk
@@ -11,10 +11,10 @@
   prevfile = FILENAME
 }
 NF > 0{
-  if ($1 == lastword)
+  if ($1 == lastword && $1 != "had")
      printf "double %s, file %s, line %d\n", $1, FILENAME, NR
   for (i=2; i <= NF; i++)
-      if ($i == $(i-1))
+      if ($i == $(i-1) && $i != "had")
          printf "double %s, file %s, line %d\n", $i, FILENAME, NR
   if (NF > 0){
      lastword = $NF


make TOC nicer, find paragraph starts

make TOC nicer, find paragraph starts

--- tools/hierarchy.awk
+++ tools/hierarchy.awk
@@ -6,16 +6,31 @@
     hier[heading] = $0
     sub(/<\/a>/, "", hier[heading])
     sub(/<\/a>/, "", hier[heading])
+    here = hier[heading]
+
+    if (heading == 2)
+    {
+      hier[heading] = "⋅ " hier[heading]
+    }
+    else if (heading == 3)
+    {
+      hier[heading] = "– " hier[heading]
+    }
+    else if (heading >= 4)
+    {
+      hier[heading] = "— " hier[heading]
+    }
+
     if (slide) print "
"
     print "
"
     slide = 1
     if (heading > 1) {
-	print "
" hier[heading] "
"
+      print "
" hier[heading] "
"
     }
     for (i=1; i < heading; ++i) {
-	print "<h" i " style='color: #C0C0C0;'>" hier[i] "</h" i ">"
+      print "<h" i " style='color: #C0C0C0;'>" hier[i] "</h" i ">"
     }
-    print "<h" heading ">" hier[heading]
+    print "<h" heading ">" here
     hunt = 0
     next
 }
@@ -50,8 +65,11 @@
     next
 }

-{ print }
+{
+  gsub(/
/, "\n&\n")
+  print
+}

 END {
     if (slide) print "
"
-}+}


oops, only add ornaments in the TOC

oops, only add ornaments in the TOC

--- tools/hierarchy.awk
+++ tools/hierarchy.awk
@@ -6,31 +6,34 @@
     hier[heading] = $0
     sub(/<\/a>/, "", hier[heading])
     sub(/<\/a>/, "", hier[heading])
-    here = hier[heading]

     if (heading == 2)
     {
-      hier[heading] = "⋅ " hier[heading]
+      here = "⋅ " hier[heading]
     }
     else if (heading == 3)
     {
-      hier[heading] = "– " hier[heading]
+      here = "– " hier[heading]
     }
     else if (heading >= 4)
     {
-      hier[heading] = "— " hier[heading]
+      here = "— " hier[heading]
     }
-
+    else
+    {
+      here = hier[heading]
+    }
+
     if (slide) print "
"
     print "
"
     slide = 1
     if (heading > 1) {
-      print "
" hier[heading] "
"
+      print "
" here "
"
     }
     for (i=1; i < heading; ++i) {
       print "<h" i " style='color: #C0C0C0;'>" hier[i] "</h" i ">"
     }
-    print "<h" heading ">" here
+    print "<h" heading ">" hier[heading]
     hunt = 0
     next
 }


parse_blast.awk deprecated

parse_blast.awk deprecated

--- parse_blast.awk
+++ parse_blast.awk
@@ -1,240 +0,0 @@
-#!/usr/bin/awk -f
-
-
-
-
-function is_repetitive_hit(start,end,threshold,threshold2)
-{
-  overlap[0]= -1;
-  overlap[1]= -10;
-
-  if (region[0]>=start && region[0]<end) {
-    overlap[0]=region[0];
-    extent[0]=start;
-  }
-  else if (start>=region[0] && start<region[1]) {
-    overlap[0]=start;
-    extent[0]=region[0];
-  }
-  else { # WE HAVE NO OVERLAP, SO JUST RESET AND RETURN */
-    region[0]= start; # SAVE THE CURRENT REGION FOR CHECKING THE NEXT ONE*/
-    region[1]= end;
-    return 0;  # NO REPETITIVE OVERLAP */
-  }
-  if (region[1]>=start && region[1]<end) {
-    overlap[1]=region[1];
-    extent[1]=end;
-  }
-  else {
-    overlap[1]=end;
-    extent[1]=region[1];
-  }
-  if (overlap[0]>=0) { # GOT OVERLAP */
-    my_length=end-start;
-    if (overlap[1]-overlap[0]>threshold*my_length && overlap[1]-overlap[0]>threshold2*(region[1]-region[0])) {
-#      printf("REPEAT [%d,%d]: overlaps [%d,%d]\n",start,end,region[0],region[1]);
-      region[0]=extent[0]; # SAVE THE UNION OF THE OVERLAPPING REGIONS*/
-      region[1]=extent[1];
-      return 1; # THIS IS A REPEAT!*/
-    }
-  }
-
-  region[0]= start; # SAVE THE CURRENT REGION FOR CHECKING THE NEXT ONE*/
-  region[1]= end;
-  return 0;  # NO REPETITIVE OVERLAP */
-}
-
-
-
-
-
-function print_interval()
-{
-    if (mode=="all") {
-	if (IDENTITY_PERCENT+0<identity_min) {
-	    return;
-	}
-	if (BLAST_FRAME+0>=0) {
-	    printf("MATCH_INTERVAL\t%d\t%s\t%s\t%d\t%s\t%s\t%s\t%d\t%d\t%d\n",hit_id,SEQ_ID,SUBJ_ID,BLAST_SCORE+0,E_VALUE,IDENTITY_PERCENT,BLAST_FRAME,q_interval_start,i_query-q_interval_start,s_interval_start);
-	}
-	else {
-	    printf("MATCH_INTERVAL\t%d\t%s\t%s\t%d\t%s\t%s\t%s\t%d\t%d\t%d\n",hit_id,SEQ_ID,SUBJ_ID,BLAST_SCORE+0,E_VALUE,IDENTITY_PERCENT,BLAST_FRAME,q_interval_start,i_query-q_interval_start,i_subj-BLAST_FRAME);
-	}
-    }
-    else if (mode=="detail") {
-	printf("%d\t%d\t%d\t%d\t%d\n",hit_id,q_interval_start,i_query-1,s_interval_start,i_subj-BLAST_FRAME);
-    }
-}
-
-
-
-
-function print_hit()
-{
-  if (remove_repeats) {
-    if (is_repetitive_hit(QUERY_START,QUERY_END,0.9,0.8)) {
-      if (nrepeat++ > 20) {
-	printf("REMOVING REPEAT %d-%d\n",QUERY_START,QUERY_END);
-        return 0;
-      }
-    }
-    else {
-      nrepeat=0;
-    }
-  }
-    hit_id++;
-    query_len=length(QUERY_SEQ);
-    q_interval_start= -1;
-    i_query=QUERY_START;
-    if (BLAST_FRAME+0>0) {
-	i_subj=SUBJ_START;
-    }
-    else {
-	i_subj=SUBJ_END;
-    }
-    for (i=1;i<=query_len;i++) {
-	if (substr(QUERY_SEQ,i,1)=="-") {
-	    if (q_interval_start>0) {
-		print_interval();
-	    }
-	    q_interval_start= -1;
-	    i_subj+= BLAST_FRAME;
-	}
-	else {
-	    if (substr(SUBJ_SEQ,i,1)=="-") {
-		if (q_interval_start>0) {
-		    print_interval();
-		}
-		q_interval_start= -1;
-	    }
-	    else {
-		if (q_interval_start<0) {
-		    q_interval_start=i_query;
-		    s_interval_start=i_subj;
-		}
-		i_subj+= BLAST_FRAME;
-	    }
-	    i_query++;
-	}
-    }
-    if (q_interval_start>0) {
-	print_interval();
-    }
-    gsub("-","",QUERY_SEQ);
-    gsub("-","",SUBJ_SEQ);
-    if (mode=="summary") {
-	printf("%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",hit_id,SEQ_ID,SUBJ_ID,BLAST_SCORE,E_VALUE,IDENTITY_PERCENT,BLAST_FRAME,QUERY_START,QUERY_END,SUBJ_START,SUBJ_END);
-    }
-    QUERY_START=9999999999;
-    QUERY_END= -1;
-    SUBJ_START=9999999999;
-    SUBJ_END= -1;
-}
-
-
-
-/^Query=/ {
-    SEQ_ID=$2;
-    TITLE=substr($0,index($0,$3));
-    QUERY_START=9999999999;
-    QUERY_END= -1;
-}
-
-/No hits/ {
-}
-
-
-/^>/ {
-    if (QUERY_START<QUERY_END) {
-	print_hit();
-    }
-    SUBJ_ID=substr($1,2);
-    SUBJ_TITLE=substr($0,index($0,$2));
-    BLAST_FRAME="+1"
-}
-
-/^ Score =/ {
-    if (QUERY_START<QUERY_END) {
-	print_hit();
-    }
-    BLAST_SCORE=$3;
-    E_VALUE=$8;
-    if (substr(E_VALUE,1,1)=="e") {
-	E_VALUE="1" E_VALUE;
-    }
-    if (E_VALUE+0.0 == 0.0) {
-	E_VALUE=300;
-    }
-    else {
-	E_VALUE= -log(E_VALUE+0.0)/log(10.0);
-	if (E_VALUE=="inf") {
-	    E_VALUE=300;
-	}
-    }
-    QUERY_SEQ="";
-    SUBJ_SEQ="";
-    SUBJ_START=9999999999;
-    SUBJ_END= -1;
-}
-
-
-/^  Database:/ {
-    if (QUERY_START<QUERY_END) {
-	print_hit();
-    }
-}
-
-
-/Identities =/ {
-    IDENTITY_PERCENT=substr($4,2);
-    IDENTITY_PERCENT=substr(IDENTITY_PERCENT,1,index(IDENTITY_PERCENT,"%")-1);
-}
-
-
-/^ Frame =/ {
-    BLAST_FRAME=$3;
-}
-
-
-/^ Strand = / {
-    if ($5=="Plus") {
-	BLAST_FRAME="+1";
-    }
-    else if ($5=="Minus") {
-	BLAST_FRAME="-1";
-    }
-}
-
-
-/^Query:/ {
-    if ($2<QUERY_START) {
-	QUERY_START=$2;
-    }
-    if ($4<QUERY_START) {
-	QUERY_START=$4;
-    }
-    if ($2>QUERY_END) {
-	QUERY_END=$2;
-    }
-    if ($4>QUERY_END) {
-	QUERY_END=$4;
-    }
-    QUERY_SEQ=QUERY_SEQ $3;
-}
-
-
-/^Sbjct:/ {
-    if ($2<SUBJ_START) {
-	SUBJ_START=$2;
-    }
-    if ($4<SUBJ_START) {
-	SUBJ_START=$4;
-    }
-    if ($2>SUBJ_END) {
-	SUBJ_END=$2;
-    }
-    if ($4>SUBJ_END) {
-	SUBJ_END=$4;
-    }
-    SUBJ_SEQ=SUBJ_SEQ $3;
-}


Use SListRef instead of UnsafeMutablePointer<GSList>!

--- Gtk-3.0.awk
+++ Gtk-3.0.awk
@@ -2,7 +2,7 @@
 #
 # Patch the generated wrapper Swift code to handle special cases
 #
-BEGIN { depr_init = 0 ; comment = 0 }
+BEGIN { depr_init = 0 ; comment = 0 ; slist = 0 }
 /open .* ColorSelection/ { depr_init = 1 }
 /public .* ColorSelection/ { depr_init = 1 }
 /public .* HSV/ { depr_init = 1 }
@@ -10,6 +10,23 @@
 /open .* HSV/ { depr_init = 1 }
 /func getColumnHeaderCells/ { comment = 1 }
 /func getRowHeaderCells/ { comment = 1 }
+/^[^ ]/ { slist = 0 }
+/ UnsafeMutablePointer<GSList>! {/ {
+	slist = 1
+	gsub("UnsafeMutablePointer.GSList..", "SListRef?")
+}
+/return cast.rv.$/ {
+	if (slist) {
+		gsub("cast.rv.", "rv.map { SListRef($0) }")
+	}
+}
+/cast.newValue./ {
+	if (slist) {
+		gsub("cast.newValue.", "newValue.map { $0.ptr }")
+		slist = 0
+	}
+}
+/^    }$/ { slist = 0 }
 / init.. {/ {
 	if (depr_init) {
 		printf("@available(*, deprecated) ")


Initial cut at processing all BritBox programs

--- getBritBoxProgramsFrom-webscraper.awk
+++ getBritBoxProgramsFrom-webscraper.awk
@@ -28,7 +28,7 @@
     Rating = $8
     Description = $9

-    sub (/ Season[s]/,"",NumSeasons)
+    sub (/ Seasons?/,"",NumSeasons)
     sub( / min/,"",Duration)

     # Convert duration from minutes to HMS
@@ -36,37 +36,24 @@
     mins = Duration % 60
     hrs = int(Duration / 60)
     HMS = sprintf ("%02d:%02d:%02d", hrs, mins, secs)
+    if (HMS == "00:00:00")
+        HMS = ""

     # Titles starting with "The" should not sort based on "The"
-    if (match (showTitle, /^The /)) {
+    if (match (showTitle, /^The /))
         showTitle = substr(showTitle, 5) ", The"
+
+    # Indicate different types of programs
+    showtype = "S"
+    if (URL ~ /^\/us\/movie\//)
+        showtype = "M"
+
+    # Extract sortkey from URL
+    nflds = split (URL,fld,"_")
+    if (URL ~ /_[[:digit:]]*$/) {
+        sortkey = sprintf ("%s%05d", showtype, fld[nflds])
+        printf \
+            ("%s - %s\t=HYPERLINK(\"https://www.britbox.com%s\";\"%s\"\)\t%s\t%s\t%s\t%s\t%s\n",\
+             showTitle, sortkey, URL, showTitle, NumSeasons, HMS, Year, Rating, Description)
     }
 }
-
-/\/us\/movie\// {
-    # Extract movie sortkey from URL
-    nflds = split (URL,fld,"_")
-    if (URL ~ /_[[:digit:]]*$/) {
-        sortkey = sprintf ("M%05d", fld[nflds])
-        printf \
-            ("%s %s - mv\t=HYPERLINK(\"https://www.britbox.com%s\";\"%s, %s, %s\"\)\t\t%s\t%s\t%s\t%s\n", \
-             showTitle, sortkey, URL, showTitle, sortkey, \
-             Title, HMS, Year, Rating, Description)
-    }
-    next
-}
-
-/\/us\/show\// {
-    # Extract show sortkey from URL
-    nflds = split (URL,fld,"_")
-    if (URL ~ /_[[:digit:]]*$/) {
-        sortkey = sprintf ("S%05d", fld[nflds])
-        printf \
-            ("%s %s - sh\t=HYPERLINK(\"https://www.britbox.com%s\";\"%s, %s, %s\"\)\t\t%s\t%s\t%s\t%s\n", \
-             showTitle, sortkey, URL, showTitle, sortkey, \
-             Title, HMS, Year, Rating, Description)
-    }
-    next
-}
-
-


minor

minor

--- lib/obs.awk
+++ lib/obs.awk
@@ -6,7 +6,8 @@
   print "
Make an observation
";
   print "
for tree with tag " f["tag"] "
 (Please double check the tag code)
";
   print "<form enctype=\"multipart/form-data\" method=\"post\" action=\"map?method=obsD\">" ;
-  print "
<input type=\"hidden\" name=\"tag\" value=\"" f["tag"] "\" />Type of observation:
<select name=\"type\"><option value=\"bud\">Spring buds just breaking open</option><option value=\"flower\">In flower (any stage)</option><option value=\"fruit\">In fruit (any stage)</option><option value=\"fall\">Outstanding fall color</option><option value=\"damage\">Report plant damage</option></select>
";
+  print "
<input type=\"hidden\" name=\"tag\" value=\"" f["tag"] "\" />Type of observation:
<select name=\"type\"><option value=\"bud\">Spring buds just breaking open</option><option value=\"flower\">In flower (any stage)</option><option value=\"fruit\">In fruit (any stage)</option><option value=\"fall\">Outstanding fall color</option></select>
";
+  # <option value=\"damage\">Report plant damage</option></select>
";
   print "
Upload a photo (optional)
(small please: <2 MB; NB: iPhone does not support file uploads)
<input type=\"file\" name=\"photo\" />
";
   print "
Your notes (optional):
<textarea name=\"notes\" cols=\"30\" rows=\"2\"></textarea>
";
   print "
Your email (optional)
<input type=\"text\" name=\"email\" size=\"30\"/>
";


makeDistortosConfiguration.awk: modify shebang

Use more generic "/bin/awk" instead of "/usr/bin/awk".

--- scripts/makeDistortosConfiguration.awk
+++ scripts/makeDistortosConfiguration.awk
@@ -1,4 +1,4 @@
-#!/usr/bin/awk -f
+#!/bin/awk -f

 #
 # file: makeDistortosConfiguration.awk
@@ -8,7 +8,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
 # distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
-# date: 2015-08-25
+# date: 2015-09-25
 #

 BEGIN {


[CLEANUP] - update year in checkFile.awk

--- bin/checkFile.awk
+++ bin/checkFile.awk
@@ -330,7 +330,7 @@
 /^\/\/ Copyright .* Pentaho/ && strict > 1 {
     # We assume that '--strict' is only invoked on files currently being
     # edited. Therefore we would expect the copyright to be current.
-    if ($0 !~ /-2015/) {
+    if ($0 !~ /-2016/) {
         error(fname, FNR, "copyright is not current");
     }
 }


Languages: add Maithili

Languages: add Maithili

--- include/Languages.awk
+++ include/Languages.awk
@@ -983,6 +983,19 @@
     Locale["mk"]["iso"]                = "mkd"
     Locale["mk"]["glotto"]             = "mace1250"
     Locale["mk"]["script"]             = "Cyrl"
+
+    # Maithili
+    Locale["mai"]["name"]              = "Maithili"
+    Locale["mai"]["endonym"]           = "मैथिली"
+    #Locale["mai"]["translations-of"]
+    #Locale["mai"]["definitions-of"]
+    #Locale["mai"]["synonyms"]
+    #Locale["mai"]["examples"]
+    #Locale["mai"]["see-also"]
+    Locale["mai"]["family"]            = "Indo-European"
+    Locale["mai"]["iso"]               = "mai"
+    Locale["mai"]["glotto"]            = "mait1250"
+    Locale["mai"]["script"]            = "Deva"

     #59 Malagasy (Plateau Malagasy)
     Locale["mg"]["name"]               = "Malagasy"


Translate: header comment

Translate: header comment


export PATH variable

export PATH variable

--- usr.sbin/ndc/ndcedit.awk
+++ usr.sbin/ndc/ndcedit.awk
@@ -1,5 +1,11 @@
-# $Id: awkedit,v 1.1.1.1 1996/08/29 19:42:59 peter Exp $
+# $Id: ndcedit.awk,v 1.1 1996/08/29 21:46:46 peter Exp $
 NR == 3 {
+	print "#"
+	print "# This file is generated automatically, do not edit it here!"
+	print "# Please change src/usr.sbin/ndc/ndcedit.awk instead"
+	print "#"
+	print ""
+
 	print "# If there is a global system configuration file, suck it in."
 	print "if [ -f /etc/sysconfig ]; then"
 	print "\t. /etc/sysconfig"
@@ -18,7 +24,12 @@
 		printf "\t%s\n", $0
 		printf "\t\tfi\n"
 	} else {
-		gsub(":/usr/ucb:", ":", $0);
+	        if (/PATH=/) {
+			gsub(":/usr/ucb:", ":", $0);
+		      	if (!/export/) {
+				$0=$0"\nexport PATH";
+			}
+		}
 		print;
 	}
 }


TestCommons: correct escape() and parameterize()

--- test/TestCommons.awk
+++ test/TestCommons.awk
@@ -109,8 +109,8 @@
     {
         assertEqual(escape(""), "")
         assertEqual(escape("foo"), "foo")
-        assertEqual(escape("\""), "\\\\\"")
-        assertEqual(escape("\"foo\""), "\\\\\"foo\\\\\"")
+        assertEqual(escape("\""), "\\\"")
+        assertEqual(escape("\"foo\""), "\\\"foo\\\"")
     }
     T("parameterize()", 10)
     {
@@ -123,7 +123,7 @@
         assertEqual(parameterize("foo", "\""), "\"foo\"")
         assertEqual(parameterize("foo bar", "\""), "\"foo bar\"")
         assertEqual(parameterize("foo 'bar", "\""), "\"foo 'bar\"")
-        assertEqual(parameterize("foo \"bar\"", "\""), "\"foo \\\\\"bar\\\\\"\"")
+        assertEqual(parameterize("foo \"bar\"", "\""), "\"foo \\\"bar\\\"\"")
     }
     T("toString()", 4)
     {


globally substitute simple stuff

globally substitute simple stuff


bump version to 0.9.1-dev

bump version to 0.9.1-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.9.0.9"
+    Version     = "0.9.1-dev"
     ReleaseDate = "2015-10-05"
     Command     = "trans"
     EntryPoint  = "translate.awk"


Moved shbang to top in removeTestCourses.awk


Languages: no more theme for getDetails()

--- include/Languages.awk
+++ include/Languages.awk
@@ -1849,17 +1849,16 @@
     iso = group[1]
     split(getName(code), group, " ")
     language = group[1]
-    return sprintf("%s\n", prettify("translation", getDisplay(code)))   \
-        prettify("languages",
-                 sprintf("%-22s%s\n", "Name", ansi("bold", getName(code))) \
-                 sprintf("%-22s%s\n", "Family", ansi("bold", getFamily(code))) \
-                 sprintf("%-22s%s\n", "Writing system", ansi("bold", script)) \
-                 sprintf("%-22s%s\n", "Code", ansi("bold", getCode(code))) \
-                 sprintf("%-22s%s\n", "ISO 639-3", ansi("bold", iso))   \
-                 sprintf("%-22s%s\n", "Ethnologue", ansi("bold", "http://www.ethnologue.com/language/" iso)) \
-                 sprintf("%-22s%s\n", "Glottolog", getGlotto(code) ?
-                         ansi("bold", "http://glottolog.org/resource/languoid/id/" getGlotto(code)) : "") \
-                 sprintf("%-22s%s", "Wikipedia", ansi("bold", "http://en.wikipedia.org/wiki/" language "_language")))
+    return ansi("bold", sprintf("%s\n", getDisplay(code)))              \
+        sprintf("%-22s%s\n", "Name", ansi("bold", getName(code)))       \
+        sprintf("%-22s%s\n", "Family", ansi("bold", getFamily(code)))   \
+        sprintf("%-22s%s\n", "Writing system", ansi("bold", script))    \
+        sprintf("%-22s%s\n", "Code", ansi("bold", getCode(code)))       \
+        sprintf("%-22s%s\n", "ISO 639-3", ansi("bold", iso))            \
+        sprintf("%-22s%s\n", "Ethnologue", ansi("bold", "http://www.ethnologue.com/language/" iso)) \
+        sprintf("%-22s%s\n", "Glottolog", getGlotto(code) ?
+                ansi("bold", "http://glottolog.org/resource/languoid/id/" getGlotto(code)) : "") \
+        sprintf("%-22s%s", "Wikipedia", ansi("bold", "http://en.wikipedia.org/wiki/" language "_language"))
 }

 # Add /slashes/ for IPA phonemic notations and (parentheses) for others.


Fix occasional msreplic_H/max_connections subtest failure due to non-zero value of CTL JnlPoolWrite Sleep (#280)

We had a test failure with the below diff.

36,37c36,37
< CTL JnlPoolWrite Sleep       Cntr                        0 [0x00000000]
< CTL JnlPoolWrite Sleep       Seqno                       0 [0x00000000]
---
> CTL JnlPoolWrite Sleep       Cntr                        1 [0x00000000]
> CTL JnlPoolWrite Sleep       Seqno                    1246 [0x00000000]

These counters can be non-zero in case of system load and so the test is now fixed to
allow for an arbitrary non-zero value of the "CTL JnlPoolWrite Sleep" line items
just like it already does for "CTL ReplPhs2Clnup IsPrcAlv".

--- msreplic_H/u_inref/dumppool_filter.awk
+++ msreplic_H/u_inref/dumppool_filter.awk
@@ -3,7 +3,7 @@
 # Copyright (c) 2013-2016 Fidelity National Information		#
 # Services, Inc. and/or its subsidiaries. All rights reserved.	#
 #								#
-# Copyright (c) 2017 YottaDB LLC. and/or its subsidiaries.	#
+# Copyright (c) 2017-2018 YottaDB LLC. and/or its subsidiaries.	#
 # All rights reserved.						#
 #								#
 #	This source code contains the intellectual property	#
@@ -67,6 +67,8 @@
 	gsub(/CTL Phase2 Commit Index1 *[1-9][0-9]* .0x[0-9A-F][0-9A-F]*./, "CTL Phase2 Commit Index1                   ##PHS2CMTINDX## [0x........]");
 	gsub(/CTL Phase2 Commit Index2 *[1-9][0-9]* .0x[0-9A-F][0-9A-F]*./, "CTL Phase2 Commit Index2                   ##PHS2CMTINDX## [0x........]");
 	# Most below can sometime be non-zero (depending on system load when running test) so convert a non-zero value into 0 for a deterministic reference file.
+	gsub(/CTL JnlPoolWrite Sleep       Cntr  *[1-9][0-9]* .0x[0-9A-F][0-9A-F]*./, "CTL JnlPoolWrite Sleep       Cntr                        0 [0x00000000]");
+	gsub(/CTL JnlPoolWrite Sleep       Seqno *[1-9][0-9]* .0x[0-9A-F][0-9A-F]*./, "CTL JnlPoolWrite Sleep       Seqno                       0 [0x00000000]");
 	gsub(/CTL ReplPhs2Clnup IsPrcAlv   Cntr  *[1-9][0-9]* .0x[0-9A-F][0-9A-F]*./, "CTL ReplPhs2Clnup IsPrcAlv   Cntr                        0 [0x00000000]");
 	gsub(/CTL ReplPhs2Clnup IsPrcAlv   Seqno *[1-9][0-9]* .0x[0-9A-F][0-9A-F]*./, "CTL ReplPhs2Clnup IsPrcAlv   Seqno                       0 [0x00000000]");
 	gsub(/Remote Supports Triggers                    TRUE/, "Remote Supports Triggers       ##TRUE_OR_FALSE##");


Languages: add Luxembourgish language

Languages: add Luxembourgish language

--- include/Languages.awk
+++ include/Languages.awk
@@ -182,6 +182,19 @@
     Locale["ku"]["iso"]                = "kur"
     Locale["ku"]["glotto"]             = "kurd1259"
     Locale["ku"]["script"]             = "Latn"
+
+    #? Luxembourgish
+    Locale["lb"]["name"]               = "Luxembourgish"
+    Locale["lb"]["endonym"]            = "Lëtzebuergesch"
+    #Locale["lb"]["translations-of"]
+    #Locale["lb"]["definitions-of"]
+    #Locale["lb"]["synonyms"]
+    #Locale["lb"]["examples"]
+    #Locale["lb"]["see-also"]
+    Locale["lb"]["family"]             = "Indo-European"
+    Locale["lb"]["iso"]                = "ltz"
+    Locale["lb"]["glotto"]             = "luxe1241"
+    Locale["lb"]["script"]             = "Latn"

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


Update generate_netbsd_syscalls.awk for NetBSD 8.99.25

Register new syscall getsockopt2.
Drop removed syscalls pmc_get_info and pmc_control.

While there address compiler warnings about potentially
unused variables.

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

--- utils/generate_netbsd_syscalls.awk
+++ utils/generate_netbsd_syscalls.awk
@@ -1464,6 +1464,8 @@
       pcmd("  }")
       pcmd("}")
     }
+  } else if (syscall == "getsockopt2") {
+    pcmd("/* TODO */")
   } else if (syscall == "fpathconf") {
     pcmd("/* Nothing to do */")
   } else if (syscall == "getrlimit") {
@@ -1982,10 +1984,6 @@
     pcmd("if (nsa_) {")
     pcmd("  PRE_READ(nsa_, sizeof(__sanitizer_sigaction));")
     pcmd("}")
-  } else if (syscall == "pmc_get_info") {
-    pcmd("/* TODO */")
-  } else if (syscall == "pmc_control") {
-    pcmd("/* TODO */")
   } else if (syscall == "rasctl") {
     pcmd("/* Nothing to do */")
   } else if (syscall == "kqueue") {
@@ -2935,16 +2933,14 @@
   } else if (syscall == "sendmmsg") {
     if (mode == "pre") {
       pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
-      pcmd("unsigned int vlen = (vlen_ > 1024 ? 1024 : vlen_);")
       pcmd("if (mmsg) {")
-      pcmd("  PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * vlen);")
+      pcmd("  PRE_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));")
       pcmd("}")
     } else {
       pcmd("struct __sanitizer_mmsghdr *mmsg = (struct __sanitizer_mmsghdr *)mmsg_;")
-      pcmd("unsigned int vlen = (vlen_ > 1024 ? 1024 : vlen_);")
       pcmd("if (res >= 0) {")
       pcmd("  if (mmsg) {")
-      pcmd("    POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * vlen);")
+      pcmd("    POST_READ(mmsg, sizeof(struct __sanitizer_mmsghdr) * (vlen_ > 1024 ? 1024 : vlen_));")
       pcmd("  }")
       pcmd("}")
     }


feature: Adds hotfix commit prefix (#2)

feature: Adds hotfix commit prefix (#2)

--- changelog.awk
+++ changelog.awk
@@ -2,7 +2,7 @@
 BEGIN {
 	REPO_URL = getRepoURL()
 	# Prefixes that determine whether a commit will be printed
-	CHANGELOG_REGEX = "^(changelog|fix|docs|chore|feat|feature|refactor|update): "
+	CHANGELOG_REGEX = "^(changelog|fix|hotfix|docs|chore|feat|feature|refactor|update): "
 	FS="|"
 	# %D: tags
 	# %s: commit message


put structs after copyright notice; ok dlg

--- dev/pci/devlist2h.awk
+++ dev/pci/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.7 2007/02/21 13:08:22 dlg Exp $
+#	$OpenBSD: devlist2h.awk,v 1.8 2007/02/21 13:17:28 deraadt Exp $
 #	$NetBSD: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -47,18 +47,6 @@
 	printf(" *\t%s\n", VERSION) > dfile
 	printf(" */\n\n") > dfile

-	printf("/* Descriptions of known vendors and devices. */\n") > dfile
-	printf("struct pci_known_vendor {\n") > dfile
-	printf("\tpci_vendor_id_t vendor;\n") > dfile
-	printf("\tconst char *vendorname;\n") > dfile
-	printf("};\n\n") > dfile
-
-	printf("struct pci_known_product {\n") > dfile
-	printf("\tpci_vendor_id_t vendor;\n") > dfile
-	printf("\tpci_product_id_t product;\n") > dfile
-	printf("\tconst char *productname;\n") > dfile
-	printf("};\n\n") > dfile
-
 	printf("/*\n") > hfile
 	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
 	    > hfile
@@ -178,6 +166,19 @@

 	if (nvendor_dup > 0)
 		exit(1);
+
+	printf("/* Descriptions of known vendors and devices. */\n") > dfile
+	printf("struct pci_known_vendor {\n") > dfile
+	printf("\tpci_vendor_id_t vendor;\n") > dfile
+	printf("\tconst char *vendorname;\n") > dfile
+	printf("};\n\n") > dfile
+
+	printf("struct pci_known_product {\n") > dfile
+	printf("\tpci_vendor_id_t vendor;\n") > dfile
+	printf("\tpci_product_id_t product;\n") > dfile
+	printf("\tconst char *productname;\n") > dfile
+	printf("};\n\n") > dfile
+

 	printf("static const struct pci_known_product pci_known_products[] = {\n") \
 	    > dfile


Languages: add Tsonga

Languages: add Tsonga

--- include/Languages.awk
+++ include/Languages.awk
@@ -1602,6 +1602,19 @@
     Locale["ti"]["iso"]                = "tir"
     Locale["ti"]["glotto"]             = "tigr1271"
     Locale["ti"]["script"]             = "Ethi"
+
+    # Tsonga
+    Locale["ts"]["name"]               = "Tsonga"
+    Locale["ts"]["endonym"]            = "Xitsonga"
+    #Locale["ts"]["translations-of"]
+    #Locale["ts"]["definitions-of"]
+    #Locale["ts"]["synonyms"]
+    #Locale["ts"]["examples"]
+    #Locale["ts"]["see-also"]
+    Locale["ts"]["family"]             = "Atlantic–Congo"
+    Locale["ts"]["iso"]                = "tso"
+    Locale["ts"]["glotto"]             = "tson1249"
+    Locale["ts"]["script"]             = "Latn"

     #96 Turkish
     Locale["tr"]["name"]               = "Turkish"


Translate: update

Translate: update

--- include/Translate.awk
+++ include/Translate.awk
@@ -4,20 +4,20 @@

 # Detect external audio player (mplayer, mpv, mpg123).
 function initAudioPlayer() {
-    AudioPlayer = !system("mplayer >/dev/null 2>/dev/null") ?
+    AudioPlayer = !system("mplayer" SUPOUT SUPERR) ?
         "mplayer" :
-        (!system("mpv >/dev/null 2>/dev/null") ?
+        (!system("mpv" SUPOUT SUPERR) ?
          "mpv" :
-         (!system("mpg123 >/dev/null 2>/dev/null") ?
+         (!system("mpg123 --version" SUPOUT SUPERR) ?
           "mpg123" :
           ""))
 }

 # Detect external speech synthesizer (say, espeak).
 function initSpeechSynthesizer() {
-    SpeechSynthesizer = !system("say '' >/dev/null 2>/dev/null") ?
+    SpeechSynthesizer = !system("say ''" SUPOUT SUPERR) ?
         "say" :
-        (!system("espeak '' >/dev/null 2>/dev/null") ?
+        (!system("espeak ''" SUPOUT SUPERR) ?
          "espeak" :
          "")
 }
@@ -72,7 +72,7 @@
         "&tl=" tl "&q=" preprocess(text)

     # Don't use getline from pipe here - the same pipe will be run only once for each AWK script!
-    system(Option["player"] " '" url "' >/dev/null 2>/dev/null")
+    system(Option["player"] " " parameterize(url) SUPOUT SUPERR)
 }

 # Get the translation of a string.
@@ -404,7 +404,7 @@
 # Translate the source text (into all target languages).
 function translate(text, inline,
                    ####
-                   i, j, playlist, saveSortedIn) {
+                   i, j, r, playlist, saveSortedIn) {

     if (!getCode(Option["hl"])) {
         # Check if home language is supported
@@ -435,13 +435,16 @@

         if (inline &&
             startsWithAny(text, UriSchemes) == "file://") {
+            # translate URL only from command-line parameters (inline)
             fileTranslation(text)
         } else if (inline &&
                    startsWithAny(text, UriSchemes) == "http://" ||
                    startsWithAny(text, UriSchemes) == "https://") {
+            # translate URL only from command-line parameters (inline)
             webTranslation(text, Option["sl"], Option["tl"][i], Option["hl"])
         } else {
-            print getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"], playlist) > Option["output"]
+            r = getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"], playlist)
+            print r > Option["output"]

             if (Option["play"])
                 if (Option["player"])


Delete analyze_path.awk

Delete analyze_path.awk

--- scripts/analyze_path.awk
+++ scripts/analyze_path.awk
@@ -1,49 +0,0 @@
-#!/usr/bin/awk -f
-# extract `obs_id' and `source name' from path
-#
-# LIweitiaNux <liweitianux@gmail.com>
-# 2013/02/04
-#
-# input:
-#     path that include `oi' and `source name'
-#     e.g.:
-#
-# output:
-#
-
-# main part
-{
-    if (NF==1) {
-        ## oi & name
-        input=($1 "/")
-        if (input ~ /_oi/) {
-            ## PATTERN: .../$name_oi$oi/...
-            idx_oi = match(input, /oi[0-9]+/) + 2;    # `2' skip the `oi'
-            len_oi = RLENGTH - 2;
-            oi = substr(input, idx_oi, len_oi);
-            idx_name = match(input, /\/[a-zA-Z0-9.+-]+_oi/) + 1;
-            len_name = RLENGTH - 4;
-            name = substr(input, idx_name, len_name);
-        }
-        else {
-            ## PATTERN: .../$name/$oi/...
-            idx_oi = match(input, /\/[0-9]+\//) + 1;
-            len_oi = RLENGTH - 2;
-            oi = substr(input, idx_oi, len_oi);
-            idx_name1 = match(input, /\/[a-zA-Z0-9_.+-]+\/[0-9]+\//);
-            len_name1 = RLENGTH;
-            name1 = substr(input, idx_name1, len_name1);
-            idx_name = match(name1, /\/[a-zA-Z0-9_.+-]+\//) + 1;
-            len_name = RLENGTH - 2;
-            name = substr(name1, idx_name, len_name);
-        }
-        ## output
-        printf("input: %s\n", input)
-        printf("oi: %s\nname: %s\n", oi, name)
-    }
-    else {
-        printf("*** WARNING: invalid input: %s\n", $0)
-    }
-}
-# END
-


Fix a leftover "iwi_boot" string.

Fix a leftover "iwi_boot" string.

Submitted by:	gallatin

--- sys/tools/fw_stub.awk
+++ sys/tools/fw_stub.awk
@@ -174,7 +174,7 @@
 };\
 DECLARE_MODULE(" opt_m "_fw, " opt_m "_fw_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);\
 MODULE_VERSION(" opt_m "_fw, 1);\
-MODULE_DEPEND(iwi_boot_fw, firmware, 1, 1, 1);\
+MODULE_DEPEND(" opt_m "_fw, firmware, 1, 1, 1);\
 ");

 if (opt_c)


Add single episode warning

Add single episode warning

--- getAcornFrom-showPages.awk
+++ getAcornFrom-showPages.awk
@@ -263,6 +263,8 @@
     if (durationLinesFound == 0) {
         printf ("==> No durations: %s\t%s\n", shortURL, showTitle) >> ERRORS
     }
+    if (showEpisodes == 1)
+        printf ("==> Only one episode: %s\t%s\n", shortURL, showTitle) >> ERRORS
     showLink = "=HYPERLINK(\"" showURL "\";\"" showTitle "\")"
     showDuration = sprintf ("%02d:%02d:%02d", showHrs, showMins, showSecs)
     # Print "show" line to SHORT_SPREADSHEET with showDuration


uppercase

uppercase

--- tools/backgrounds.awk
+++ tools/backgrounds.awk
@@ -7,7 +7,7 @@
   print ""
   print "
"
   print "  "
-  print "  Gabor.Greif@alcatel-lucent.com"
+  print "  Gabor.Greif@alcatel-lucent.com"
   print "
"
   print ""
   print "
"


make-barcodes.awk: Validate input. - Make sure it has the right number of columns. - Make sure + and @ lines begin with those characters.

--- make-barcodes.awk
+++ make-barcodes.awk
@@ -39,6 +39,24 @@
   }
 }

+# Validate input.
+{
+  for (i = 1; i <= 8; i++) {
+    if (!$i) {
+      print "Error on read pair (line) " NR ": Missing or empty columns." > "/dev/stderr"
+      exit 1
+    }
+  }
+  if (substr($1, 1, 1) != "@" || substr($2, 1, 1) != "@") {
+    print "Error on read pair (line) " NR ": Read name line doesn't begin with '@'." > "/dev/stderr"
+    exit 1
+  }
+  if (substr($5, 1, 1) != "+" || substr($6, 1, 1) != "+") {
+    print "Error on read pair (line) " NR ": '+' column does not begin with '+'." > "/dev/stderr"
+    exit 1
+  }
+}
+
 $3 && $4 {
   alpha = substr($3, 1, TAG_LEN)
   beta = substr($4, 1, TAG_LEN)


duh...actually test the change this time


Update permissions

Update permissions