Translate: correct the behavior of download-audio

--- include/Translate.awk
+++ include/Translate.awk
@@ -227,26 +227,31 @@
             webTranslation(text, Option["sl"], Option["tl"][i], Option["hl"])
         } else {
             if (!Option["no-translate"])
-                p(getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"], playlist, il))
+                p(getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"] || Option["download-audio"], playlist, il))
             else
                 il[0] = Option["sl"] == "auto" ? "en" : Option["sl"]

             if (Option["play"] == 1) {
-                if (Option["player"]) {
+                if (Option["player"])
                     for (j in playlist)
                         play(playlist[j]["text"], playlist[j]["tl"])
-                    if (Option["download-audio"])
-                        download_audio(playlist[length(playlist) - 1]["text"], playlist[length(playlist) - 1]["tl"])
-                } else if (SpeechSynthesizer)
+                else if (SpeechSynthesizer)
                     for (j in playlist)
                         print playlist[j]["text"] | SpeechSynthesizer
             } else if (Option["play"] == 2) {
-                if (Option["player"]) {
+                if (Option["player"])
                     play(text, il[0])
-                    if (Option["download-audio"])
-                        download_audio(text, il[0])
-                } else if (SpeechSynthesizer)
+                else if (SpeechSynthesizer)
                     print text | SpeechSynthesizer
+            }
+
+            if (Option["download-audio"] == 1) {
+                # Download the translation unless used with -sp or -no-trans
+                if (Option["play"] != 2 && !Option["no-translate"])
+                    download_audio(playlist[length(playlist) - 1]["text"], \
+                                   playlist[length(playlist) - 1]["tl"])
+                else
+                    download_audio(text, il[0])
             }
         }
     }


Fix translation table for JIS keys; reported by Nakano Takaharu.


Languages: add Papiamento language (yandex only)

--- include/Languages.awk
+++ include/Languages.awk
@@ -1646,6 +1646,20 @@
     Locale["or"]["iso"]                = "ori"
     Locale["or"]["glotto"]             = "macr1269"
     Locale["or"]["script"]             = "Orya"
+
+    #? Papiamento
+    Locale["pap"]["support"]           = "yandex-only"
+    Locale["pap"]["name"]              = "Papiamento"
+    Locale["pap"]["endonym"]           = "Papiamentu"
+    #Locale["pap"]["translations-of"]
+    #Locale["pap"]["definitions-of"]
+    #Locale["pap"]["synonyms"]
+    #Locale["pap"]["examples"]
+    #Locale["pap"]["see-also"]
+    Locale["pap"]["family"]            = "Indo-European"
+    Locale["pap"]["iso"]               = "pap"
+    Locale["pap"]["glotto"]            = "papi1253"
+    Locale["pap"]["script"]            = "Latn"

     #? Romansh
     Locale["rm"]["support"]            = "unstable"


code cleanup

code cleanup

--- include/Translate.awk
+++ include/Translate.awk
@@ -220,8 +220,8 @@
         if (!anything(oPhonetics)) wShowOriginalPhonetics = 0
         if (!anything(phonetics)) wShowTranslationPhonetics = 0
         if (il == tl && isarray(oWordClasses)) {
-            wShowOriginalDictionary = 1 ###FIXME
-            wShowTranslation = 0        ###FIXME
+            wShowOriginalDictionary = 1
+            wShowTranslation = 0
         }
         hasWordClasses = isarray(wordClasses) && anything(wordClasses)
         hasAltTranslations = isarray(altTranslations[0]) && anything(altTranslations[0])
@@ -483,7 +483,7 @@
                 translate(line)

                 # Interactive verbose mode: newline after each translation
-                if (Option["verbose"]) printf "\n"
+                if (Option["verbose"]) printf RS
             }

             prompt()


refactored

refactored

--- tools/hierarchy.awk
+++ tools/hierarchy.awk
@@ -2,11 +2,22 @@
     heading = 0
 }

-hunt && /class="section_anchor">/ {
+## this is for google wiki conventions
+!insertslide && hunt && /class="section_anchor">/ {
     hier[heading] = $0
     sub(/<\/a>/, "", hier[heading])
     sub(/<\/a>/, "", hier[heading])
+    insertslide = 1
+}

+## this is for twiki conventions
+!insertslide && hunt && /^<a\ name="/ {
+    hier[heading] = $0
+    sub(/<\/a>/, "", hier[heading])
+    insertslide = 1
+}
+
+insertslide {
     if (heading == 2)
     {
       here = "⋅ " hier[heading]
@@ -35,42 +46,7 @@
     }
     print "<h" heading ">" hier[heading]
     hunt = 0
-    next
-}
-
-## this is for twiki conventions
-hunt && heading && /^<a\ name="/ {
-    hier[heading] = $0
-    sub(/<\/a>/, "", hier[heading])
-
-    if (heading == 2)
-    {
-      here = "⋅ " hier[heading]
-    }
-    else if (heading == 3)
-    {
-      here = "– " hier[heading]
-    }
-    else if (heading >= 4)
-    {
-      here = "— " hier[heading]
-    }
-    else
-    {
-      here = hier[heading]
-    }
-
-    if (slide) print "
"
-    print "
"
-    slide = 1
-    if (heading > 1) {
-      print "
" here "
"
-    }
-    for (i=1; i < heading; ++i) {
-      print "<h" i " style='color: #C0C0C0;'>" hier[i] "</h" i ">"
-    }
-    print "<h" heading ">" hier[heading]
-    hunt = 0
+    insertslide = 0
     next
 }


Languages: add Amharic language

Languages: add Amharic language

--- include/Languages.awk
+++ include/Languages.awk
@@ -13,6 +13,19 @@
 #      <https://en.wikipedia.org/wiki/ISO_15924#List_of_codes>
 #      <http://glottolog.org/>
 function initLocale(    i) {
+
+    #? Amharic
+    Locale["am"]["name"]               = "Amharic"
+    Locale["am"]["endonym"]            = "አማርኛ"
+    #Locale["am"]["translations-of"]
+    #Locale["am"]["definitions-of"]
+    #Locale["am"]["synonyms"]
+    #Locale["am"]["examples"]
+    #Locale["am"]["see-also"]
+    Locale["am"]["family"]             = "Afro-Asiatic"
+    Locale["am"]["iso"]                = "amh"
+    Locale["am"]["glotto"]             = "amha1245"
+    Locale["am"]["script"]             = "Ethi"

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


Translate: improve getResponse() and print detailed debug message (for issue #64)

--- include/Translate.awk
+++ include/Translate.awk
@@ -73,8 +73,10 @@
         header = header "User-Agent: " Option["user-agent"] "\n"

     print header |& HttpService
-    while ((HttpService |& getline) > 0)
-        content = $0
+    while ((HttpService |& getline) > 0) {
+        if (length($0) > 1) content = $0
+        l(sprintf("%4s bytes > %s", length($0), $0))
+    }
     close(HttpService)

     return assert(content, "[ERROR] Null response.")


Generate `include_directories` for `CMakeLists.txt` etc.

	modified:   code/awk/generate_source_list_from_make_output.awk

--- code/awk/generate_source_list_from_make_output.awk
+++ code/awk/generate_source_list_from_make_output.awk
@@ -3,6 +3,8 @@
     # This program generates source list to be used in `CMakeLists.txt`
     # or elsewhere using `foo.txt` produced by `make >foo.txt 2>&1` as input.

+    array_index = 0;
+    split("", dir_array);
     current_dir = "";
     new_filename = "";
     current_filename = "";
@@ -50,6 +52,9 @@

         # read current dir.
         current_dir = substr($0, junk_part_length, length($0) - junk_part_length);
+
+        # store current dir into array.
+        dir_array[array_index++] = current_dir "/";
     }
     else if (cpp_match_index > 0)
     {
@@ -62,3 +67,15 @@
         get_filename();
     }
 }
+END{
+    n_dirs = array_index;
+    asort(dir_array);
+
+    print "";
+    print "include_directories(";
+
+    for (i = 0; i < n_dirs; i++)
+    {
+        print dir_array[i];
+    }
+} # END


Added exactCells parameter to the soloBasicCellFilter.awk script tp specify exact number of cells. Parameters can now be specified as variables with awk -v ...

--- extras/scripts/soloBasicCellFilter.awk
+++ extras/scripts/soloBasicCellFilter.awk
@@ -1,7 +1,17 @@
+# usage awk -v exactCells=... -v maxCells=... -v maxPercentile=... -v maxMinRatio=... -f soloBasicCellFilter.awk
 BEGIN {
-    maxCells=3000;
-    maxPercentile=0.99;
-    maxMinRatio=10;
+    # default values - if variables were not defined by the user
+    if (exactCells==0)
+        exactCells=0;
+    if (maxCells==0)
+        maxCells=3000;
+    if (maxPercentile==0)
+        maxPercentile=0.99;
+    if (maxMinRatio==0)
+        maxMinRatio=10;
+
+    print "Parameters: " "exactCells=" exactCells, "maxCells=" maxCells, "maxPercentile=", maxPercentile, "maxMinRatio=", maxMinRatio;
+
     nHeaderLines=3;
     fOutCB=ARGV[1] ".filtered";
     fOutMat=ARGV[2] ".filtered";
@@ -28,6 +38,9 @@
     nMax=cellTotSort[-int((1-maxPercentile)*maxCells)+length(cellTot)];
     nMin=nMax/maxMinRatio;

+    if (exactCells>0)
+        nMin=length(cellTot)<exactCells ? cellTotSort[1] : cellTotSort[length(cellTot)-exactCells];
+
     nCell=0;
     for (ii=1; ii<=length(CB); ii++) {
         if (cellTot[ii]>=nMin) {
@@ -38,7 +51,11 @@
         };
     };

-    print cellTotSort[length(cellTotSort)]+0,nMax,nMin,nCell;
+    if (exactCells==0) {
+        print "maxUMIperCell=" cellTotSort[length(cellTotSort)]+0,"Robust maxUMIperCel=" nMax,"minUMIperCell=" nMin, "Filtered N cells=", nCell;
+    } else {
+        print "total N cells=" length(cellTot), "exactCells=" exactCells, "minUMIperCell=" nMin;
+    };

     nMat=0;
     for (ii=nHeaderLines+1; ii<=nLines; ii++) {


AWK converstion script for CMIP5-table to Bash case list

--- rewrite-cmor-table-to-bash-case.awk
+++ rewrite-cmor-table-to-bash-case.awk
@@ -41,7 +41,7 @@
   newvar="none"
   no_ws=20
   ws=repeat(" ", no_ws, rep, i)
-  print "case"
+  print "case ${var_in[$var]} in"
 }

 {


dtx_check.gawk: add check for repetitive SID FIRST

Change-Id: Id7acdfae7880fb488b65435ab8d33f2874499967

--- contrib/dtx_check.gawk
+++ contrib/dtx_check.gawk
@@ -38,6 +38,10 @@
 		}
 		if ("FIRST_P2" != $2 && "FIRST_P1" == TYPE) {
 			CHK = "FAIL: " TYPE " followed by " $2 " instead of P2."
+			ERR++
+		}
+		if ("FIRST" == $2 && "FIRST" == TYPE) {
+			CHK = "FAIL: multiple SID FIRST in a row."
 			ERR++
 		}
 		if ("OK" == CHK && "ONSET" != $2) { # check inter-SID distances:


Make the media and session attribute marker, a little bit more specific

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

--- scripts/long2html.awk
+++ scripts/long2html.awk
@@ -119,10 +119,10 @@
       if ($0 ~ "Connection Information") MARK = "media"
       # Use ... here.  Actually "(a)" should be used, but awk does not like the
       # parenthesis (), workaround it with the dots.
-      if ($0 ~ "Media Attribute ...:") MARK = "media"
+      if ($0 ~ "Media Attribute .a.:") MARK = "media"
       if ($0 ~ "Media Description, name and address") MARK = "media"
       if ($0 ~ "Owner/Creator, Session Id") MARK = "media"
-      if ($0 ~ "Session Attribute ...:") MARK = "media"
+      if ($0 ~ "Session Attribute .a.:") MARK = "media"
       if ($0 ~ "Session Description Protocol Version") MARK = "media"
       if ($0 ~ "Session Name") MARK = "media"
       if ($0 ~ "Time Description, active time") MARK = "media"


Changed some formatting of for and if, then, else statements

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

--- scripts/callflow.awk
+++ scripts/callflow.awk
@@ -114,40 +114,38 @@
   y = NR;
   y = y * yLineSpace + ystart;

-  if($0 ~ "^#")
-  {
+  if($0 ~ "^#") {
     output = "";
     split($0, A, " ")

-    for (i=2; i <= length(A); i++)
-    {
+    for (i=2; i <= length(A); i++) {
+
       if (A[i] == "!")
         break;
       output = output " " A[i];
     }

     link = "";
-    if (A[i] == "!")
-    {
+    if (A[i] == "!") {
+
       i++;
-      for(;i <= length(A); i++)
-      {
+      for(;i <= length(A); i++) {
         link = link " " A[i];
       }
     }

-    if (link != "")
-    {
+    if (link != "") {
+
       printf("<text x=\"%d\" y=\"%d\" class=\"link\">%s</text>\n", 50, y, output);
       printf("    <area href=\"%s\" coords=\"%d,%d,%d,%d\"/>\n", link, 50, y-yLineSpace+2, w, y+1) >> "imagemap";
-    }
-    else
-    {
+
+    } else {
+
       printf("<text x=\"%d\" y=\"%d\" class=\"comment-text\">%s</text>\n", 50, y, output);
     }
-  }
-  else
-  {
+
+  } else {
+
     if ($6 ~ "{([0-9]+)}") {
       str = $6
       gsub("{", "", str)
@@ -167,24 +165,22 @@

     l1 = sprintf("%s:%s", $4,$5);
     l2 = sprintf("%s:%s", $7,$8);
-    for (i=0; i<numHosts; i++)
-    {
-      if(l1 ~ hosts[i])
-      {
+    for (i=0; i<numHosts; i++) {
+
+      if(l1 ~ hosts[i]) {
         x1 = strtonum(lookup[hosts[i]]);
       }
-      if(l2 ~ hosts[i])
-      {
+
+      if(l2 ~ hosts[i]) {
         x2 = strtonum(lookup[hosts[i]]);
       }
     }

     x1 = x1 * xHostSpace + leftMargin;
     x2 = x2 * xHostSpace + leftMargin;
-    if ((x1==x2) && (noLocalLoop==1)){
+    if ((x1==x2) && (noLocalLoop==1)) {
       # Do nothing
-      }
-    else{
+    } else {
       # Print the line
       ORS = "";
       printf "<text x=\"%d\" y=\"%d\" class=\"pkt-text\">%d</text>\n", leftMargin/2, y, $3;


Translate: add getResponse() and play()

Translate: add getResponse() and play()

--- lib/Translate.awk
+++ lib/Translate.awk
@@ -3,6 +3,29 @@
 @include "lib/Commons"
 @include "lib/PLTokenizer"
 @include "lib/PLParser"
+
+# Send an HTTP request and get response from Google Translate.
+function getResponse(text, sl, tl, hl,    content, url) {
+    url = HttpProtocol HttpHost "/translate_a/t?client=t"       \
+        "&ie=UTF-8&oe=UTF-8"                                    \
+        "&text=" preprocess(text) "&sl=" sl "&tl=" tl "&hl=" hl
+
+    print "GET " url |& HttpService
+    while ((HttpService |& getline) > 0)
+        content = $0
+    close(HttpService)
+
+    return assert(content, "[ERROR] Null response.")
+}
+
+# Play using Google Text-to-Speech engine.
+function play(text, tl,    url) {
+    url = HttpProtocol HttpHost "/translate_tts?ie=UTF-8"       \
+        "&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")
+}

 # Get the translation of a string.
 function getTranslation(text, sl, tl, hl,


Make executable.

Make executable.


Update pp.awk

Update pp.awk

add copyright

--- core/sqf/src/seatrans/hbase-trx/pp.awk
+++ core/sqf/src/seatrans/hbase-trx/pp.awk
@@ -1,4 +1,25 @@
-#  The following example has been tested to work.
+#
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+##  The following example has been tested to work.
 #  If the file f1 contains the following, run this script
 #  as follows:
 #   awk -f pp.awk -v distro=HDP2.3 f1 > f2


avoid gnu extension, for installing

avoid gnu extension, for installing

git-svn-id: 88e1a00e4eab3b0bb0c09889526309a3e2f5bd8a@42 c26eb9a1-5813-0410-bd6c-c2e55f420ca7

--- mkstructinfo.awk
+++ mkstructinfo.awk
@@ -13,15 +13,15 @@
 		if (instruct in typedefs) {
 			instruct = typedefs[instruct];
 		}
-		elm = "";
+		sizeinfo = "";
 		elms = "";
 		for (i = 0; i in buffer; i ++) {
-			if (i) elm = elm " + ";
-			# elm = elm "sizeof(((`" instruct "'*)NULL)->`" buffer[i] "')";
-			# elms = elms " `" buffer[i] "'";
-			elm = elm "sizeof(((" instruct "*)NULL)->" buffer[i] ")";
+			if (i) {
+				sizeinfo = sizeinfo " + ";
+			}
+			sizeinfo = sizeinfo "sizeof(((" instruct "*)NULL)->" buffer[i] ")";

-			if (elms == "") {
+			if (i == 0) {
 				elms = buffer[i];
 			}
 			else {
@@ -30,7 +30,7 @@
 		}
 		printf "define(`ELEMENTSOF_%s', `%s')\n", instruct, elms;
 		printf "define(`COUNTOF_%s', `%s')\n", instruct, i;
-		printf "define(`SIZEOF_%s', `(  %s  )')\n", instruct, elm;
+		printf "define(`SIZEOF_%s', `(  %s  )')\n", instruct, sizeinfo;
 		print "\n";
 		for (i in buffer) {
 			delete buffer[i];
@@ -51,20 +51,48 @@
 {
 	if (brace == 1 && instruct) {
 		sub(/.*[{}]/, "");
-		gsub(/\[[^\]]+\]/, "");
-		gsub(/:[0-9]+/, "");
-		str = $0;
-		if (match(str, /\([ ]*\*([^)]+)\)/, a)) {
-			buffer[buffer_len] = a[1];
+		gsub(/\[[^\]]+\]/, ""); # ignore [...]
+		gsub(/:[0-9]+/, ""); # ignore struct bit
+		if (match($0, /^[^(]*\([ ]*\*([^)]+)\)/)) {
+			sub(/ +/, "")
+			sub(/^[^(]*\(\*/, "");
+			sub(/\).*/, "");
+			# function pointer
+			buffer[buffer_len] = $0;
 			buffer_len ++;
 		}
 		else {
-			while (gsub(/(\([^)]*\))/, "", str)) {
+			# ignore any ()s
+			while (gsub(/(\([^)]*\))/, "")) {
 			}
-			while (match(str, /([^*() ]+)[ ]*[,;](.*)/, a)) {
-				buffer[buffer_len] = a[1];
+			if (match($0, /[()]/)) {
+				next;
+			}
+			gsub(/[*]/, " ");
+			gsub(/ +/, " ");
+			gsub(/ *[,;]/, ";");
+			if (!match($0, /;/)) {
+				next;
+			}
+			split($0, chunks, ";");
+			# get var of "int *var, var;" etc
+			for (i in chunks) {
+				if (chunks[i] == "") {
+					delete chunks[i];
+					continue;
+				}
+				split(chunks[i], pieces, " ");
+
+				for (j in pieces) {
+					last_piece = pieces[j];
+					delete pieces[i];
+				}
+				if (last_piece == "") {
+					print "=====" chunks[i];
+				}
+				buffer[buffer_len] = last_piece;
 				buffer_len ++;
-				str = a[2];
+				delete chunks[i];
 			}
 		}
 		next;


#152 Ensure terraform-docs 0.12 multi-line default statement is parsed correctly (#155)

* #152 Ensure terraform-docs 0.12 multi-line default statement is parsed correctly

* Fix indentation

--- bin/terraform-docs.awk
+++ bin/terraform-docs.awk
@@ -4,42 +4,76 @@
 # https://github.com/segmentio/terraform-docs/issues/62

 {
-  if ( /\{/ ) {
-    braceCnt++
+  if ( /\{/ ) {
+    braceCnt++
   }

-  if ( /\}/ ) {
-    braceCnt--
+  if ( /\}/ ) {
+    braceCnt--
   }

+  # [START] variable or output block started
   if ($0 ~ /(variable|output) "(.*?)"/) {
+    # [CLOSE] "default" block
+    if (blockDefCnt > 0) {
+      blockDefCnt = 0
+    }
     blockCnt++
     print $0
   }

-  if ($1 == "description") {
-    print $0
+  # [START] multiline default statement started
+  if (blockCnt > 0) {
+    if ($1 == "default") {
+      print $0
+      if ($NF ~ /[\[\(\{]/) {
+        blockDefCnt++
+        blockDefStart=1
+      }
+    }
   }

-  if ($1 == "default") {
-    if (braceCnt > 1) {
-      print "  default = {}"
+  # [PRINT] single line "description"
+  if (blockDefCnt == 0) {
+    if ($1 == "description") {
+      # [CLOSE] "default" block
+      if (blockDefCnt > 0) {
+        blockDefCnt = 0
+      }
+      print $0
+    }
+  }
+
+  # [PRINT] single line "type"
+  if (blockCnt > 0) {
+    if ($1 == "type" ) {
+      # [CLOSE] "default" block
+      if (blockDefCnt > 0) {
+        blockDefCnt = 0
+      }
+      type=$3
+      if (type ~ "object") {
+        print "  type = \"object\""
+      } else {
+        print "  type = \"" $3 "\""
+      }
+    }
+  }
+
+  # [CLOSE] variable/output block
+  if (blockCnt > 0) {
+    if (braceCnt == 0 && blockCnt > 0) {
+      blockCnt--
+      print $0
+    }
+  }
+
+  # [PRINT] Multiline "default" statement
+  if (blockCnt > 0 && blockDefCnt > 0) {
+    if (blockDefStart == 1) {
+      blockDefStart = 0
     } else {
       print $0
     }
   }
-
-  if ($1 == "type" ) {
-    type=$3
-    if (type ~ "object") {
-      print "  type = \"object\""
-    } else {
-      print "  type = \"" $3 "\""
-    }
-  }
-
-  if (braceCnt == 0 && blockCnt > 0) {
-    blockCnt--
-    print $0
-  }
 }


Main: initialize screen width if not set

--- include/Main.awk
+++ include/Main.awk
@@ -28,7 +28,7 @@
     Option["show-original-dictionary"] = 0
     Option["show-dictionary"] = 1
     Option["show-alternatives"] = 1
-    Option["width"] = ENVIRON["COLUMNS"] ? ENVIRON["COLUMNS"] - 2 : 64
+    Option["width"] = ENVIRON["COLUMNS"] ? ENVIRON["COLUMNS"] - 2 : 0
     Option["indent"] = 4
     Option["no-ansi"] = 0
     Option["theme"] = "default"
@@ -91,9 +91,15 @@
 }

 # Miscellany initialization.
-function initMisc(    group) {
+function initMisc(    group, temp) {
     # (Translate.awk)
     initHttpService()
+
+    # Initialize screen width if not set
+    if (!Option["width"] && detectProgram("tput", "-V")) {
+        "tput cols" | getline temp
+        Option["width"] = temp ? temp - 2 : 64
+    }

     # Disable ANSI escape codes if required
     if (Option["no-ansi"])


TINKERPOP-1612 Reference GroovyTranslator with full package name

It is no longer part of wildcard imports.

--- docs/preprocessor/awk/init-code-blocks.awk
+++ docs/preprocessor/awk/init-code-blocks.awk
@@ -83,7 +83,7 @@
       print "    mapper = GraphSONMapper.build().version(GraphSONVersion.V2_0).create().createMapper()"
       print "    bytecode = mapper.readValue(jython.eval('GraphSONWriter().writeObject(j)').toString(), Bytecode.class)"
       print "    language = BytecodeHelper.getLambdaLanguage(bytecode).orElse('gremlin-groovy')"
-      print "    result = language.equals('gremlin-groovy') ? groovy.eval(GroovyTranslator.of(\"g\").translate(bytecode) + '.toList()').toString() : jython.eval(JythonTranslator.of(\"h\").translate(bytecode) + '.toList()').toString()"
+      print "    result = language.equals('gremlin-groovy') ? groovy.eval(org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator.of(\"g\").translate(bytecode) + '.toList()').toString() : jython.eval(JythonTranslator.of(\"h\").translate(bytecode) + '.toList()').toString()"
       print "    jython.getContext().getBindings(GLOBAL_SCOPE).put('json', mapper.writeValueAsString(result))"
       print "    return jython.eval('GraphSONReader().readObject(json)').toString()"
       print "  } else {"


interp_utils.awk	-- return "" if scale_type == log and v <= 0

--- lib/interp_utils.awk
+++ lib/interp_utils.awk
@@ -235,6 +235,9 @@
 		ev = IU_handle_exceptions(interp, v)
 		if(ev != "")
 			return ev
+	}else if(interp["scale_type"] == "log"){
+		if(v <= 0)
+			return ""
 	}

 	idx = IU_search(interp, v)


Do not use double underscores to escape underscores.

C and C++ reserve macro names containing adjacent underscores.

"Each name that contains a double underscore (__) or begins with an
 underscore followed by an uppercase letter (2.11) is reserved to
 the implementation for any use."
-- C++ 2003, 17.4.3.1.2 Global names [lib.global.names] (via StackOverflow)

--- awkgward/awkgward.awk
+++ awkgward/awkgward.awk
@@ -40,12 +40,12 @@

 function create_guard_macro(prefix, filename)
 {
-    double_underscore = toupper(filename);
-    # just in case, double single underscores
-    gsub(/_/, "__", double_underscore);
+    escaped_underscores = toupper(filename);
+    # Just in case, escape single underscores.
+    gsub(/_/, "_u_", escaped_underscores);
     # \/ = slash (/), \. = dot (.), \\ = backslash (\) - replace them with underscore.
-    gsub(/[\/\.\\]/, "_", double_underscore);
-    return prefix double_underscore;
+    gsub(/[\/\.\\]/, "_", escaped_underscores);
+    return prefix escaped_underscores;
 }

 function create_guard(prefix, filename)


fixed search_tests.awk identify the name of a test case between the first pair of parenthesis ( ... ) after the keyword BOOST_AUTO_TEST_CASE


Shell: rewrite initRlwrap()

Shell: rewrite initRlwrap()

--- include/Shell.awk
+++ include/Shell.awk
@@ -4,7 +4,7 @@

 # Detect external readline wrapper (rlwrap).
 function initRlwrap() {
-    Rlwrap = !system("rlwrap --version >/dev/null 2>/dev/null") ? "rlwrap" : ""
+    Rlwrap = ("rlwrap --version 2>/dev/null" | getline) ? "rlwrap" : ""
 }

 # Prompt for interactive session.


Wrap brlapi_brldefs.h with the correct #define. (dm)

--- Programs/brlapi_brldefs.awk
+++ Programs/brlapi_brldefs.awk
@@ -17,7 +17,7 @@
 ###############################################################################

 BEGIN {
-  writeHeaderPrologue("BRLAPI_INCLUDED_BRLDEFS", "api.h")
+  writeHeaderPrologue("BRLAPI_INCLUDED_BRLAPI_BRLDEFS", "api.h")
 }

 END {


query_json: handle string values correctly

It seems like a small oversight oversight did not populate variables
of type string into the returned array.

--- library.awk
+++ library.awk
@@ -753,6 +753,8 @@
             X[B[k]] = 1
         } else if (j == "false") {
             X[B[k]] = 0
+        } else if (j == "string") {
+            X[B[k]] = V[k]
         } else {
             # null will satisfy ismissing()
             X[B[k]]


Languages: add Dari language

Languages: add Dari language

--- include/Languages.awk
+++ include/Languages.awk
@@ -953,8 +953,9 @@
     Locale["ps"]["script"]             = "Arab"
     Locale["ps"]["rtl"]                = "true" # RTL language

-    #71 Persian (Western Farsi)
+    #71 Persian / Farsi (Western Farsi / Iranian Persian)
     Locale["fa"]["name"]               = "Persian"
+    Locale["fa"]["name2"]              = "Farsi"
     Locale["fa"]["endonym"]            = "فارسی"
     Locale["fa"]["translations-of"]    = "ترجمه‌های %s"
     Locale["fa"]["definitions-of"]     = "تعریف‌های %s"
@@ -1233,7 +1234,7 @@
     Locale["sv"]["glotto"]             = "swed1254"
     Locale["sv"]["script"]             = "Latn"

-    #91 Tajik / Tajiki, Cyrillic alphabet
+    #91 Tajik / Tajiki (Tajiki Persian), Cyrillic alphabet
     Locale["tg"]["name"]               = "Tajik"
     Locale["tg"]["name2"]              = "Tajiki"
     Locale["tg"]["endonym"]            = "Тоҷикӣ"
@@ -1480,6 +1481,16 @@
     Locale["yue"]["glotto"]            = "cant1236"
     Locale["yue"]["script"]            = "Hant"

+    #* Dari (Dari Persian)
+    Locale["prs"]["support"]           = "bing-only"
+    Locale["prs"]["name"]              = "Dari"
+    Locale["prs"]["endonym"]           = "دری"
+    Locale["prs"]["family"]            = "Indo-European"
+    Locale["prs"]["iso"]               = "prs"
+    Locale["prs"]["glotto"]            = "dari1249"
+    Locale["prs"]["script"]            = "Arab"
+    Locale["prs"]["rtl"]               = "true" # RTL language
+
     #* Fijian
     Locale["fj"]["support"]           = "bing-only"
     Locale["fj"]["name"]              = "Fijian"
@@ -1489,7 +1500,7 @@
     Locale["fj"]["glotto"]            = "fiji1243"
     Locale["fj"]["script"]            = "Latn"

-    #* Hmong Daw
+    #* Hmong Daw (White Hmong)
     Locale["mww"]["support"]           = "bing-only"
     Locale["mww"]["name"]              = "Hmong Daw"
     Locale["mww"]["endonym"]           = "Hmoob Daw"


- Add two checks for syntax errors - Improve error reporting - Remove redundant conditionals


checkFile now checks for Mondrian headers, bans /* ... */ comments (only checks in strict mode, and allows those comments if they start at column 0), and gives better messages if imports are in the wrong order.

--- bin/checkFile.awk
+++ bin/checkFile.awk
@@ -13,6 +13,8 @@
        || fname ~ "/fennel/" \
        || fname ~ "/extensions/" \
        || fname ~ "/com/sqlstream/" \
+       || fname ~ "/linq4j/" \
+       || fname ~ "/optiq/" \
        || strict > 0;
 }
 function _isCpp(fname) {
@@ -23,6 +25,9 @@
 }
 function _isMondrian(fname) {
     return fname ~ /mondrian/;
+}
+function _isOlap4j(fname) {
+    return fname ~ "/org/olap4j/";
 }
 function push(val) {
     switchStack[switchStackLen++] = val;
@@ -50,7 +55,6 @@
 function unmatchedOpenParens(s) {
     i = index(s, "(");
     if (i == 0) {
-    if (0)         print FNR, "unmatchedOpenParens=0";
         return 0;
     }
     openCount = 1;
@@ -61,12 +65,10 @@
         }
         if (c == ")") {
             if (--openCount == 0) {
-    if (0)         print FNR, "unmatchedOpenParens=0 (b)";
                 return 0;
             }
         }
     }
-    if (0) print FNR, "unmatchedOpenParens=1";
     return 1;
 }

@@ -102,6 +104,56 @@
     mondrian = _isMondrian(fname);
     prevImport = "";
     prevImportGroup = "";
+
+    delete headers;
+    headerCount = 0;
+    if ($0 ~ /Generated By:JavaCC/ \
+        || $0 ~ /This class is generated/) {
+        # generated; skip whole file
+        nextfile
+    } else if (fname ~ /XmlaOlap4jDriverVersion.java/ \
+        || fname ~ /package-info.java/ \
+        || fname ~ /MondrianOlap4jDriverVersion.java/ \
+        || fname ~ /MondrianTestRunner.java/ \
+        || fname ~ /MondrianResultPrinter.java/) {
+        # generated; does not contain standard header
+    } else if (mondrian) {
+        headers[headerCount++] = "/\\*$";
+        headers[headerCount++] = "// This software is subject to the terms of the Eclipse Public License v1.0$";
+        headers[headerCount++] = "// Agreement, available at the following URL:$";
+        headers[headerCount++] = "// http://www.eclipse.org/legal/epl-v10.html.$";
+        headers[headerCount++] = "// You must accept the terms of that agreement to use this software.$";
+        headers[headerCount++] = "//$";
+        headers[headerCount++] = "// Copyright (C) [0-9]*-[0-9]* Pentaho$";
+    } else if (1) {
+        headers[headerCount++] = "/\\*$";
+        if (_isOlap4j(fname)) {
+            headers[headerCount++] = /^\/\/ \$Id: /;
+            headers[headerCount++] = "//";
+        }
+        headers[headerCount++] = "// Licensed to Julian Hyde under one or more contributor license$";
+        headers[headerCount++] = "// agreements. See the NOTICE file distributed with this work for$";
+        headers[headerCount++] = "// additional information regarding copyright ownership.$";
+        headers[headerCount++] = "//$";
+        headers[headerCount++] = "// Julian Hyde licenses this file to you under the Apache License,$";
+        headers[headerCount++] = "// Version 2.0 \\(the \"License\"\\); you may not use this file except in$";
+        headers[headerCount++] = "// compliance with the License. You may obtain a copy of the License at:$";
+        headers[headerCount++] = "//$";
+        headers[headerCount++] = "// http://www.apache.org/licenses/LICENSE-2.0$";
+        headers[headerCount++] = "//$";
+        headers[headerCount++] = "// Unless required by applicable law or agreed to in writing, software$";
+        headers[headerCount++] = "// distributed under the License is distributed on an \"AS IS\" BASIS,$";
+        headers[headerCount++] = "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.$";
+        headers[headerCount++] = "// See the License for the specific language governing permissions and$";
+        headers[headerCount++] = "// limitations under the License.$";
+        headers[headerCount++] = "*/$";
+    }
+}
+FNR < headerCount {
+    if ($0 !~ headers[FNR - 1]) {
+        error(fname, FNR, "Does not match expected header line: " headers[FNR - 1] "\n");
+        headerCount = 0; # prevent further errors from this file
+    }
 }
 {
     if (previousLineEndedInCloseBrace > 0) {
@@ -136,6 +188,9 @@
         # beginning of multiline comment "/*"
         inComment = 1;
         gsub(/\/\*.*$/, "/* comment */", s);
+        if (strict > 1 && FNR > 1 && $0 !~ /\/\*\*/ && $0 !~ /^\/\*/) {
+            error(fname, FNR, "Multi-line c-style comment not allowed");
+        }
     } else {
         # mask out /* */ comments
         gsub(/\/\*.*\*\//, "/* comment */", s);
@@ -209,26 +264,36 @@
     thisImport = $2;
     gsub(/;/, "", thisImport);
     gsub(/\*/, "", thisImport);
-    if (thisPackage ~ /^mondrian.*/ && thisImport ~ /^mondrian.*/ \
-        || thisPackage ~ /^org.olap4j.*/ && thisImport ~ /^org.olap4j.*/)
-    {
-        importGroup = "a";
+    if (thisPackage ~ /^mondrian.*/ && thisImport ~ /^mondrian.*/) {
+        importGroup = "a:mondrian";
+    } else if (thisPackage ~ /^net.hydromatic.*/ && thisImport ~ /^net.hydromatic.*/) {
+        importGroup = "a:net.hydromatic";
+    } else if (thisPackage ~ /^org.olap4j.*/ && thisImport ~ /^org.olap4j.*/) {
+        importGroup = "a:org.olap4j";
     } else if (thisImport ~ /^static/) {
-        importGroup = "z";
+        importGroup = "z:static";
     } else if (thisImport ~ /^java.*/) {
-        importGroup = "y";
+        if (thisPackage ~ /^org.eigenbase.*/) {
+            importGroup = "aa:java";
+        } else {
+            importGroup = "y:java";
+        }
     } else if (thisImport ~ /^junit.*/) {
-        importGroup = "b";
+        importGroup = "b:junit";
     } else if (thisImport ~ /^mondrian.*/) {
-        importGroup = "bb";
+        importGroup = "bb:mondrian";
+    } else if (thisImport ~ /^org.olap4j.xmla.server.*/) {
+        importGroup = "bc:org.olap4j.xmla.server";
+    } else if (thisImport ~ /^openjava.*/) {
+        importGroup = "cc:openjava";
     } else if (thisImport ~ /^org.apache.*/) {
-        importGroup = "c";
+        importGroup = "c:org.apache";
     } else if (thisImport ~ /^org.eigenbase.*/) {
-        importGroup = "d";
+        importGroup = "d:org.eigenbase";
     } else if (thisImport ~ /^org.olap4j.*/) {
-        importGroup = "e";
-    } else {
-        importGroup = "f";
+        importGroup = "e:org.olap4j";
+    } else {
+        importGroup = "f:other";
     }
     if (importGroup != prevImportGroup \
         && prevImportGroup)
@@ -236,7 +301,8 @@
         if (!previousLineWasEmpty) {
             error(fname, FNR, "Expected blank line between import groups");
         } else if (prevImportGroup > importGroup) {
-            error(fname, FNR, "Import group out of sequence (should precede " prevImportGroup ")");
+            error(fname, FNR, "Import group out of sequence (should precede " \
+                substr(prevImportGroup, index(prevImportGroup, ":") + 1) ")");
         }
     } else if (prevImport \
         && prevImport > thisImport \


Translate: add m(string) and a few debugging messages

--- include/Translate.awk
+++ include/Translate.awk
@@ -46,6 +46,12 @@
         HttpService = "/inet/tcp/0/" HttpHost "/" HttpPort
         HttpPathPrefix = ""
     }
+}
+
+# Return a message for debugging.
+function m(string) {
+    if (Option["debug"])
+        return ansi("blue", string) RS
 }

 # Pre-process string (URL-encode before send).
@@ -250,6 +256,7 @@
         if (wShowOriginal) {
             # Display: original text
             if (r) r = r RS RS
+            r = r m("-- display original text")
             r = r ansi("negative", ansi("bold", s(join(original), il)))
             if (wShowOriginalPhonetics)
                 r = r RS showPhonetics(join(oPhonetics), il)
@@ -258,6 +265,7 @@
         if (wShowTranslation) {
             # Display: major translation & phonetics
             if (r) r = r RS RS
+            r = r m("-- display major translation & phonetics")
             r = r ansi("bold", s(translation, tl))
             if (wShowTranslationPhonetics)
                 r = r RS showPhonetics(join(phonetics), tl)
@@ -270,6 +278,7 @@
             if (hasWordClasses) {
                 # Definitions of
                 if (r) r = r RS
+                r = r m("-- display prompt message (Definitions of ...)")
                 if (isRTL(hl)) # home language is R-to-L
                     r = r s(showDefinitionsOf(hl, join(original)))
                 else # home language is L-to-R
@@ -277,6 +286,7 @@
             } else if (hasAltTranslations) {
                 # Translations of
                 if (r) r = r RS
+                r = r m("-- display prompt message (Translations of ...)")
                 if (isRTL(hl)) # home language is R-to-L
                     r = r s(showTranslationsOf(hl, join(original)))
                 else # home language is L-to-R
@@ -287,6 +297,7 @@
             # Display: source language -> target language
             if (hasWordClasses || hasAltTranslations) {
                 if (r) r = r RS
+                r = r m("-- display source language -> target language")
                 r = r s(sprintf("[ %s -> %s ]", getEndonym(il), getEndonym(tl)))
             }
         }
@@ -294,6 +305,7 @@
         if (wShowOriginalDictionary) {
             # Display: original dictionary
             if (r) r = r RS
+            r = r m("-- display original dictionary")
             if (isarray(oWordClasses) && anything(oWordClasses)) {
                 for (i = 0; i < length(oWordClasses); i++) {
                     r = (i > 0 ? r RS : r) RS s(oWordClasses[i], hl)
@@ -354,6 +366,7 @@
         if (wShowDictionary) {
             # Display: dictionary entries
             if (r) r = r RS
+            r = r m("-- display dictionary entries")
             for (i = 0; i < length(wordClasses); i++) {
                 r = (i > 0 ? r RS : r) RS s(wordClasses[i], hl)
                 for (j = 0; j < length(words[i]); j++) {
@@ -370,6 +383,7 @@
         if (wShowAlternatives) {
             # Display: alternative translations
             if (r) r = r RS RS
+            r = r m("-- display alternative translations")
             for (i = 0; i < length(altTranslations); i++) {
                 r = (i > 0 ? r RS : r) ansi("underline", show(segments[i]))
                 temp = isRTL(tl) ? altTranslations[i][0] : ansi("bold", altTranslations[i][0])


Translate: preprocessByDump()

Translate: preprocessByDump()

--- include/Translate.awk
+++ include/Translate.awk
@@ -86,6 +86,15 @@
     return quote(text)
 }

+# Pre-process string (using hexdump to URL-encode everything).
+function preprocessByDump(text,    arr, len, temp) {
+    len = dumpX(text, arr)
+    temp = ""
+    for (i = 1; i <= len; i++)
+        temp = temp "%" arr[i]
+    return temp
+}
+
 # [OBSOLETE] Is this function still relevant?
 # Post-process string (remove any redundant whitespace).
 function postprocess(text) {


Added sortkey field

Added sortkey field

--- getBBoxCatalogFrom-sitemap.awk
+++ getBBoxCatalogFrom-sitemap.awk
@@ -2,7 +2,7 @@

 BEGIN {
     # Print header
-    printf ("Content Type\tContent ID\tTitle\tEntity ID\tGenre\tRating\t")
+    printf ("Sortkey\tContent Type\tContent ID\tTitle\tEntity ID\tGenre\tRating\t")
     printf ("Show Type\tDuration\tDate Type\tOriginal Date\tShow ID\tSeason ID\t")
     printf ("Sn #\tEp #\tDescription\n")
 }
@@ -38,6 +38,7 @@
     # print "contentType = " contentType
     # print "contentId = " contentId
     # Make sure no fields will be carried over due to missing keys
+    sortkey = ""
     title = ""
     EntityId = ""
     genre = ""
@@ -166,8 +167,26 @@
         EntityId = "_23842"
         # print "EntityId = " EntityId
     }
-    printf ("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", contentType, contentId, \
-            title, EntityId, genre, rating, showType, duration, dateType, originalDate, \
+
+    if (contentType == "movie") {
+        sortkey = sprintf ("%s (1) %s M%s", title, originalDate, EntityId)
+    }
+
+    if (contentType == "tv_show") {
+        showTitle = title
+        sortkey = sprintf ("%s (1) %s S%s", title, originalDate, EntityId)
+    }
+
+    if (contentType == "tv_season") {
+        sortkey = sprintf ("%s (2) %s S%02d", showTitle, originalDate, seasonNumber)
+    }
+
+    if (contentType == "tv_episode") {
+        sortkey = sprintf ("%s (2) %s S%02dE%03d", showTitle, originalDate, seasonNumber, episodeNumber)
+    }
+
+    printf ("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", sortkey, contentType, \
+            contentId, title, EntityId, genre, rating, showType, duration, dateType, originalDate, \
             showContentId, seasonContentId, seasonNumber, episodeNumber, description)
 }


Changed RENDERER to _Renderer

Changed RENDERER to _Renderer

--- lib/config.awk
+++ lib/config.awk
@@ -10,7 +10,7 @@
   section = substr($0, (RSTART + 1), (RLENGTH - 2))

   # if we have encountered a new rule
-  if (section != "RENDERERS") {
+  if (section != "_Renderers") {
 	  if (section in rules) {
 		  print "Error Parsing config @ line", FNR ": encountered section", section, "multiple times"
 		exit -1
@@ -25,7 +25,7 @@
 /.*=.*/ {

 	# special exception for renderer: we use this to store converters
-	if (section == "RENDERERS") {
+	if (section == "_Renderers") {
 		renderers = renderers $0 "\n"
 	} else { 		# we are parsing a rule
 		rules[section] = rules[section] $0 "\n"


Exclude any target with "Test" in the name

--- targets.awk
+++ targets.awk
@@ -4,7 +4,7 @@

 /Targets:/ {
     while (getline && $0 != "") {
-        if ($0 ~ /Tests/) continue;
+        if ($0 ~ /Test/) continue;

         sub(/^ +/, "");
         print;


change compare and title heads

change compare and title heads

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

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -14,8 +14,11 @@
 } else if ((length($4) == 4 {
   end = substr($4,1,4)
 }
-if (end >= $3) incontract = 1
-else incontract = 0
+if (end >= $3) {
+  incontract = 1
+} else {
+  incontract = 0
+}

 if (incontract == 1) {
     nn = split($2,na,/\./)


Fix ' in Character names

Fix ' in Character names

--- getCast.awk
+++ getCast.awk
@@ -45,6 +45,7 @@
     if ($0 ~ /<span class="small-8 capitalize/) {
         split ($0,fld,"[<>]")
         char_name = fld[3]
+        gsub (/'/,"'",char_name)
         if (match (person_name, " and ") || match (person_name, " & ")) {
             pname = substr(person_name,1,RSTART-1)
             sub (/\.$/,"",pname)


class: recognize "2012, Mar 17" as a date


#1 Debian jessie, mawk v 1.3.3-17; Syntax error in awk file

--- get-tag.awk
+++ get-tag.awk
@@ -1,12 +1,12 @@
 #!/usr/bin/awk -f
 BEGIN {
   FS = "[ /^]+"
-  while ("git ls-remote " ARGV[1] "| sort -Vk2" | getline) {
+  while (("git ls-remote " ARGV[1] "| sort -Vk2") | getline) {
     if (!sha)
       sha = substr($0, 1, 7)
     tag = $3
   }
-  while ("curl -s " ARGV[1] "/releases/tag/" tag | getline)
+  while (("curl -s " ARGV[1] "/releases/tag/" tag) | getline)
     if ($3 ~ "commits")
       com = $2
   printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha


Whoops tabs

Whoops tabs

--- src/synthesize.template.awk
+++ src/synthesize.template.awk
@@ -8,79 +8,79 @@

     # @include-fragment util.awk config

-	# @start-fragment body
-	while (getline line) {
-		parseLine(line)
-	}
-	# @end-fragment body
+    # @start-fragment body
+    while (getline line) {
+        parseLine(line)
+    }
+    # @end-fragment body
 }

 # @start-fragment functions

 function parseLine(line) {
-	if (line ~ /@synthesize/) {
-		readSynthesizers(line, properties, aliases)
-	}
+    if (line ~ /@synthesize/) {
+        readSynthesizers(line, properties, aliases)
+    }
 }

 function readSynthesizers(line, properties, aliases) {
-	while (line ~ /@synthesize/ && !index(line, ";")) {
-		getline anotherLine
-		line = line anotherLine
-	}
+    while (line ~ /@synthesize/ && !index(line, ";")) {
+        getline anotherLine
+        line = line anotherLine
+    }

-	extractSynthesizers(line, properties, aliases)
-	getline line
-
-	if (line ~ /@synthesize/ || line ~ /^[ \t]*$/) {
-		readSynthesizers(line, properties, aliases)
-	} else {
-		formatSynthesizers(properties, aliases)
-		parseLine(line)
-	}
+    extractSynthesizers(line, properties, aliases)
+    getline line
+
+    if (line ~ /@synthesize/ || line ~ /^[ \t]*$/) {
+        readSynthesizers(line, properties, aliases)
+    } else {
+        formatSynthesizers(properties, aliases)
+        parseLine(line)
+    }
 }

 function extractSynthesizers(line, properties, aliases) {
-	gsub("@synthesize", "", line)
-	gsub(";", "", line)
-	gsub(/[ \t]*/, "", line)
-
-	split(line, individualProperties, ",")
-
-	for (i = 1; i <= length(individualProperties); i++) {
-		split(individualProperties[i], components, "=")
-
-		if (length(components[1]) > 0) { # avoid lines with only whitespace
-			j = length(properties) + 1
-			properties[j] = components[1]
+    gsub("@synthesize", "", line)
+    gsub(";", "", line)
+    gsub(/[ \t]*/, "", line)
+
+    split(line, individualProperties, ",")
+
+    for (i = 1; i <= length(individualProperties); i++) {
+        split(individualProperties[i], components, "=")
+
+        if (length(components[1]) > 0) { # avoid lines with only whitespace
+            j = length(properties) + 1
+            properties[j] = components[1]

-			if (length(components) > 1) {
-				aliases[j] = components[2]
-			} else {
-				aliases[j] = components[1]
-			}
-		}
-	}
+            if (length(components) > 1) {
+                aliases[j] = components[2]
+            } else {
+                aliases[j] = components[1]
+            }
+        }
+    }
 }

 function formatSynthesizers(properties, aliases) {
-	maxLength = 0
+    maxLength = 0

-	for (i = 1; i <= length(properties); i++) {
-		maxLength = max(maxLength, length(properties[i]));
-	}
-
-	for (i = 1; i <= length(properties); i++) {
-		format = ""
+    for (i = 1; i <= length(properties); i++) {
+        maxLength = max(maxLength, length(properties[i]));
+    }
+
+    for (i = 1; i <= length(properties); i++) {
+        format = ""

-		if (config["SYNTHESIZERS_SHOULD_HAVE_N_COLUMNS"] == 1) {
-			format = "@synthesize %s = %s;\n"
-		} else {
-			format = "@synthesize %-" maxLength "s = %s;\n"
-		}
+        if (config["SYNTHESIZERS_SHOULD_HAVE_N_COLUMNS"] == 1) {
+            format = "@synthesize %s = %s;\n"
+        } else {
+            format = "@synthesize %-" maxLength "s = %s;\n"
+        }

-		printf(format, properties[i], aliases[i])
-	}
+        printf(format, properties[i], aliases[i])
+    }
 }

 # @end-fragment functions


One additional must be commented out

One additional must be commented out

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

--- awk-scripts/callflow.awk
+++ awk-scripts/callflow.awk
@@ -74,8 +74,8 @@
   printf " .element-line { stroke-width: 0.25pt; stroke: black; }\n";
   printf " .link { color: blue; font-family: Trebuchet MS,Helvetica, sans-serif;\n";
   printf "		font-size: 9pt; text-decoration: underline; fill: blue;}\n";
-  #printf " .session-text { color: red; font-family: Trebuchet MS,Helvetica, sans-serif;\n";
-  printf "		font-size: 9pt; font-weight: bold; fill: red;}\n";
+  # printf " .session-text { color: red; font-family: Trebuchet MS,Helvetica, sans-serif;\n";
+  # printf "		font-size: 9pt; font-weight: bold; fill: red;}\n";
   printf " ]]></style>\n</defs>\n";
 }


parsegaspriceshtml.awk: Show name for "top tier" advertisers.

--- parsegaspriceshtml.awk
+++ parsegaspriceshtml.awk
@@ -36,7 +36,7 @@
    expectName=True
 }

-inGasPriceRecord && expectName && /<a href="/ {
+inGasPriceRecord && expectName && / <a href="/ {
    gsub("","Marathon")
    gsub("","Duchess (BP)")
    gsub("","Thorntons")


Work around va_list and CLongDouble issues on Linux and arm64

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


handle driver/driver tags

handle driver/driver tags

--- dev/isa/devlist2h.awk
+++ dev/isa/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.3 1997/12/21 14:41:21 downsj Exp $
+#	$OpenBSD: devlist2h.awk,v 1.4 1998/12/28 09:15:16 hugh Exp $
 #	$NetBSD: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -55,12 +55,17 @@
 		next
 	if (substr($2,0,1) == "#")
 		next
-	nproducts++
-	products[nproducts, 1] = $1;		# driver name
-	products[nproducts, 2] = $2;		# pnp id
-#	if ($3 && substr($3,0,1) == "#")
-#		products[nproducts, 3] = substr($3, 1);
-#	printf("%s %s %s\n", $1, $2, products[nproducts, 3]);
+	do {
+		nproducts++
+		if ((x = index($1, "/")))
+			products[nproducts, 1] = substr($1, 1, x - 1);
+		else
+			products[nproducts, 1] = $1;		# driver name
+		products[nproducts, 2] = $2;		# pnp id
+#		if ($3 && substr($3,0,1) == "#")
+#			products[nproducts, 3] = substr($3, 1);
+#		printf("%s %s %s\n", $1, $2, products[nproducts, 3]);
+	} while (x && ($1 = substr($1, x + 1, length($1) - x)));

 	next
 }


Main: allow non-option arguments to appear before options (fix #90)

--- include/Main.awk
+++ include/Main.awk
@@ -150,6 +150,7 @@

     # Command-line options override initialization script
     pos = 0
+    noargc = 0
     while (ARGV[++pos]) {
         ## Information options

@@ -569,7 +570,8 @@
             break # no more option from here
         }

-        break # no more option from here
+        # non-option argument
+        noargv[noargc++] = ARGV[pos]
     }

     # Handle interactive shell
@@ -616,22 +618,23 @@
     if (Option["interactive"])
         welcome()

-    if (pos < ARGC) {
-        # More parameters
-
-        # Translate remaining parameters
-        for (i = pos; i < ARGC; i++) {
+    # More remaining non-option arguments
+    if (pos < ARGC)
+        for (i = pos; i < ARGC; i++)
+            noargv[noargc++] = ARGV[i]
+
+    if (noargc) {
+        # Translate all non-option arguments
+        for (i = 0; i < noargc; i++) {
             # Verbose mode: separator between sources
             if (Option["verbose"] && i > pos)
                 p(prettify("source-seperator", replicate(Option["chr-source-seperator"], Option["width"])))

-            translate(ARGV[i], 1) # inline mode
+            translate(noargv[i], 1) # inline mode
         }

         # If input not specified, we're done
     } else {
-        # No more parameter besides options
-
         # If input not specified, use stdin
         if (!Option["input"]) Option["input"] = STDIN
     }


Commons: add anything()

Commons: add anything()

--- lib/Commons.awk
+++ lib/Commons.awk
@@ -3,6 +3,15 @@
 # Append an element into an array (zero-based).
 function append(array, element) {
     array[length(array)] = element
+}
+
+# Return 1 if the array contains anything; otherwise return 0.
+function anything(array,
+                  ####
+                  i) {
+    for (i in array)
+        if (array[i]) return 1
+    return 0
 }

 # Return an element if it belongs to the array;


Languages: mark Tatar as yandex-only

Languages: mark Tatar as yandex-only

--- include/Languages.awk
+++ include/Languages.awk
@@ -381,7 +381,7 @@
     Locale["tk"]["script"]             = "Latn"

     #? Tatar
-    Locale["tt"]["support"]            = "unstable"
+    Locale["tt"]["support"]            = "yandex-only"
     Locale["tt"]["name"]               = "Tatar"
     Locale["tt"]["endonym"]            = "татарча"
     #Locale["tt"]["translations-of"]


Languages: add Wolof language

Languages: add Wolof language

--- include/Languages.awk
+++ include/Languages.awk
@@ -393,6 +393,19 @@
     Locale["vo"]["iso"]                = "vol"
     #Locale["vo"]["glotto"]
     Locale["vo"]["script"]             = "Latn"
+
+    #? Wolof
+    Locale["wo"]["name"]               = "Wolof"
+    Locale["wo"]["endonym"]            = "Wollof"
+    #Locale["wo"]["translations-of"]
+    #Locale["wo"]["definitions-of"]
+    #Locale["wo"]["synonyms"]
+    #Locale["wo"]["examples"]
+    #Locale["wo"]["see-also"]
+    Locale["wo"]["family"]             = "Atlantic-Congo"
+    Locale["wo"]["iso"]                = "wol"
+    Locale["wo"]["glotto"]             = "wolo1247"
+    Locale["wo"]["script"]             = "Latn"

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


Don't check the state of the vnode interlock if the specification says
that the lock should not be checked.

Skip the lock assertion checks for *vpp or any other pointer to a vnode
pointer if vpp (or equivalent) is NULL.

--- sys/tools/vnode_if.awk
+++ sys/tools/vnode_if.awk
@@ -67,7 +67,10 @@
 {
 	if (arg == "vpp")
 		arg = "*vpp";
-	if (lockdata[name, arg, pos]) {
+	if (lockdata[name, arg, pos] && (lockdata[name, arg, pos] != "-")) {
+		if (arg ~ /^\*/) {
+			printh("\tif ("substr(arg, 2)" != NULL) {");
+		}
 		printh("\tASSERT_VI_UNLOCKED("arg", \""uname"\");");
 		# Add assertions for locking
 		if (lockdata[name, arg, pos] == "L")
@@ -76,6 +79,9 @@
 			printh("\tASSERT_VOP_UNLOCKED("arg", \""uname"\");");
 		else if (0) {
 			# XXX More checks!
+		}
+		if (arg ~ /^\*/) {
+			printh("\t}");
 		}
 	}
 }


Output a comment on top of each generated file explaining where it came from.


Regenerate tool/configure.awk

Regenerate tool/configure.awk

--- tool/configure.awk
+++ tool/configure.awk
@@ -23,3 +23,4 @@
 $1 == "--srcdir" { print $0,SRCDIR }
 $1 == "--sysconfdir" { print $0,SYSCONFDIR }
 $1 == "--sysdepdir" { print $0,SYSDEPDIR }
+$1 == "--xdgdatadir" { print $0,XDGDATADIR }


Sort the output tables, and mention the rcsid of the converter script in the output as well.

--- arch/hppa/gsc/makemap.awk
+++ arch/hppa/gsc/makemap.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: makemap.awk,v 1.4 2005/05/06 18:04:37 mickey Exp $
+#	$OpenBSD: makemap.awk,v 1.5 2005/05/09 05:07:25 miod Exp $
 #
 # Copyright (c) 2003, Miodrag Vallat.
 # All rights reserved.
@@ -33,6 +33,9 @@
 #

 BEGIN {
+	rcsid = "$OpenBSD: makemap.awk,v 1.5 2005/05/09 05:07:25 miod Exp $"
+	ifdepth = 0
+	ignore = 0
 	mapnum = 0
 	declk = 0

@@ -154,18 +157,52 @@
 NR == 1 {
 	VERSION = $0
 	gsub("\\$", "", VERSION)
+	gsub("\\$", "", rcsid)

 	printf("/*\t\$OpenBSD\$\t*/\n\n")
 	printf("/*\n")
-	printf(" * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n")
+	printf(" * THIS FILE IS AUTOMAGICALLY GENERATED.  DO NOT EDIT.\n")
 	printf(" *\n")
+	printf(" * generated by:\n")
+	printf(" *\t%s\n", rcsid)
 	printf(" * generated from:\n")
 	printf(" */\n")
 	print VERSION

 	next
 }
+
+#
+# A very limited #if ... #endif parser. We only want to correctly detect
+# ``#if 0'' constructs, so as not to process their contents. This is necessary
+# since our output is out-of-order from our input.
+#
+# Note that this does NOT handle ``#ifdef notyet'' correctly - please only use
+# ``#if 0'' constructs in the input.
+#
+
+/^#if/ {
+	ignores[ifdepth] = ignore
+	if ($2 == "0")
+		ignore = 1
+	else
+		ignore = 0
+	ifdepth++
+	if (ignore)
+		next
+}
+/^#endif/ {
+	oldignore = ignore
+	ifdepth--
+	ignore = ignores[ifdepth]
+	ignores[ifdepth] = 0
+	if (oldignore)
+		next
+}
+
 $1 == "#include" {
+	if (ignore)
+		next
 	if ($2 == "<dev/pckbc/wskbdmap_mfii.h>")
 		print "#include <hppa/gsc/gsckbdmap.h>"
 	else
@@ -174,9 +211,12 @@
 	next
 }
 $1 == "#define" || $1 == "#undef" {
+	if (ignore)
+		next
 	print $0
 	next
 }
+
 # Don't bother converting the DEC LK layout.
 /declk\[/ {
 	declk = 1
@@ -185,12 +225,19 @@
 /declk/ {
 	next
 }
+
 /pckbd/ {
+	if (ignore)
+		next
 	gsub("pckbd", "gsckbd", $0)
 	print $0
 	next
 }
+
 /KC/ {
+	if (ignore)
+		next
+
 	if (declk)
 		next

@@ -210,20 +257,46 @@
 		}
 		printf("\t*/\n")
 	} else {
-		printf("    KC(%d),", id)
+		lines[id] = sprintf("    KC(%d),", id)
+		#
+		# This makes sure that the non-comment part of the output
+		# ends up with a trailing comma. This is necessary since
+		# the last line of an input block might not have a trailing
+		# comma, but might not be the last line of an output block
+		# due to sorting.
+		#
+		comma = 0
 		for (f = 2; f <= NF; f++) {
-			printf("\t%s", $f)
+			if ($f == "/*")
+				comma++
+			if (comma == 0 &&
+			    substr($f, length($f)) != ",") {
+				lines[id] = sprintf("%s\t%s,", lines[id], $f)
+			} else {
+				lines[id] = sprintf("%s\t%s", lines[id], $f)
+			}
+			if ($f == "*/")
+				comma--
 		}
-		printf("\n")
 	}

 	next
 }
 /};/ {
+	if (ignore)
+		next
+
 	if (declk) {
 		declk = 0
 		next
 	}
+
+	for (i = 0; i < 256; i++)
+		if (lines[i]) {
+			print lines[i]
+			lines[i] = ""
+		}
+
 	if (mapnum == 0) {
 		# Add 241 to the US map...
 		print "    KC(241),\tKS_Delete"
@@ -271,6 +344,8 @@
 	printf("\tKBD_MAP(KB_US | KB_MACHDEP,\tKB_US,\tgsckbd_keydesc_precisionbook),\n");
 }
 {
+	if (ignore)
+		next
 	if (declk)
 		next
 	print $0


LanguageHelper: improve getDetails() for language isolates


Fix indentation.  Delete spaces between a functiuon name and '('.

--- CASED.awk
+++ CASED.awk
@@ -63,42 +63,48 @@
 }

 function single (str, bit) {
-i = decode_hex (str, 1);
-if (cased[i] != bit)
-     cased[i] += bit;
-     }
+  i = decode_hex(str, 1);
+  if (cased[i] != bit)
+    cased[i] += bit;
+}

 function range (str, bit) {
-end = decode_hex (str, index (str, "..") + 2);
-for (i = decode_hex (str, 1); i <= end; i++)
-     if (cased[i] != bit)
-     cased[i] += bit;
-     }
+  end = decode_hex(str, index (str, "..") + 2);
+  for (i = decode_hex(str, 1); i <= end; i++)
+    if (cased[i] != bit)
+      cased[i] += bit;
+}

 FILE == 1 && /^[^#]/ {
-		if ($3 ~ /L[ltu]/) single ($1, 1);
-		else if ($3 ~ /Mn|Me|Cf|Lm|Sk/) range ($1, 2);
-		}
+  if ($3 ~ /L[ltu]/)
+    single($1, 1);
+  else if ($3 ~ /Mn|Me|Cf|Lm|Sk/)
+    range($1, 2);
+}

 /^# PropList-.+\.txt/ {
-FILE = 2;
+  FILE = 2;
 }

 FILE == 2 && /^[^#;]+; *Other_(Upp|Low)ercase/ {
-if (index ($1, ".")) range ($1, 1);
-else single ($1, 1);
+  if (index ($1, "."))
+    range($1, 1);
+  else
+    single($1, 1);
 }

 /^# WordBreakProperty-.+\.txt/ {
-FILE = 3;
+  FILE = 3;
 }

 FILE == 3 && /^[^#;]+; *MidLetter/ {
-if (index ($1, ".")) range ($1, 2);
-else single ($1, 2);
+  if (index ($1, "."))
+    range($1, 2);
+  else
+    single($1, 2);
 }

 END {
-for (i in cased)
-     printf ("0x%X %d\n", i, cased[i]);
-     }
+  for (i in cased)
+    printf ("0x%X %d\n", i, cased[i]);
+}


Simplified the pre-processor's prettify script.

--- docs/preprocessor/awk/prettify.awk
+++ docs/preprocessor/awk/prettify.awk
@@ -21,14 +21,8 @@
 /^==>\/\/\/\/$/ { doPrint = 1 }

 {
-  lastLineStartedWithGremlin = lastLineStartedWithGremlin && inCodeSection
-  if (inCodeSection) {
-    if ($0 ~ /^gremlin> / && ($0 ~ /([.,({]|""")(\s*\/\/.*)?$/ || $0 ~ /^gremlin>  /)) {
-      if (lastLineStartedWithGremlin) gsub(/^gremlin> /, "         ")
-      lastLineStartedWithGremlin = 1
-    } else {
-      lastLineStartedWithGremlin = 0
-    }
+  if (inCodeSection && $0 ~ /^\.*[0-9]+> /) {
+    gsub(/^.{8}/, "        ")
   }
   if (doPrint) print
 }


sio nfo prefixes default

sio nfo prefixes default

--- bin/util/header2params2.awk
+++ bin/util/header2params2.awk
@@ -66,6 +66,8 @@
       print "@prefix bibo:          <http://purl.org/ontology/bibo/> ."
       print "@prefix prov:          <http://www.w3.org/ns/prov#> ."
       print "@prefix doap:          <http://usefulinc.com/ns/doap#> ."
+      print "@prefix nfo:           <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#> ."
+      print "@prefix sio:           <http://semanticscience.org/resource/> ."
       print "@prefix qb:            <http://purl.org/linked-data/cube#> ."
       print "@prefix dgtwc:         <http://data-gov.tw.rpi.edu/2009/data-gov-twc.rdf#> ."
    }


Main: manual RTL padding for konsole (#288)

--- include/Main.awk
+++ include/Main.awk
@@ -128,8 +128,14 @@
         delete AnsiCode

     # Disable conversion of bidirectional texts if required or supported by emulator
-    if (Option["no-bidi"] || BiDiTerm)
+    if (Option["no-bidi"] || BiDiTerm == "mlterm")
+        # mlterm implements its own padding
         BiDi = BiDiNoPad = NULLSTR
+    else if (BiDiTerm == "konsole") {
+        # konsole implements no padding; we should handle this
+        BiDiNoPad = NULLSTR
+        BiDi = "sed \"s/'/\\\\\\'/\" | xargs -0 printf '%%%ss'"
+    }

     # (Languages.awk)
     initLocaleDisplay()


Oups! Fix mistake in loop to read the next word

--- praxis/ordered-words.awk
+++ praxis/ordered-words.awk
@@ -10,8 +10,9 @@
         len = length(word)
         if (len < maxlen) next
         for (i = 1; i <= len - 1; ++i)
-                if (substr(word, i, 1) < substr(word, i + 1, 1))
-                        maxlen = length(max = word)
+                if (substr(word, i, 1) > substr(word, i + 1, 1))
+                        next
+        maxlen = length(max = word)
 }
 END {
         printf("Largest word '%s' is %d characters long\n", max, maxlen)


Our awk does not implement the ARGIND variable, so we were attempting to parse the binary .kld file as a list of symbols. Fix this by simply deleting the unwanted argument from the ARGV[] array instead of trying to skip over it.

--- sys/conf/kmod_syms.awk
+++ sys/conf/kmod_syms.awk
@@ -7,12 +7,11 @@
                         syms[$3] = $2
                 }
         }
+        delete ARGV[1]
 }

 # De-list symbols from the export list.
 {
-        if (ARGIND == 1)
-                nextfile
         delete syms[$0]
 }


Minor tweak

Minor tweak

--- make/log_to_changelog.awk
+++ make/log_to_changelog.awk
@@ -134,7 +134,7 @@
 			for(j=i-1; j>0 &&
 					   author==line_to_author[date_to_line[sorted_dates[j]]] &&
 					   message==line_to_message[date_to_line[sorted_dates[j]]] &&
-					   date - sorted_dates[j] < 100; j--)
+					   date - sorted_dates[j] < 1000; j--)
 			{
 				#Reset i, so that the fragment appears once only.
 				i=j


add copyright

add copyright

--- tools/slidy.awk
+++ tools/slidy.awk
@@ -34,7 +34,7 @@
 {
     sub(/<title>Haskell: Functional Programming, Solid Code, Big Data<\/title>/, "<title>Intro \\“Functional Programming\\”</title>")
     sub(/<meta name="date" content="2011-09-18" \/>/, "<meta name='date' content='2011-10-19' />")
-    sub(/<meta name="author" content="Bryan O'Sullivan" \/>/, "<meta name='author' content='Gabor Greif' />\n  <meta name='duration' content='45' />\n  <link type='text/css' rel='stylesheet' href='http://www.gstatic.com/codesite/ph/13841197563397998716/css/ph_detail.css' />")
+    sub(/<meta name="author" content="Bryan O'Sullivan" \/>/, "<meta name='author' content='Gabor Greif' />\n  <meta name='duration' content='45' />\n  <link type='text/css' rel='stylesheet' href='http://www.gstatic.com/codesite/ph/13841197563397998716/css/ph_detail.css' />\n  <meta name='copyright' content='Copyright \\© 2011 Gabor Greif' />")
 }

 /^<body>/ {


build.awk: use sha256sum in Homebrew formula

--- build.awk
+++ build.awk
@@ -251,11 +251,12 @@

     d("Updating gh-pages/translate-shell.rb ...")
     # Update gh-pages/translate-shell.rb
-    ("sha1sum " PagesPath "translate-shell.tar.gz") | getline temp
+    system("git archive --format=tar.gz --prefix=translate-shell-"Version"/ v"Version" >"PagesPath"/v"Version".tar.gz")
+    ("sha256sum " PagesPath"/v"Version".tar.gz") | getline temp
     split(temp, group)
-    sha1 = group[1]
+    sha256 = group[1]
     text = readFrom(HomebrewFormula ".temp")
-    gsub(/\$sha1\$/, sha1, text)
+    gsub(/\$sha256\$/, sha256, text)
     gsub(/\$Version\$/, Version, text)
     writeTo(text, HomebrewFormula)


Accept variable 'format' from -v parameter.

--- gfwlist2dnsmasq.awk
+++ gfwlist2dnsmasq.awk
@@ -3,6 +3,7 @@
 BEGIN {
 	host = host != "" ? host : "127.0.0.1"
 	port = port != "" ? port : 5353
+	format = format != "" ? format : "server=/.%s/%s#%d\n"

 	"date \"+%Y-%m-%d %H:%M:%S\"" | getline now
 	print "# gfw list ipset rules for dnsmasq"
@@ -32,7 +33,7 @@

 END {
 	for (i = 1; i <= domain_count; i++) {
-		printf "server=/.%s/%s#%d\n", domains[i], host, port | "sort | uniq"
+		printf format, domains[i], host, port | "sort | uniq"
 	}
 	close("sort | uniq")
 }


sanitize.awk: slightly better regex

sanitize.awk: slightly better regex


Commons: squeeze more

Commons: squeeze more

--- include/Commons.awk
+++ include/Commons.awk
@@ -136,7 +136,7 @@
     if (!preserveIndent)
         gsub(/^[[:space:]]+/, "", line)
     # Remove comment
-    gsub(/^#.*$/, "", line)
+    gsub(/^[[:space:]]*#.*$/, "", line)
     # Remove in-line comment
     gsub(/#[^"]*$/, "", line)
     # Remove trailing spaces


It seems SCO puts touch in a wierd place

--- extra/scripts/initfini.awk
+++ extra/scripts/initfini.awk
@@ -8,7 +8,7 @@
 { alignval="";
   endp=0;
   end=0;
-  system("/bin/touch crt[in].S");
+  system("touch crt[in].S");
   system("/bin/rm -f crt[in].S");
   omitcrti=0;
   omitcrtn=0;


force to use UTF-8 locale

force to use UTF-8 locale

--- build.awk
+++ build.awk
@@ -132,6 +132,8 @@

         print "#!/usr/bin/env " target > Trans
         print > Trans
+
+        print "if ! [[ $LANG =~ '[UTF|utf]-?8$' ]]; then export LANG=en_US.UTF-8; fi" > Trans

         print "read -r -d '' TRANS_PROGRAM << 'EOF'" > Trans
         if (fileExists(EntryPoint))


pushing

pushing

--- auk/sdtree.auk
+++ auk/sdtree.auk
@@ -43,6 +43,7 @@
   n = musort(ranges,sorted)
   return sorted[n].column
 }
+
 function report(rows,   w,n,r,txt) {
   for(w in W) {
     num(n)


add step in awk script to convert config to win32 to remote remove standard universe starter from the windows config file.

--- src/condor_examples/convert_config_to_win32.awk
+++ src/condor_examples/convert_config_to_win32.awk
@@ -81,6 +81,16 @@
     next
 }

+# Remove STARTER_STANDARD (the standard universe starter)
+#
+/^STARTER_STANDARD/ {
+    next
+}
+/^STARTER_LIST/ {
+    printf "STARTER_LIST = STARTER\n"
+    next
+}
+
 # Choose a Windows-reasonable value for RELEASE_DIR and LOCAL_DIR
 #
 /^RELEASE_DIR[ \t]*=/ {
@@ -94,10 +104,10 @@

 # Don't require a local config file.
 #
-/^\#REQUIRE_LOCAL_CONFIG_FILE \=/ {
-   printf "REQUIRE_LOCAL_CONFIG_FILE = FALSE\n"
-   next
-}
+/^\#REQUIRE_LOCAL_CONFIG_FILE \=/ {
+   printf "REQUIRE_LOCAL_CONFIG_FILE = FALSE\n"
+   next
+}

 # Specify $(FULL_HOSTNAME) as the sample commented-out entry for
@@ -213,4 +223,3 @@

 # If we made it here, print out the line unchanged
 {print $0}
-


Try to optimize for grabbing header file, incompleted

--- linkparser/linkparser.awk
+++ linkparser/linkparser.awk
@@ -53,10 +53,6 @@
 		inst_root = g_sroot"-"date
 	}

-	# ---------
-	# Sources
-	# ---------
-
 	cmd_file = link".cmd"
 	while ((getline line < cmd_file) > 0) {
 		# abosolute path
@@ -65,42 +61,71 @@
 		else # relative path
 			source = gensub(/^cd (.+);.+-c (.+)/, "\\1/\\2", "g", line)

-		rel_install(source, g_sroot, inst_root)
-	}
+		gsub(/esam\/objects\/([^\/]+\/){2,}sources\/src/, "dsl/sw/flat", source)
+		sources[source]++
+		#rel_install(source, g_sroot, inst_root)
+
+		split(line, a, " ")
+		prefix = gensub(/^cd (.+);.+/, "\\1", "g", line)
+		for (i in a) {
+			if (a[i] ~ /^-I/) {
+				gsub(/^-I/, "", a[i])
+				gsub(/esam\/objects\/([^\/]+\/)\{2,}sources\/src/, "dsl/sw/flat", a[i])
+				if (a[i] ~ /^\//)
+					includes[a[i]]++
+				else
+					includes[prefix "/" a[i]]++
+			}
+		}
+	}
+
 	close(cmd_file)

 	# ---------
 	# Headers
 	# ---------

-	gsub(/\.(obj|o|lib)$/, "", link)
-	dep_file = link ".D"
-
-	if ((getline < dep_file) < 0)
-		next
-
-	# Get path prefix
-	cur_path = $1
-	gsub(/^#/, "", cur_path)
-
-	while ((getline < dep_file) > 0) {
-		gsub(/:/, " ")
-		for (i = 1; i <= NF; i++) {
-			if ($i !~ /\.(h|hpp)$/)
-				continue
-			header = cur_path "/" $i
-			rel_install(header, g_sroot, inst_root)
-		}
-	}
-	close(dep_file)
+#	gsub(/\.(obj|o|lib)$/, "", link)
+#	dep_file = link ".D"
+#
+#	if ((getline < dep_file) < 0)
+#		next
+#
+#	# Get path prefix
+#	cur_path = $1
+#	gsub(/^#/, "", cur_path)
+#
+#	while ((getline < dep_file) > 0) {
+#		gsub(/:/, " ")
+#		for (i = 1; i <= NF; i++) {
+#			if ($i !~ /\.(h|hpp)$/)
+#				continue
+#			header = cur_path "/" $i
+#			rel_install(header, g_sroot, inst_root)
+#		}
+#	}
+#	close(dep_file)
 }

 END {
 	if (SKIP_END)
 		exit 0
 	print "Total dumped files: " count
+
+	for (i in sources)
+		rel_install(i, g_sroot, inst_root)
+
+	for (i in includes) {
+
+		#rel_install(i, g_sroot, inst_root)
+	}
+
 	if (arg ~ /tar/)
 		make_tarball(arg)
+}
+
+function get_include(line) {
+	inc = gensub(/^(-[^I]+|[^-]+) -I(.+)/, "\\2", "g")
 }

 function rel_install(source, rel_root, new_root) {
@@ -121,7 +146,7 @@
 	}

 	system("mkdir -p " new_root "/" rel_path)
-	system("cp -L " source " " new_root "/" rel_path)
+	system("cp -Lr " source " " new_root "/" rel_path)
 }

 function make_tarball(flag) {


Add license

Add license

--- script/key_elems.awk
+++ script/key_elems.awk
@@ -1,4 +1,28 @@
 #! /bin/awk -f
+
+# Copyright (c) 2012, Dennis Hedback
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#   * Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.

 BEGIN {
     key_elems_len = 0;


msg/msg_parser.awk: fixed whitespace

msg/msg_parser.awk: fixed whitespace

darcs-hash:20081127232458-db55f-76adf5524d9c263fa37a9f8b2ecdc4a9284afb2f.gz

--- libsofia-sip-ua/msg/msg_parser.awk
+++ libsofia-sip-ua/msg/msg_parser.awk
@@ -49,7 +49,7 @@
   # Initialize these as arrays
   split("", symbols);
   split("", names);
-  split("", comments);
+  split("", comments);
   split("", hashes);
   split("", NAMES);
   split("", Comments);
@@ -81,7 +81,7 @@
 {
   hash = 0;

-  len = length(name);
+  len = length(name);

   for (i = 1; i <= len; i++) {
     c = tolower(substr(name, i, 1));
@@ -112,7 +112,7 @@
 function protos (name, comment, hash, since)
 {
   NAME=toupper(name);
-  sub(/.*[\/][*][*][<][ 	]*/, "", comment);
+  sub(/.*[\/][*][*][<][ 	]*/, "", comment);
   sub(/[ 	]*[*][\/].*/, "", comment);
   sub(/[ 	]+/, " ", comment);

@@ -132,12 +132,12 @@
     if (name2 != name && name2 != tprefix "_" name) {
       print name " mismatch with " comment " (" real ")" > "/dev/stderr";
     }
-
+
     hash = name_hash(parts[1]);

     hashed[name] = hash;

-    if (comment !~ /header/) {
+    if (comment !~ /header/) {
       comment = comment " header";
     }
   }
@@ -149,13 +149,13 @@
   COMMENT = toupper(comment);

   # Store the various forms into an array for the footer processing
-  N++;
-  hashes[N] = hash;
+  N++;
+  hashes[N] = hash;
   names[N] = name;
-  NAMES[N] = NAME;
-  comments[N] = comment;
-  Comments[N] = comment;
-  COMMENTS[N] = COMMENT;
+  NAMES[N] = NAME;
+  comments[N] = comment;
+  Comments[N] = comment;
+  COMMENTS[N] = COMMENT;

   symbols[name] = comment;
   if (since) {
@@ -165,8 +165,8 @@
   expr = (without_experimental > 0 && do_hash);
   if (expr) {
     printf "%s is experimental\n", Comment;
-  }
-
+  }
+
   experimental[N] = expr;

   if (PR) {
@@ -190,7 +190,7 @@
   #
   if (p) {
     gsub(/#hash#/, hash, p);
-    gsub(/#xxxxxx#/, name, p);
+    gsub(/#xxxxxx#/, name, p);
     gsub(/#XXXXXX#/, NAME, p);
     gsub(/#xxxxxxx_xxxxxxx#/, comment, p);
     gsub(/#Xxxxxxx_Xxxxxxx#/, Comment, p);
@@ -203,17 +203,17 @@
       # Remove line with #version#
       gsub(/\n[^#\n]*#version#[^\n]*/, "", p);
     }
-
+
     print p > PR;
   }
 }

-#
+#
 # Repeat each line in the footer containing the magic replacement
 # pattern with an instance of all headers
 #
 function process_footer (text)
-{
+{
   if (!match(tolower(text), /#(xxxxxx(x_xxxxxxx)?|hash)#/)) {
     n = length(text);
     while (substr(text, n) == "\n") {
@@ -224,7 +224,7 @@
       print text > PR;
     return;
   }
-
+
   n = split(text, lines, RS);

   for (i = 1; i <= n; i++) {
@@ -247,7 +247,7 @@
 	gsub(/#xxxxxxx_xxxxxxx#/, comments[j], l);
 	gsub(/#Xxxxxxx_Xxxxxxx#/, Comments[j], l);
 	gsub(/#XXXXXXX_XXXXXXX#/, COMMENTS[j], l);
-	gsub(/#xxxxxx#/, names[j], l);
+	gsub(/#xxxxxx#/, names[j], l);
 	gsub(/#XXXXXX#/, NAMES[j], l);
 	print l > PR;
       }
@@ -272,7 +272,7 @@
     if (line ~ /^#/ || line ~ /^$/)
       continue;

-    split(line, tokens,  /[ \t]*=[ \t]*/);
+    split(line, tokens,  /[ \t]*=[ \t]*/);
     name = tolower(tokens[1]);
     gsub(/-/, "_", name);
     gsub(/,/, " ", name);
@@ -297,7 +297,7 @@
 function templates ()
 {
   if (!auto) {
-    auto = FILENAME;
+    auto = FILENAME;

     if (!prefix) { prefix = module; }
     if (!tprefix) { tprefix = prefix; }
@@ -369,11 +369,11 @@

 /^#### EXTRA HEADER LIST STARTS HERE ####$/ { HLIST=1; templates(); }
 HLIST && /^#### DEFAULT HEADER LIST ENDS HERE ####$/ { basic=total; }
-HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ {
+HLIST && /^#### EXPERIMENTAL HEADER LIST STARTS HERE ####$/ {
   without_experimental = total; }

-HLIST && /^[a-z]/ { protos($1, $0, 0, $2);
-  headers[total++] = $1;
+HLIST && /^[a-z]/ { protos($1, $0, 0, $2);
+  headers[total++] = $1;
   Extra[$1] = extra++;
 }
 /^#### EXTRA HEADER LIST ENDS HERE ####$/ { HLIST=0;  }
@@ -383,14 +383,14 @@

 PT && /^ *\/\* === Hash headers end here \*\// { in_header_list=0;}

-in_header_list && /^  (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ {
+in_header_list && /^  (sip|rtsp|http|msg|mp)_[a-z_0-9]+_t/ {
   n=$0
-  sub(/;.*$/, "", n);
+  sub(/;.*$/, "", n);
   sub(/^ *(sip|rtsp|http|msg|mp)_[a-z0-9_]*_t[ 	]*/, "", n);
   sub(/^[*](sip|rtsp|http|msg|mp)_/, "", n);

   if ($0 !~ /[\/][*][*][<]/) {
-    getline;
+    getline;
   }
   if ($0 !~ /[\/][*][*][<]/) {
     printf "msg_protos.awk: header %s is malformed\n", n;
@@ -446,7 +446,7 @@
     len = split("request status separator payload unknown error", unnamed, " ");

     for (i = 1; i <= len; i++) {
-      printf("  {{ %s_%s_class, msg_offsetof(%s_t, %s_%s) }},\n",
+      printf("  {{ %s_%s_class, msg_offsetof(%s_t, %s_%s) }},\n",
 	     tprefix, unnamed[i], module, prefix, unnamed[i]) > PT;
     }
     if (multipart) {
@@ -456,7 +456,7 @@
       printf("  {{ NULL, 0 }},\n") > PT;
     }
     if (MC_SHORT_SIZE) {
-      printf("  %s_short_forms, \n", module) > PT;
+      printf("  %s_short_forms, \n", module) > PT;
     }
     else {
       printf("  NULL, \n") > PT;
@@ -488,11 +488,11 @@

 	if (i >= ordinary) {
 	  printf("    { %s_%s_class,\n" \
-		 "      msg_offsetof(struct %s, extra[%u])%s }%s\n",
+		 "      msg_offsetof(struct %s, extra[%u])%s }%s\n",
 		 tprefix, n, struct, Extra[n], flags, c) > PT;
 	}
 	else {
-	  printf("    { %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
+	  printf("    { %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
 		 tprefix, n, module, prefix, n, flags, c) > PT;
 	}

@@ -520,7 +520,7 @@
     if (multipart)
       protos("multipart", "/**< Multipart payload */", -7);
   }
-
+
   if (PR) {
     process_footer(footer);
   }
@@ -548,17 +548,17 @@

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

       for (i = 1; i <= MC_SHORT_SIZE; i = i + 1) {
 	c = (i == MC_SHORT_SIZE) ? "" : ",";
 	if (i in shorts) {
 	  n = shorts[i];
         flags = header_flags[n]; if (flags) flags = ",\n      " flags;
-
-	printf("  { /* %s */ %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
-	       substr(lower_case, i, 1),
+
+	printf("  { /* %s */ %s_%s_class, msg_offsetof(%s_t, %s_%s)%s }%s\n",
+	       substr(lower_case, i, 1),
 	       tprefix, n, module, prefix, n, flags, c)	\
 	    > PT;
 	}
@@ -567,7 +567,7 @@
 	    > PT;
 	}
       }
-      printf("};\n\n") > PT;
+      printf("};\n\n") > PT;
     }

     # printf("extern msg_hclass_t msg_multipart_class[];\n\n") > PT;


Function-local variable.

Function-local variable.

--- src/cloudfront.awk
+++ src/cloudfront.awk
@@ -16,7 +16,7 @@
   return x
 }

-function urlDecode(url) {
+function urlDecode(url, i) {
     for (i = 0x20; i < 0x40; ++i) {
         repl = sprintf("%c", i);
         if ((repl == "&") || (repl == "\\")) {


-Packet text back to black color (not colored with session color)

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

--- awk-scripts/callflow.awk
+++ awk-scripts/callflow.awk
@@ -192,7 +192,7 @@
     x2 = x2 * xHostSpace + leftMargin;

     ORS = "";
-    printf "<text x=\"%d\" y=\"%d\" class=\"pkt-text\" style=\"fill: %s;\">%d</text>\n", leftMargin/2, y, color[c], $1;
+    printf "<text x=\"%d\" y=\"%d\" class=\"pkt-text\">%d</text>\n", leftMargin/2, y, $1;

     output = "";
     for(i=7;i<=NF;i++) output = output " " $i;


added name_template to bundle template

added name_template to bundle template

--- bin/util/header2params2.awk
+++ bin/util/header2params2.awk
@@ -119,6 +119,7 @@
                                     printf("#:a_bundle\n");
                                     printf("#   a conversion:ImplicitBundle;\n");
                                     printf("#   conversion:property_name \"a_property\"; # Can also be a URI, e.g. dcterms:title.\n");
+                                    printf("#   conversion:name_template \"[/sd]company/[#2]/[r]\";\n");
                                     printf("#   #conversion:type_name     \"My Class\";   # Can also be a URI, e.g. foaf:Person.\n");
                                     printf("#.\n");
    }


Fix extra header line inserted by MHz

Fix extra header line inserted by MHz

--- getMHzFrom-seriesPages.awk
+++ getMHzFrom-seriesPages.awk
@@ -65,35 +65,37 @@
             # uppercase the first character of any second word
             if (match (fld[i],/ /) > 0)
                 fld[i] = substr(fld[i],1,RSTART) toupper(substr(fld[i],RSTART+1,1)) \
-                   (substr(fld[i],RSTART+2))
+                (substr(fld[i],RSTART+2))
         }
         # print the finalized header
-        print fld[1] "\t" fld[2] "\t" fld[(numFields-1)] "\t" fld[(numFields)] >> HEADER_FILE
-        headerPrinted = "yes"
+        if (numFields > 3 ) {
+            print fld[1] "\t" fld[2] "\t" fld[(numFields-1)] "\t" fld[(numFields)] >> HEADER_FILE
+            headerPrinted = "yes"
+        }
     } else {
-        # We found a description, clean it up and print it
-        gsub (/  */," ")
-        gsub (/'/,"'")
-        gsub (/"/,"\"")
-        gsub (/&/,"\\&")
-        gsub (/‘/,"’")
-        gsub (/’/,"’")
-        gsub (/“/,"“")
-        gsub (/”/,"”")
-        gsub (/\r/," ")
-        # if it's not the last line of the description, print it without a newline
-        if ($0 !~ /"\>/) {
-            printf ("%s", $0) >> DESCRIPTION_FILE
-        } else {
-            # if it's the last line of the description, print it with a newline
-            sub (/"\>/,"")
-            print $0 >> DESCRIPTION_FILE
-            # if we didn't find a header in this block, print a blank one
-            if (headerPrinted == "no") {
-                print "==> No genre/country line: " seriesTitle >> ERROR_FILE
-                print "\t\t\t" >> HEADER_FILE
-            }
-        }
+    # We found a description, clean it up and print it
+    gsub (/  */," ")
+    gsub (/'/,"'")
+    gsub (/"/,"\"")
+    gsub (/&/,"\\&")
+    gsub (/‘/,"’")
+    gsub (/’/,"’")
+    gsub (/“/,"“")
+    gsub (/”/,"”")
+    gsub (/\r/," ")
+    # if it's not the last line of the description, print it without a newline
+    if ($0 !~ /"\>/) {
+        printf ("%s", $0) >> DESCRIPTION_FILE
+    } else {
+    # if it's the last line of the description, print it with a newline
+    sub (/"\>/,"")
+    print $0 >> DESCRIPTION_FILE
+    # if we didn't find a header in this block, print a blank one
+    if (headerPrinted == "no") {
+        print "==> No genre/country line: " seriesTitle >> ERROR_FILE
+        print "\t\t\t" >> HEADER_FILE
+    }
+}
     }
 }


-discontinuity mode

-discontinuity mode

--- packager/bin/anal_nginx_log_packager.awk
+++ packager/bin/anal_nginx_log_packager.awk
@@ -39,11 +39,17 @@
     if(verbose){
         print $2 " "lastChunkPath;
     }
-    if(lastChunk && lastChunk+1 != b[2]){
-        print $2" "lastChunkPath" error: expected chunk "lastChunk+1" got: "b[2]
+
+    if(length(b) == 6){
+        lastChunkId = b[4]
+    } else {
+        lastChunkId =  b[2]
+    }
+    if(lastChunk && lastChunk+1 != lastChunkId){
+        print $2" "lastChunkPath" error: expected chunk "lastChunk+1" got: "lastChunkId
         delete __lastDTS[0]
     }
-    lastChunk=b[2];
+    lastChunk=lastChunkId;
     split($2,a,":");
     time=a[3]+a[2]*60+a[1]*3600;
     if(lastTime){
@@ -76,6 +82,29 @@
      __lastDTS[0] = $11
 }

+$0 ~ /media_set_parse_json: produced segment/ {
+    tmp1 = $9
+    tmp2=$11
+    tmp3=$13
+    if(segment_index){
+        if(segment_index == tmp1 - 1){
+            if(segment_start_time+segment_duration != tmp2){
+                printf (" chunk %d adjucent chunks  differ: diff: %d prev={ %d  %d}  cur={%d %d}",tmp1,
+                (tmp2-segment_start_time+segment_duration),
+                segment_start_time,
+                segment_duration,
+                tmp2,
+                tmp3)
+            }
+        } else {
+            print "segment discontinuity: cur: "tmp1" prev: "segment_index
+        }
+    }
+    segment_index = tmp1
+    segment_start_time=tmp2
+    segment_duration=tmp3
+}
+
 END {
     printStats("chunkInterval")
     printStats("chunkDuration")


LanguageData: remove Emoji

LanguageData: remove Emoji

--- include/LanguageData.awk
+++ include/LanguageData.awk
@@ -2276,11 +2276,6 @@
     Locale["chr"]["glotto"]            = "cher1273"
     Locale["chr"]["script"]            = "Cher"

-    #? Emoji
-    Locale["emj"]["status"]            = "non-language"
-    Locale["emj"]["support"]           = "yandex-only"
-    Locale["emj"]["name"]              = "Emoji"
-    Locale["emj"]["endonym"]           = "Emoji"
 }

 # Initialize aliases of all locales supported.


generalized date generation. Untested

generalized date generation. Untested

--- tsv2vcal.awk
+++ tsv2vcal.awk
@@ -1,6 +1,15 @@
 #!/usr/bin/awk -f

+
+
 BEGIN {
+if(!TODAY) {
+   TODAY="2015-02-26-11:30:10"
+}
+split(TODAY, t, /[-:]/)
+if(!YEAR) {
+   YEAR=t[1]
+}
 FS="\t"
 print "BEGIN:VCALENDAR\nVERSION:2.0\nMETHOD:PUBLISH"
 }
@@ -12,9 +21,9 @@
 {
 split($1,a,/[-.]/)
 print "BEGIN:VEVENT"
-print "DTSTAMP:" datestamp(2015,02,26,11,30,10) "Z"
-print "DTSTART:" datestamp(2015,m,d,a[1],a[2],0)
-print "DTEND:" datestamp(2015,m,d,a[3],a[4],0)
+print "DTSTAMP:" datestamp(t[1],t[2],t[3],t[4],t[5],t[6]) "Z"
+print "DTSTART:" datestamp(YEAR,m,d,a[1],a[2],0)
+print "DTEND:" datestamp(YEAR,m,d,a[3],a[4],0)
 print "SUMMARY:" $2
 print "LOCATION:" $3
 print "UID:-417s61147-mbg@istanbul.edu.tr"


The awk scripts need to handle BrlAPI type aliases. (dm)

--- Programs/brlapi.awk
+++ Programs/brlapi.awk
@@ -63,8 +63,15 @@
 }

 /^[[:space:]]*BRLAPI_PARAM_TYPE_[^[:space:],]+,?/ {
-  gsub(",", "", $1)
-  apiConstant(substr($1, 8), $1, apiParameterTypeCount++, getComment($0))
+  if ($2 == "=" ) {
+    gsub("^BRLAPI_", "", $3)
+    gsub(",", "", $3)
+    apiConstant(substr($1, 8), $1, $3, getComment($0))
+  } else {
+    gsub(",", "", $1)
+    apiConstant(substr($1, 8), $1, apiParameterTypeCount++, getComment($0))
+  }
+
   next
 }


[TRAFODION 2381] Enhance awk script to support many variations of distros.

--- core/sqf/src/seatrans/hbase-trx/pp.awk
+++ core/sqf/src/seatrans/hbase-trx/pp.awk
@@ -19,93 +19,151 @@
 # under the License.
 #
 # @@@ END COPYRIGHT @@@
-#  The following example has been tested to work.
+#  The following example has been tested to work. Any other
+#  combination is not guranteed to work.
 #  If the file f1 contains the following, run this script
 #  as follows:
 #   awk -f pp.awk -v distro=HDP2.3 f1 > f2
+#   awk -f pp.awk -v distro=APACHE1.1 f1 > f2
 #
 #  contents of  file f1:
-#   #ifdef HDP2.3
-#   this is HDP2.3 specific code
-#   #else
-#   this is anything other than  HDP2.3 code
-#   #endif
-#
-#   #ifndef HDP2.3
-#   this is anything other than HDP2.3 code partof ifndef construct
-#   #else
-#   this is HDP2.3 code part of ifndef else construct
-#   #endif
-#
-#   this is common code for all cases
-#
-#   #ifdef CDH5.4
-#   this is CDH5.4 specific code
-#   #endif
-#
-#   #ifdef CDH5.5 HDP2.3 APACHE1.1 CDH5.7
-#   this is common CDH5.5 or HDP2.3 or APACHE1.1 or CDH5.7
-#   #else
-#   this is anything other than CDH5.5 or HDP2.3 or APACHE1.1 or CDH5.7 code
-#   #endif
+# #ifdef HDP2.3
+# this is HDP2.3 specific code
+# #else
+# this is anything other than  [HDP2.3] code
+# #endif
+#
+# common code 1
+#
+# #ifndef HDP2.3
+# this is anything other than [HDP2.3] code partof ifndef construct
+# #else
+# this is HDP2.3 code part of ifndef else construct
+# #endif
+#
+# common code 2
+#
+# #ifdef CDH5.4
+# this is CDH5.4 specific code
+# #endif
+#
+# common code 3
+#
+# #ifdef CDH5.5 HDP2.3 APACHE1.1 CDH5.7
+# this is common CDH5.5 or HDP2.3 or APACHE1.1 or CDH5.7
+# #else
+# this is anything other than [CDH5.5] or [HDP2.3] or [APACHE1.1] or [CDH5.7] code
+# #endif
+#
+# common code 4
+#
+# #ifdef CDH5.5 HDP2.3
+# this is common CDH5.5 or HDP2.3
+# #elseif APACHE1.1
+# this is specific to APACHE1.1 part of elseif construct
+# #elseif CDH5.7
+# this is specific to CDH5.7 part of elseif construct
+# #else
+# this is anything other than [CDH5.5] or [HDP2.3] or [APACHE1.1] or [CDH5.7] code
+# #endif
+#
+# common code 5
+#
+# #ifdef CDH5.5 HDP2.3
+# this is common CDH5.5 or HDP2.3
+# #elseif APACHE1.1
+# this is specific to APACHE1.1 part of elseif construct
+# #elseif CDH5.7
+# this is specific to CDH5.7 part of elseif construct
+# #endif
+#
+# common code 6
+

 BEGIN{
 printline=1      #print current line or not.
 matchBegun=0     #match succeeded, keep printing
 unmatchBegun=0   #opposite of  match, keep non-printing
+unmatchTillEndif=0 #specific to #elseif case.
 ifdefpattern = "#ifdef"
 endifpattern = "#endif"
 elsepattern = "#else"
 ifndefpattern = "#ifndef"
-#distro passed in as argument
+elseifpattern = "#elseif"
+#distro passed in as argument, can only be one tag set by makefile at a time.
 }
 {
   #By default print everything
   printline =1

 #########################
-#  This section deals with resetting flags
+#  This section deals with #else #elseif #endif tags
 ########################
   #reset when #endif is encountered
-  if(($0 ~ endifpattern) && (matchBegun == 1))
-    {
-      printline = 0
-     matchBegun = 0
-    }
-
-  #reset when #endif is encountered
-  if(($0 ~ endifpattern) && (unmatchBegun == 1))
-    {
-      printline = 0
-     unmatchBegun = 0
-    }
-
+  if($1 == endifpattern)
+    {
+      printline = 0
+      matchBegun = 0
+      unmatchBegun = 0
+      unmatchTillEndif = 0
+    }
+
+  # Handle #else in this section.
   #when #else is encountered and unmatchBegun, reset unmatchBegun
   #start print subsequent lines.
-  if(($0 ~ elsepattern) && (unmatchBegun == 1))
+  if(($1 == elsepattern) && (unmatchBegun == 1))
     {
       printline = 0
       unmatchBegun = 0
-      matchBegun = 1
+      matchBegun = 0
     }
   else
   {
     #when #else is encountered and matchBegun, reset matchBegun
     #start unprint subsequent lines by setting unmatchBegun
-    if(($0 ~ elsepattern) && (matchBegun == 1))
+    if(($1 == elsepattern) && (matchBegun == 1))
     {
       printline = 0
       unmatchBegun = 1
+      matchBegun = 0
     }
   }
-
+
+  # Handle #elseif  in this section.
+  #when #elseif is encountered and unmatchBegun, reset unmatchBegun
+  #start print subsequent lines.
+  if(($1 == elseifpattern) && ($0 ~ distro) && (unmatchBegun == 1))
+    {
+      printline = 0
+      unmatchBegun = 0
+      matchBegun = 1
+    }
+  else
+  {
+    #when #elseif is encountered and matchBegun, reset matchBegun
+    #start unprint subsequent lines by setting unmatchBegun
+    if(($1 == elseifpattern) && (matchBegun == 1))
+    {
+      printline = 0
+      unmatchBegun = 0   #setting to 1 or 0 does not matter.
+      matchBegun = 0
+      unmatchTillEndif = 1 #setting to 1 handles subsequent #else
+    }
+  }
+
 ##########################
-# This section matches distro string and sets flags
+# This section matches distro string and sets flags.
+# This section deals with #ifdef and #ifndef tags only.
+#
+# printline is set 0 in all cases below to indicate not to print
+# current line. matchBegun and unmatchBegun toggles appropriately.
+# matchBegun used for all lines that must be included.
+# unmatchBegun used for all lines that must be excluded.
 ##########################

-  if($0 ~ ifdefpattern)
+  if($1 == ifdefpattern)
    {
-     if( $2 ~ distro || $3 ~ distro || $4 ~ distro || $5 ~ distro || $6 ~ distro)
+     if($0 ~ distro)
      {
        printline = 0
        matchBegun = 1
@@ -116,9 +174,9 @@
       unmatchBegun = 1
      }
    }
- if($0 ~ ifndefpattern)
+ if($1 == ifndefpattern)
   {
-    if($2 ~ distro || $3 ~ distro || $4 ~ distro || $5 ~ distro || $6 ~ distro)
+    if($0 ~ distro)
     {
       printline = 0
       unmatchBegun = 1
@@ -136,7 +194,11 @@
   #if unmatchBegun discard those lines
   if(unmatchBegun == 1)
      printline = 0
-
+
+  #if unmatchTillEndif discard those lines
+  if(unmatchTillEndif == 1)
+     printline = 0
+
   if(printline == 1)
 	print $0;
 }


Make this link against gtk+-3.24.4

Make this link against gtk+-3.24.4

--- Gtk-3.0.awk
+++ Gtk-3.0.awk
@@ -2,11 +2,14 @@
 #
 # Patch the generated wrapper Swift code to handle special cases
 #
-BEGIN { depr_init = 0 }
+BEGIN { depr_init = 0 ; comment = 0 }
 /open .* ColorSelection/ { depr_init = 1 }
 /public .* ColorSelection/ { depr_init = 1 }
 /public .* HSV/ { depr_init = 1 }
 /open .* HSV/ { depr_init = 1 }
+/open .* HSV/ { depr_init = 1 }
+/func getColumnHeaderCells/ { comment = 1 }
+/func getRowHeaderCells/ { comment = 1 }
 / init.. {/ {
 	if (depr_init) {
 		printf("@available(*, deprecated) ")
@@ -19,4 +22,10 @@
 		depr_init = 0
 	}
 }
-// { print }
+// {
+	if (comment) {
+		printf("// ")
+	}
+	print
+}
+/^    }$/ { comment = 0 }


comment

comment

--- script.awk
+++ script.awk
@@ -1,4 +1,5 @@
-BEGIN {
+# this script replaces development scripts by a minified ones
+BEGIN {
     script=0;
     output=1;
     endscript=0;