feat: Update to output in markdown format

--- changelog.awk
+++ changelog.awk
@@ -1,29 +1,44 @@
 #!/usr/bin/awk -f
 BEGIN {
-	# Determines whether to print 'Unreleased' banner at top
-	UNRELEASED_COMMITS = 1
+	REPO_URL = getRepoURL()
 	# Prefixes that determine whether a commit will be printed
 	CHANGELOG_REGEX = "^(changelog|fix|docs|chore|feat|feature|refactor|update): "
 	FS="|"
-	while ("git log --pretty='%D|%s|%H'" | getline) {
+	# %D: tags
+	# %s: commit message
+	# %H: long hash
+	# %h: short hash
+	while ("git log --pretty='%D|%s|%H|%h'" | getline) {
 		IS_GIT_TAG = length($1) && match($1, /tag:/)
 		if (IS_GIT_TAG) {
-			UNRELEASED_COMMITS = 0
-			# Cut out text up to tag
-			sub(/.*tag: /, "", $1)
-			# Cut out text after tag
-			sub(/,.*/, "", $1)
-			print $1
+			printTag($1)
 		} else {
-			if ( UNRELEASED_COMMITS ) {
-				print "Unreleased"
-				UNRELEASED_COMMITS = 0
-			}
-			if ( match($2, CHANGELOG_REGEX) ) {
-				sub(CHANGELOG_REGEX, "", $2)
-				printf("\t- %s\n", $2)
-			}
+			printCommit($2, $3, $4)
 		}

 	}
 }
+function printTag(input) {
+	# Cut out text up to tag
+	sub(/.*tag: /, "", input)
+	# Cut out text after tag
+	sub(/,.*/, "", input)
+	printf("## %s\n", input)
+}
+function printCommit(input, longHash, shortHash) {
+	if ( match(input, CHANGELOG_REGEX) ) {
+		sub(CHANGELOG_REGEX, "", input)
+		printf("- %s (%s)\n", input, makeCommitLink(REPO_URL, shortHash, longHash) )
+	}
+}
+function makeCommitLink(repoUrl, shortHash, longHash) {
+	return ("[" shortHash "](" repoUrl "/commit/" longHash ")")
+}
+# Get Git repo URL
+function getRepoURL() {
+	"git config --get remote.upstream.url || git config --get remote.origin.url || git config --get remote.dev.url" | getline REPO_URL
+	sub(/:/, "/", REPO_URL)
+	sub(/git@/, "https://", REPO_URL)
+	sub(/\.git/, "", REPO_URL)
+	return REPO_URL
+}


Add feature to ignore years except for 2005-2012 with manifest status.

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

--- scripts/tdb/statuses_gln.awk
+++ scripts/tdb/statuses_gln.awk
@@ -1,5 +1,5 @@
 #!/usr/bin/awk -f
-# cat *.tdb | tdbout -t publisher,plugin,publisher:info[tester],status
+# cat *.tdb | tdbout -t publisher,plugin,publisher:info[tester],status,year

 BEGIN {
   FS="\t"
@@ -7,6 +7,21 @@
 }

 {
+  # add a loop to add line only if either status is _not_ manifest or ending year is gt or eq to contract year
+  current_year = 2012
+  end_year = 0
+  incontract = 0
+  test_year = ""
+  test_year = 2005
+  if (length($5) > 3) {
+    end_year = substr($5,length($5)-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
+  if (($4 != "manifest") || ((end_year >= test_year) && (end_year <= current_year))) {
+    incontract = 1
+  }
+
+  if (incontract == 1) {
     nn = split($2,na,/\./)
     lp2 = na[nn]
     if (!(($1,lp2) in b)) {
@@ -14,12 +29,24 @@
       n[pn] = lp2
   #    n[pn] = $2
       r[pn] = $3
+      if (r[pn] == "") {
+        if ((substr(p[pn],1,2) >= "Aa") && (substr(p[pn],1,2) <= "Am")) {
+          r[pn] = "7"
+        } else if ((substr(p[pn],1,2) >= "An") && (substr(p[pn],1,2) <= "Cz")) {
+          r[pn] = "4"
+        } else if ((substr(p[pn],1,2) >= "Da") && (substr(p[pn],1,2) <= "Nz")) {
+          r[pn] = "5"
+        } else if (substr(p[pn],1,1) >= "O") {
+          r[pn] = "8"
+        }
+      }
       pn++
     }
     b[$1,lp2]++
     c[$1,lp2,$4]++
     x[$4]++
     tt++
+  }
 }

 END {


Fix ë in Acorn titles

Fix ë in Acorn titles

--- getAcornFrom-showPages.awk
+++ getAcornFrom-showPages.awk
@@ -23,6 +23,7 @@
     gsub (/&/,"\\&",showTitle)
     gsub (/"/,"\"\"",showTitle)
     gsub (/'/,"'",showTitle)
+    gsub (/ë/,"ë",showTitle)
     if (match (showTitle, /^The /)) {
         showTitle = substr(showTitle, 5) ", The"
     }


Main: cleanup

Main: cleanup

--- include/Main.awk
+++ include/Main.awk
@@ -9,16 +9,18 @@

     split(PROCINFO["version"], group, ".")
     if (group[1] < 4) {
-        e("[ERROR] Oops! Your gawk (version " GawkVersion ") appears to be too old.\nYou need at least gawk 4.0.0 to run this program.")
+        e("[ERROR] Oops! Your gawk (version " GawkVersion ") "          \
+          "appears to be too old.\n"                                    \
+          "        You need at least gawk 4.0.0 to run this program.")
         exit 1
     }
 }

-# Pre-initialization (before option parsing).
-function preInit() {
-    initGawk()          #<< AnsiCode
-
-    # Languages
+# Initialization #1. (prior to option parsing)
+function init1() {
+    initGawk()          #<< Commons.awk/AnsiCode
+
+    # Languages.awk
     initBiDi()
     initLocale()
     initLocaleDisplay() #<< Locale, BiDi
@@ -58,23 +60,53 @@
     Option["prompt-color"] = ENVIRON["TRANS_PS_COLOR"] ? ENVIRON["TRANS_PS_COLOR"] : "default"

     Option["input"] = ""
-    Option["output"] = "/dev/stdout"
+    Option["output"] = STDOUT

     Option["hl"] = ENVIRON["HOME_LANG"] ? ENVIRON["HOME_LANG"] : UserLang
     Option["sl"] = ENVIRON["SOURCE_LANG"] ? ENVIRON["SOURCE_LANG"] : "auto"
     Option["tl"][1] = ENVIRON["TARGET_LANG"] ? ENVIRON["TARGET_LANG"] : UserLang
 }

-# Post-initialization (after option parsing).
-function postInit() {
-    # Translate
+# Initialization #2. (prior to interactive mode handling)
+function init2() {
+    # Disable ANSI escape codes if required
+    if (Option["no-ansi"])
+        delete AnsiCode
+}
+
+# Initialization #3.
+function init3(    group) {
+    # Translate.awk
     initHttpService()
+
+    # Initialize browser
+    if (!Option["browser"]) {
+        "xdg-mime query default text/html" SUPERR |& getline Option["browser"]
+        match(Option["browser"], "(.*).desktop$", group)
+        Option["browser"] = group[1]
+    }
+
+    # Initialize audio player or speech synthesizer
+    if (Option["play"]) {
+        if (!Option["player"]) {
+            initAudioPlayer()
+            Option["player"] = AudioPlayer ? AudioPlayer : Option["player"]
+            if (!Option["player"])
+                initSpeechSynthesizer()
+        }
+
+        if (!Option["player"] && !SpeechSynthesizer) {
+            w("[WARNING] No available audio player or speech synthesizer is found.")
+            Option["play"] = 0
+        }
+    }
 }

 # Main entry point.
 BEGIN {
-    preInit()
-
+    init1() # initialization #1
+
+    # Option parsing
     pos = 0
     while (ARGV[++pos]) {
         # -, -no-op
@@ -105,7 +137,7 @@
             if (ENVIRON["TRANS_MANPAGE"])
                 system("echo -E \"${TRANS_MANPAGE}\" | " \
                        "groff -Wall -mtty-char -mandoc -Tutf8 -rLL=${COLUMNS}n -rLT=${COLUMNS}n | " \
-                       (system("most 2>/dev/null") ?
+                       (system("most" SUPERR) ?
                         "less -s -P\"\\ \\Manual page " Command "(1) line %lt (press h for help or q to quit)\"" :
                         "most -Cs"))
             else
@@ -375,8 +407,7 @@
         break # no more option from here
     }

-    # Option parsing finished
-    postInit()
+    init2() # initialization #2

     if (Option["interactive"] && !Option["no-rlwrap"]) {
         # Interactive mode
@@ -427,41 +458,17 @@
             Option["interactive"] = 1 # skip
     }

-    if (Option["play"]) {
-        # Initialize audio player or speech synthesizer
-        if (!Option["player"]) {
-            initAudioPlayer()
-            Option["player"] = AudioPlayer ? AudioPlayer : Option["player"]
-            if (!Option["player"])
-                initSpeechSynthesizer()
-        }
-
-        if (!Option["player"] && !SpeechSynthesizer) {
-            w("[WARNING] No available audio player or speech synthesizer is found.")
-            Option["play"] = 0
-        }
-    }
-
     if (Option["interactive"]) {
-        print AnsiCode["bold"] AnsiCode[tolower(Option["prompt-color"])] getVersion() AnsiCode[0] > "/dev/stderr"
-        print AnsiCode[tolower(Option["prompt-color"])] "(:q to quit)" AnsiCode[0] > "/dev/stderr"
-    }
-
-    # Initialize browser
-    if (!Option["browser"]) {
-        "xdg-mime query default text/html 2>/dev/null" |& getline Option["browser"]
-        match(Option["browser"], "(.*).desktop$", group)
-        Option["browser"] = group[1]
-    }
-
-    # Disable ANSI SGR (Select Graphic Rendition) codes if required
-    if (Option["no-ansi"])
-        delete AnsiCode
+        print AnsiCode["bold"] AnsiCode[tolower(Option["prompt-color"])] getVersion() AnsiCode[0] > STDERR
+        print AnsiCode[tolower(Option["prompt-color"])] "(:q to quit)" AnsiCode[0] > STDERR
+    }
+
+    init3() # initialization #3

     if (pos < ARGC) {
         # More parameters

-        # Translate the remaining parameters
+        # Translate remaining parameters
         for (i = pos; i < ARGC; i++) {
             # Verbose mode: separator between sources
             if (Option["verbose"] && i > pos)
@@ -475,7 +482,7 @@
         # No more parameter besides options

         # If input not specified, use stdin
-        if (!Option["input"]) Option["input"] = "/dev/stdin"
+        if (!Option["input"]) Option["input"] = STDIN
     }

     # If input specified, start translating


Languages: add Yucatec Maya language

Languages: add Yucatec Maya language


Main: two-way connection is not needed for initializing browser

--- include/Main.awk
+++ include/Main.awk
@@ -126,7 +126,7 @@

     # Initialize browser
     if (!Option["browser"]) {
-        "xdg-mime query default text/html" SUPERR |& getline Option["browser"]
+        "xdg-mime query default text/html" SUPERR | getline Option["browser"]
         match(Option["browser"], "(.*).desktop$", group)
         Option["browser"] = group[1]
     }


Work around a Linux bug on Unsafe*Pointer<va_list>

--- GLib-2.0.awk
+++ GLib-2.0.awk
@@ -29,6 +29,10 @@
 	vaptrptr = 1
 	print "#if !os(Linux)"
 }
+/Pointer<va_list>/ {
+	vaptrptr = 1
+	print "#if !os(Linux)"
+}
 /^$/ {
 	if (vaptrptr) {
 		print "#endif"


replace old slidy stylesheet with current one; .oO we could just use a constant html header now

--- tools/slidy.awk
+++ tools/slidy.awk
@@ -11,15 +11,25 @@
   next
 }

-### TODO:
-#  <link rel="stylesheet" type="text/css" media="screen, projection, print" href="http://www.w3.org/Talks/Tools/Slidy2/styles/slidy.css" />
-
-
 /<script type="text\/javascript" charset="utf-8">/ {
   print "  <script src='http://www.w3.org/Talks/Tools/Slidy2/scripts/slidy.js' charset='utf-8' type='text/javascript'></script>"
   skipScript = 1
   next
 }
+
+/<style type="text\/css">/ {
+  styleEncountered++
+}
+
+styleEncountered == 2 && /<\/style>/ {
+  print "  <link rel='stylesheet' type='text/css' media='screen, projection, print' href='http://www.w3.org/Talks/Tools/Slidy2/styles/slidy.css' />"
+  styleEncountered = 3
+}
+
+styleEncountered == 2 {
+  next
+}
+

 {
     sub(/<title>Haskell: Functional Programming, Solid Code, Big Data<\/title>/, "<title>Intro \\“Functional Programming\\”</title>")


syscall: Remove a couple more 3-parameter match's in mksyscall.awk.

R=iant
CC=gofrontend-dev
https://golang.org/cl/5322062

--- libgo/go/syscall/mksyscall.awk
+++ libgo/go/syscall/mksyscall.awk
@@ -170,7 +170,7 @@
 	    printf("\t}\n")

 	    ++carg
-	    if (match(cargs[carg], "^([^ ]*) ([^ ]*)$", cparam) == 0) {
+	    if (split(cargs[carg], cparam) != 2) {
 		print loc, "bad C parameter:", cargs[carg] | "cat 1>&2"
 		status = 1
 		next
@@ -207,7 +207,7 @@
 	}
 	usedr = 0
 	for (goresult = 1; goresults[goresult] != ""; goresult++) {
-	    if (match(goresults[goresult], "^([^ ]*) ([^ ]*)$", goparam) == 0) {
+	    if (split(goresults[goresult], goparam) != 2) {
 		print loc, "bad result:", goresults[goresult] | "cat 1>&2"
 		status = 1
 		next


Delete postbanken.awk

Delete postbanken.awk

es funktioniert nicht wie beschrieben und wird jetzt doch nicht mehr gebraucht

--- postbanken.awk
+++ postbanken.awk
@@ -1,39 +0,0 @@
-#
-# Quelle (2014-12-07):
-# http://wiki.gnucash.org/wiki/FAQ#Q:_How_do_I_convert_from_CSV.2C_TSV.2C_XLS_.28Excel.29.2C_or_SXC_.28OpenOffice.org_Calc.29_to_a_QIF.3F
-# Anwendung:
-# awk -f postbanken.awk kontoutskrift.csv > import.qif
-#
-# awk convert fra Postbankens CSV til QIF(Gnucash, quicken, osv)
-# CSV fra Postbanken er ikke en kommaseparert fil, men en tekstfil med feltene på fast plass.
-# Bruker derfor fieldwidths i awk. Det går også ant å bruke substr().
-# Kilder:
-# http://wiki.gnucash.org/wiki/FAQ
-# http://www.ibm.com/developerworks/library/l-awk1.html
-# http://www.ibm.com/developerworks/library/l-awk2.html
-# http://www.grymoire.com/Unix/Awk.html#uh-67
-# Samt manualen til awk og egrep.
-#
-# Bruk filen slik:
-# $ awk -f postbanken.awk kontoutskrift.csv > import.qif
-#
-#
-# Arve Seljebu - juni 2010
-
-
-# Del opp filen i felter og skriv "!Type:Bank" bare en gang i toppen av filen
-BEGIN {FIELDWIDTHS="8 5 17 35 31 11 1 11"; print "!Type:Bank";}
-# Bare bruk linjen hvis den inneholder dato
-{ if ($0 ~ /[0-9][0-9].[0-9][0-9].[0-9][0-9]/) {
-# Dato
-  print "D" $1;
-# Avkommenter neste linje for å bruke BETALING, BETALING UTLAND osv som konto/kategori
-# print "L" $3;
-# Beskrivelse/memo
-  print "M" $4;
-# Debit eller kredit
-  if ($6 == 0) { print "T-" $8; }
-  else { print "T" $6; }
-  print "^";
-  }
-}


MFp4:

MFp4:

- Check for duplicated symbols and suggest moving them to ObsoleteVersions.
- Improve and unify error handling.
- Make the regular expressions more uniform, robust, and less sensitive
  to harmless variations in the input such as those to whitespace amount.

Reviewed by:	deischen
Tested with:	md5 (Version.map files in /usr/obj stay the same)

--- share/mk/version_gen.awk
+++ share/mk/version_gen.awk
@@ -34,6 +34,8 @@
 #                  version name.
 #   symbols[][] - array index by [version name, symbol index], contains
 #                 names of symbols defined for each version.
+#   names[] - array index is symbol name and value is count,
+#	      used to check for duplicate symbols and warn about them.
 #
 BEGIN {
 	brackets = 0;
@@ -45,10 +47,13 @@
 		# Strip comments.
 		sub("#.*$", "", $0);

-		# Strip trailing spaces.
-		sub(" *$", "", $0);
-
-		if (/^[ \t]*[a-zA-Z0-9._]+ *{/) {
+		# Strip leading and trailing whitespace.
+		sub("^[ \t]+", "", $0);
+		sub("[ \t]+$", "", $0);
+
+		if (/^[a-zA-Z0-9._]+[ \t]*{$/) {
+			# Strip brace.
+			sub("{", "", $1);
 			brackets++;
 			symver = $1;
 			versions[symver] = 1;
@@ -56,39 +61,56 @@
 			generated[symver] = 0;
 			version_count++;
 		}
-		else if (/^[ \t]*} *[a-zA-Z0-9._]+ *;/) {
+		else if (/^}[ \t]*[a-zA-Z0-9._]+[ \t]*;$/) {
+			v = $1 != "}" ? $1 : $2;
+			# Strip brace.
+			sub("}", "", v);
 			# Strip semicolon.
-			gsub(";", "", $2);
-			if (symver == "")
-				printf("Unmatched bracket.\n");
-			else if (versions[$2] != 1)
-				printf("File %s: %s has unknown " \
-				    "successor %s\n", vfile, symver, $2);
+			sub(";", "", v);
+			if (symver == "") {
+				printf("File %s: Unmatched bracket.\n",
+				vfile) > stderr;
+				errors++;
+			}
+			else if (versions[v] != 1) {
+				printf("File %s: `%s' has unknown " \
+				    "successor `%s'.\n",
+				    vfile, symver, v) > stderr;
+				errors++;
+			}
 			else
-				successors[symver] = $2;
+				successors[symver] = v;
 			brackets--;
 		}
-		else if (/^[ \t]*};/) {
-			if (symver == "")
+		else if (/^}[ \t]*;$/) {
+			if (symver == "") {
 				printf("File %s: Unmatched bracket.\n",
 				    vfile) > stderr;
+				errors++;
+			}
 			# No successor
 			brackets--;
 		}
-		else if (/^[ \t]*}/) {
-			printf("File %s: Missing ending semi-colon.\n",
+		else if (/^}$/) {
+			printf("File %s: Missing final semicolon.\n",
 			    vfile) > stderr;
+			errors++;
 		}
 		else if (/^$/)
 			;  # Ignore blank lines.
-		else
-			printf("File %s: Unknown directive: %s\n",
+		else {
+			printf("File %s: Unknown directive: `%s'.\n",
 			    vfile, $0) > stderr;
+			errors++;
+		}
 	}
 	brackets = 0;
 }

-/.*/ {
+{
+	# Set meaningful filename for diagnostics.
+	filename = FILENAME != "" ? FILENAME : "<stdin>";
+
 	# Delete comments, preceding and trailing whitespace, then
 	# consume blank lines.
 	sub("#.*$", "", $0);
@@ -98,15 +120,18 @@
 		next;
 }

-/^[a-zA-Z0-9._]+ +{$/ {
+/^[a-zA-Z0-9._]+[ \t]*{$/ {
 	# Strip bracket from version name.
 	sub("{", "", $1);
-	if (current_version != "")
+	if (current_version != "") {
 		printf("File %s, line %d: Illegal nesting detected.\n",
-		    FILENAME, FNR) > stderr;
+		    filename, FNR) > stderr;
+		errors++;
+	}
 	else if (versions[$1] == 0) {
 		printf("File %s, line %d: Undefined " \
-		    "library version %s\n", FILENAME, FNR, $1) > stderr;
+		    "library version `%s'.\n", filename, FNR, $1) > stderr;
+		errors++;
 		# Remove this entry from the versions.
 		delete versions[$1];
 	}
@@ -116,20 +141,34 @@
 	next;
 }

-/^[a-zA-Z0-9._]+ *;$/ {
+/^[a-zA-Z0-9._]+[ \t]*;$/ {
+	# Strip semicolon.
+	sub(";", "", $1);
 	if (current_version != "") {
 		count = versions[current_version];
 		versions[current_version]++;
 		symbols[current_version, count] = $1;
+		if (names[$1]++) {
+			printf("File %s, line %d: Duplicated symbol `%s'. " \
+			    "Did you forget to move it to ObsoleteVersions?\n",
+			    filename, FNR, $1) > stderr;
+			errors++;
+		}
+	}
+	else {
+		printf("File %s, line %d: Symbol `%s' outside version scope.\n",
+		    filename, FNR, $1) > stderr;
+		errors++;
 	}
 	next;
 }

-/^} *;$/ {
+/^}[ \t]*;$/ {
 	brackets--;
 	if (brackets < 0) {
 		printf("File %s, line %d: Unmatched bracket.\n",
-		    FILENAME, FNR, $1) > stderr;
+		    filename, FNR, $1) > stderr;
+		errors++;
 		brackets = 0;	# Reset
 	}
 	current_version = "";
@@ -137,9 +176,10 @@
 }

-/.*/ {
-	printf("File %s, line %d: Unknown directive: '%s'\n",
-	    FILENAME, FNR, $0) > stderr;
+{
+	printf("File %s, line %d: Unknown directive: `%s'.\n",
+	    filename, FNR, $0) > stderr;
+	errors++;
 }

 function print_version(v)
@@ -162,7 +202,7 @@
 	for (i = 1; i < versions[v]; i++) {
 		if (i == 1)
 			printf("global:\n");
-		printf("\t%s\n", symbols[v, i]);
+		printf("\t%s;\n", symbols[v, i]);
 	}

 	version_count--;
@@ -178,7 +218,13 @@

 	generated[v] = 1;
     }
+
 END {
+	if (errors) {
+		printf("%d errors total.\n", errors) > stderr;
+		exit(1);
+	}
+	# OK, no errors.
 	for (v in versions) {
 		print_version(v);
 	}


program update

program update

--- cut_files.awk
+++ cut_files.awk
@@ -3,7 +3,7 @@
 #
 # Author : Yoshihiro Tanaka
 # Date   : 2014-11-04
-# Version: 0.1.2
+# Version: 0.1.3

 function output(chrom, header, seq) {
     filename = "db/Canis_familiaris.CanFam3.1.dna.chromosome." chrom ".fa";
@@ -13,8 +13,6 @@
     print "Successful output: " filename;
 }
 BEGIN {
-    "wc -l " ARGV[1] " | xargs -n 1 | head -n 1" | getline wc;
-    wc = wc ".0"
     c  = 0
 }
 {
@@ -31,7 +29,7 @@
         seq = seq "\n" $0
     }
     c++;
-    printf("progress: %f%%\r\b", (c / wc)*100)
+    printf("progress: %d\r\b", c)
 }
 END {
     output(chrom, header, seq)


Add method to generate temp bed for single end

--- lib/optical/bam_to_insert_size_bed.awk
+++ lib/optical/bam_to_insert_size_bed.awk
@@ -29,6 +29,19 @@
 }

 function se_bedder(path,size) {
+  if ($2==16) {
+    start = ($4+length($10) - size);
+    if (start <=0) {
+      start = 1;
+    }
+    print $3,start,($4-1+length($10)),".","1","-" > path;
+  } else if ($2==0) {
+    start=$4;
+    if (start<=0) {
+      start=1;
+    }
+    print $3,start,($4-1+size),".","1","+" > path;
+  }
 }

 {
@@ -38,6 +51,7 @@
     tlens[$9]++;
     pe_bedder(base"_tmp.bed");
   } else if ("se" == endness) {
+    se_bedder(base"_tmp.bed",size);
   }
 }


Main: set default indentation to 4

Main: set default indentation to 4

--- include/Main.awk
+++ include/Main.awk
@@ -25,7 +25,7 @@
     initUserLang()      #<< Locale

     RS = "\n"
-    I  = "  "
+    I  = "    "

     ExitCode = 0


more edits to match2tpl script

more edits to match2tpl script

--- recipes/match2tpl/match2tpl.awk
+++ recipes/match2tpl/match2tpl.awk
@@ -39,8 +39,8 @@

   print "Reading your names list..." > "/dev/stderr";
   while ((getline < IN) > 0) {
-    # INdata[++inputorder] = $0;
-    INcode[++inputorder] = $IN_code ;
+    INdata[++inputorder] = $0;
+    INcode[inputorder] = $IN_code ;
     INg[inputorder] = $IN_g ;
     INgsaStr[inputorder] = $IN_xg " " $IN_g " " $IN_xs " " $IN_s " " \
       $IN_st " " $IN_ssp " " $IN_a ;
@@ -65,6 +65,41 @@
   }
   print "  Done.\n" > "/dev/stderr";

+  # --------------------------------------------------------------
+
+  # STEP 6.
+
+  cmd = "test -e names.manual.EDITED.csv ; echo $?";
+  cmd | getline test1;
+  close(cmd);
+  cmd = "test -e names.simplematch.csv ; echo $?";
+  cmd | getline test2;
+  close(cmd);
+  if ((test1 == "0") && (test2 == "0")) {
+
+    while ((getline < "names.simplematch.csv") > 0) {
+      resultPL[$1] = $2;
+      status[$1] = "gsa";
+    }
+    while ((getline < "names.manual.EDITED.csv") > 0) {
+      if ($5 == 1) {
+        resultPL[$1] = $4;
+        status[$1] = "manual";
+      }
+    }
+
+    for (i = 1 ; i <= inputorder ; i++) {
+
+      if (PLsyn[resultPL[INcode[i]]]) final[i] = PLsyn[resultPL[INcode[i]]];
+      else final[i] = resultPL[INcode[i]];
+
+      print INdata[i], status[INcode[i]], PLdata[resultPL[INcode[i]]], PLdata[final[i]];
+    }
+    exit;
+  }
+
+  # --------------------------------------------------------------
+
   # STEP 2. try simple matching
   print "Simple matching..." > "/dev/stderr";
   for (i = 1 ; i <= inputorder ; i++) {
@@ -90,7 +125,7 @@

   # STEP 4. try agrep matching on species name
   for (i = 1 ; i <= inputorder ; i++) {
-    if (!INmatched[i]) {
+    if (!INmatched[i] && (!INgNotPL[INg[i]])) {
       cmd = "agrep -k -2 '" INgsakey[i] "' tmp_genera/" INg[i] ".csv";
       agreps = "";
       RS = "\x04";
@@ -108,10 +143,7 @@
     }
   }

-
-
-
-
+  # STEP 5. Manually edit "names.manual.csv"

   exit;
 }


ahrf.awk: Delete old comments

ahrf.awk: Delete old comments

--- ahrf.awk
+++ ahrf.awk
@@ -46,8 +46,6 @@
 			gsub(/^ +$/,"",$c)
 			printf("%s\n", $c)
 		}
-		# Solve "space" bug! Less crado (gsub).
-		#gsub(/^ +/,"",$NF)
 		printf("%s
\n", $NF)
 	}
 	next


Prevent that comments are changed

Prevent that comments are changed

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

--- scripts/marksession.awk
+++ scripts/marksession.awk
@@ -5,7 +5,7 @@
 }

 {
-  if ($1 ~ "[0-9]+") {
+  if ($3 ~ "[0-9]+") {
     # See if the current line is already in the table
     frame_file = destDir "/frames/Frame"$3".html"
     session_line = ""


Now toloka.awk can process multiple inputs

--- misc/toloka.awk
+++ misc/toloka.awk
@@ -3,10 +3,10 @@
     FS = OFS = "\t";
     print "INPUT:hyponym", "INPUT:hypernym", "INPUT:genitive", "GOLDEN:judgement", "HINT:text";
 }
-NR == 1 {
+FNR == 1 {
     for (i=1; i<=NF; i++) ix[$i] = i;
     next;
 }
-$ix["found"] {
+{
     print $ix["hyponym"], $ix["hypernym"], $ix["genitive"], "", "" | "sort -t \"\t\" -k1,1 -k2,2 -k3,3 -u";
 }


build.awk: export TRANS_DIR when rebuilding EntryScript

--- build.awk
+++ build.awk
@@ -202,7 +202,7 @@

         # Rebuild EntryScript
         print "#!/bin/sh" > EntryScript
-        print "TRANS_DIR=`dirname $0`" > EntryScript
+        print "export TRANS_DIR=`dirname $0`" > EntryScript
         print "gawk \\" > EntryScript
         for (i = 0; i < length(Includes) - 1; i++)
             print "-i \"${TRANS_DIR}/" Includes[i] "\" \\" > EntryScript


2.13.awk


Utils: curlPost()

Utils: curlPost()

--- include/Utils.awk
+++ include/Utils.awk
@@ -165,6 +165,32 @@
     return content
 }

+# Fetch the content of a URL. Return a null string if failed.
+function curlPost(url, data, output,    command, content, line) {
+    initCurl()
+
+    if (!Curl) {
+        l(">> not found: curl")
+        w("[WARNING] curl is not found.")
+        return NULLSTR
+    }
+
+    command = Curl " --location --silent"
+    if (Option["user-agent"])
+        command = command " --user-agent " parameterize(Option["user-agent"])
+    command = command " --request POST --data " data
+    command = command " " parameterize(url)
+    if (output) {
+        command = command " --output " parameterize(output)
+        system(command)
+        return NULLSTR
+    }
+    content = NULLSTR
+    while ((command |& getline line) > 0)
+        content = (content ? content "\n" : NULLSTR) line
+    return content
+}
+
 # Dump a Unicode string into a byte array. Return the length of the array.
 # NOTE: can only be ran once for each text! Build a cache.
 function dump(text, group,    command, temp) {


relpath.awk shouldn't be executable. (dm)

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


Apply regress because of errors.

Apply regress because of errors.

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -8,7 +8,7 @@
     #str | getline date;
     #close str;
 }
-$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
   # increased to 2015 July 1 2015.


Utils: fix newerVersion()

Utils: fix newerVersion()

--- include/Utils.awk
+++ include/Utils.awk
@@ -57,21 +57,15 @@
 }

 # Return 1 if the first version is newer than the second; otherwise return 0.
-function newerVersion(ver1, ver2,    group1, group2) {
+function newerVersion(ver1, ver2,    i, group1, group2) {
     split(ver1, group1, ".")
     split(ver2, group2, ".")
-    if (group1[1] + 0 > group2[1] + 0)
-        return 1
-    else if (group1[1] + 0 < group2[1] + 0)
-        return 0
-    if (group1[2] + 0 > group2[2] + 0)
-        return 1
-    else if (group1[2] + 0 < group2[2] + 0)
-        return 0
-    if (group1[3] + 0 > group2[3] + 0)
-        return 1
-    else if (group1[3] + 0 < group2[3] + 0)
-        return 0
+    for (i = 1; i <= 4; i++) {
+        if (group1[i] + 0 > group2[i] + 0)
+            return 1
+        else if (group1[i] + 0 < group2[i] + 0)
+            return 0
+    }
     return 0
 }


neaten up file generation

neaten up file generation

--- bin/mkrunetype.awk
+++ bin/mkrunetype.awk
@@ -5,7 +5,6 @@
 	# set up hexadecimal lookup table
 	for(i = 0; i < 16; i++)
 		hex[sprintf("%X",i)] = i;
-	HEADER = "/* Automatically generated by mkrunetype.awk */\n#include <stdlib.h>\n\n#include \"utf.h\"\n#include \"runetype.h\"\n"
 }

 $3  ~ /^L/ { alphav[alphac++] = $1; }
@@ -43,6 +42,11 @@
 	rune3c = 0;
 	rune4c = 0;
 	mode = 1;
+
+	print "/* Automatically generated by mkrunetype.awk */" > file
+	print "#include <stdlib.h>" > file
+	print "#include \"utf.h\"" > file
+	print "#include \"runetype.h\"" > file

 	#sort rune groups into singletons, ranges and laces
 	for(j = 0; j < runec; j++) {
@@ -169,6 +173,7 @@
 		}
 		print "};\n" > file;
 	}
+
 	# generate lookup function
 	print "int\nis"name"rune(Rune r)\n{" > file;
 	if(rune4c > 0 || rune3c > 0)
@@ -194,22 +199,22 @@
 		print "\nint\nto"casename"rune(Rune r)\n{\n\tRune *match;\n" > file;
 		if(rune4c > 0) {
 			print "\tmatch = bsearch(&r, "name"4, nelem("name"4), sizeof *"name"4, &rune2cmp);" > file;
-			print "\tif (match)" > file;
+			print "\tif(match)" > file;
 			print "\t\treturn ((r - match[0]) % 2) ? r : r - 1;" > file;
 		}
 		if(rune3c > 0) {
 			print "\tmatch = bsearch(&r, "name"3, nelem("name"3), sizeof *"name"3, &rune2cmp);" > file;
-			print "\tif (match)" > file;
+			print "\tif(match)" > file;
 			print "\t\treturn ((r - match[0]) % 2) ? r : r + 1;" > file;
 		}
 		if(rune2c > 0) {
 			print "\tmatch = bsearch(&r, "name"2, nelem("name"2), sizeof *"name"2, &rune2cmp);" > file;
-			print "\tif (match)" > file;
+			print "\tif(match)" > file;
 			print "\t\treturn match[2] + (r - match[0]);" > file;
 		}
 		if(rune1c > 0) {
 			print "\tmatch = bsearch(&r, "name"1, nelem("name"1), sizeof *"name"1, &rune1cmp);" > file;
-			print "\tif (match)" > file;
+			print "\tif(match)" > file;
 			print "\t\treturn match[1];" > file;
 		}
 		print "\treturn r;\n}" > file;


Parameter by which to tilt loops.

Parameter by which to tilt loops.

--- share/bin/plain2mp.awk
+++ share/bin/plain2mp.awk
@@ -37,6 +37,8 @@

 	# TODO: common stuff for multiple graphs

+	loopangle = 0; # angle by which to tilt loops. 0 is vertical
+
 	print "path e;"

 	print "input fsm.mp;"
@@ -56,7 +58,7 @@
 	print "		path m; m = head -- point t of e;"
 	print "		numeric ta; (ta, whatever) = head.perim intersectiontimes m;"
 #	print "		draw point ta of head.perim withpen pencircle scaled 4bp withcolor red;"
-	print "		fsmloop(head)(ta, lab);"
+	printf "		fsmloop(head)(ta - (length fullcircle * %f / 360), lab);\n", loopangle
 	print "	else:"
 	print "		path b; b = tail .. q .. p .. head;"
 # TODO: explain this. we permit a 2% lengthening threshold relative to graphviz's b-spline


Languages: add Bambara

Languages: add Bambara

--- include/Languages.awk
+++ include/Languages.awk
@@ -118,6 +118,19 @@
     Locale["az"]["iso"]                = "aze"
     Locale["az"]["glotto"]             = "nort2697"
     Locale["az"]["script"]             = "Latn"
+
+    # Bambara
+    Locale["bm"]["name"]               = "Bambara"
+    Locale["bm"]["endonym"]            = "Bamanankan"
+    #Locale["bm"]["translations-of"]
+    #Locale["bm"]["definitions-of"]
+    #Locale["bm"]["synonyms"]
+    #Locale["bm"]["examples"]
+    #Locale["bm"]["see-also"]
+    Locale["bm"]["family"]             = "Mande"
+    Locale["bm"]["iso"]                = "bam"
+    Locale["bm"]["glotto"]             = "bamb1269"
+    Locale["bm"]["script"]             = "Latn"

     #7 Basque
     Locale["eu"]["name"]               = "Basque"


Translate: fix translate()

Translate: fix translate()

--- lib/Translate.awk
+++ lib/Translate.awk
@@ -166,7 +166,7 @@
 # Translate the source text (into all target languages).
 function translate(text,
                    ####
-                   i, j, playlist) {
+                   i, j, playlist, saveSortedIn) {

     if (!getCode(Option["hl"])) {
         # Check if home language is supported
@@ -187,15 +187,13 @@
             w("[WARNING] " Locale[getCode(Option["sl"])]["name"] " is a right-to-left language, but GNU FriBidi is not found on your system.\nText might be displayed incorrectly.")
     }

+    saveSortedIn = PROCINFO["sorted_in"]
+    PROCINFO["sorted_in"] = "@ind_num_asc"
     for (i in Option["tl"]) {
-        # Non-interactive verbose mode: separator between translations
-        if (!Option["interactive"]) {
-            # Separator for multiple targets
-            if (i > 1) {
-                for (j = 0; j < Option["width"]; j++) printf "─"
-                printf "\n"
-            }
-        }
+        # Non-interactive verbose mode: separator between targets
+        if (!Option["interactive"])
+            if (Option["verbose"] && i > 1)
+                print replicate("─", Option["width"])

         print getTranslation(text, Option["sl"], Option["tl"][i], Option["hl"], Option["verbose"], Option["play"], playlist) > Option["output"]

@@ -207,4 +205,5 @@
                 for (j in playlist)
                     print playlist[j]["text"] | SpeechSynthesizer
     }
+    PROCINFO["sorted_in"] = saveSortedIn
 }


Correct coding error.

Correct coding error.

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

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -10,14 +10,14 @@
   # add a loop to add line only if ending year is gt or eq to contract year
   end_year = 0
   incontract = 0
-  if ($7 > 1900) {
+  if ($7 != "") {
     test_year = $7
   } else {
     test_year = $3
   }
   if (length($4) > 3) {
     end_year = substr($4,length($4)-3,4)
-  }
+  }
   if (end_year >= test_year) {
     incontract = 1
   }


fix some parameter

fix some parameter

--- lawson2osm.awk
+++ lawson2osm.awk
@@ -20,9 +20,13 @@

     printf("  <node id='-%s' lat='%f' lon='%f'>\n",$1,$2/3600000,$3/3600000);
     printf("    <tag k='shop' v='convenience' />\n");
+    printf("    <tag k='toilet' v='yes' />\n");
+    printf("    <tag k='atm' v='yes' />\n");
+    printf("    <tag k='internet_access' v='wlan' />\n");
     printf("    <tag k='name' v=' %sŹ' />\n",$9);
     printf("    <tag k='name:en' v='Lawson %s' />\n",t);
     printf("    <tag k='branch' v='%sŹ' />\n",$9);
+    printf("    <tag k='branch:ja_kana' v='%sŹ' />\n",$11);
     printf("    <tag k='branch:en' v='%s' />\n",t);
     printf("    <tag k='operator' v='' />\n");
     printf("    <tag k='operator:en' v='Lawson' />\n");
@@ -45,12 +49,8 @@
     if($5!=""){
 	printf("    <tag k='start_date' v='%s' />\n",$5);
     }
-    if($6!=""){
-	printf("    <tag k='end_date' v='%s' />\n",$6);
-    }
     printf("    <tag k='addr:full' v='%s' />\n",$10);
     printf("    <tag k='ref' v='%s' />\n",$1);
-    printf("    <tag k='source_ref' v='http://wiki.openstreetmap.org/wiki/Lawson_hackathon_2013' />\n");
     printf("  </node>\n");
 }
 END {


layerman: get awk location from env

layerman: get awk location from env

Signed-off-by: Koen Kooi <42e3d96910f922bdd7dd1805fe3f8aff634f391d@dominion.thruhere.net>

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

 BEGIN {
 	FS =",";


For now, comment out the broken part

For now, comment out the broken part

--- extra/scripts/initfini.awk
+++ extra/scripts/initfini.awk
@@ -19,12 +19,12 @@
     if(/\.align/) {alignval=$2}
 # here comes some special stuff for the SuperH targets
 # Search for all labels
-    if(/_GLOBAL_OFFSET_TABLE_/) {
-      sub (":","",last);
-      glb_label[glb_idx] = last;
-      glb_idx += 1;
-      glb = $0;
-    }
+#    if(/_GLOBAL_OFFSET_TABLE_/) {
+#      sub (":","",last);
+#      glb_label[glb_idx] = last;
+#      glb_idx += 1;
+#      glb = $0;
+#    }
     last = $1;
   }
   close("initfini.s");


Cosmetic

Cosmetic

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

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -10,6 +10,7 @@
   # add a loop to add line only if ending year is gt or eq to contract year
   end_year = 0
   incontract = 0
+  test_year = ""
   if ($7 == "") {
     test_year = $3
   } else {
@@ -18,11 +19,11 @@
   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
   if (end_year >= test_year) {
     incontract = 1
   }

-  #if ((substr($4,1,4) >= $3) || ((length($4) == 9) && (substr($4,6,4) >= $3))) {
   if (incontract == 1) {
       nn = split($2,na,/\./)
       lp2 = na[nn]


Fix The_Edinburgh_Show

Fix The_Edinburgh_Show

--- getBBoxEpisodesFrom-webscraper.awk
+++ getBBoxEpisodesFrom-webscraper.awk
@@ -42,18 +42,20 @@
     showtype = "S"

     shortURL = URL
+    episodeSeason = ""
+    # Season 3, Episode 8
     if (match (episodeTitle, /^Season [[:digit:]]+|^Series [[:digit:]]+/))
         episodeSeason = substr(episodeTitle,8,RLENGTH-7)
-    else
-        episodeSeason = ""

     # Extract sortkey from URL
     nflds = split (URL,fld,"_")
     if (URL ~ /_S[[:digit:]]*_E[[:digit:]]*_[[:digit:]]*$/) {
         # /us/episode/35_Days_S3_E8_23851
-        # Season 3, Episode 8
         seasonNumber = substr(fld[nflds-2], 2)
         episodeNumber = substr(fld[nflds-1], 2)
+        if (baseURL ~ /The_Edinburgh_Show_23924$/) {
+            episodeSeason = Years
+        }
         # Give precedence to season number in episodeTitle over season number in URL
         if (episodeSeason != "" && seasonNumber+0 != episodeSeason+0) {
             revisedSeasons1 += 1
@@ -68,7 +70,6 @@
         printf ("c1\t%d\t%s\t%s\t%s\t%s\t%s\n",c1Num,sortkey,URL,showTitle,episodeTitle,Years) >> outfile
     } else if (URL ~ /_E[[:digit:]]*_[[:digit:]]*$/) {
         # /us/episode/35_Hours_E1_26129
-        # 35 Hours, Episode 1
         revisedSeasons2 += 1
         episodeSeason = Years
         if (episodeSeason != "" && seasonNumber+0 != episodeSeason+0) {
@@ -83,7 +84,6 @@
         printf ("c2\t%d\t%s\t%s\t%s\t%s\t%s\n",c2Num,sortkey,URL,showTitle,episodeTitle,Years) >> outfile
     } else if (URL ~ /Episode_[[:digit:]]*_[[:digit:]]*$/) {
         # /us/episode/Episode_5_26089
-        # Season 4, Episode 5
         revisedSeasons3 += 1
         seasonNumber = "98"
         episodeNumber = substr(fld[nflds-1], 1)


Rework the way the awk code handles BrlAPI parameter type aliases so that the OCaml bindings can be built. (dm)

--- Programs/brlapi.awk
+++ Programs/brlapi.awk
@@ -63,13 +63,16 @@
 }

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

   next


Delete make-otagi-map.awk

Delete make-otagi-map.awk

--- table-CFF/bin/make-otagi-map.awk
+++ table-CFF/bin/make-otagi-map.awk
@@ -1,43 +0,0 @@
-#!/bin/awk -f
-#
-# usage: glyph-list.pl otagi.otf | make-otagi-map.awk > otagi.map
-#
-# asebi.CFF の作成に必要な otagi.map の作成。
-# 基本的には otagi の全てのグリフをそのまま map するだけなのだが、
-# /23058(や行え)と /23059(ア行エ)を交換しておく。
-# sammin の cmap と一致させるため。
-#
-# ちなみに otagi 0.603 と sammin 1.001 の cmap はほとんど同じであり、
-# えとエの他には
-#
-#   175 (U+00AF) MACRON (アンダースコアの逆、オーバースコア) の幅
-#  8216 (U+2018) 開始シングルクォート の幅
-#  8217 (U+2019) 終了シングルクォート の幅
-#  8220 (U+201C) 開始ダブルクォート の幅
-#  8221 (U+201D) 終了ダブルクォート の幅
-# 漢字 交、分、文、月、校、父 のデザイン差
-#
-# 以外は同じだった(以下のコマンドで確認できる)。
-# これらのグリフのための修正は不要と判断した。
-#
-# cmap 差分確認用コマンド
-# % sh cmap.sh sammin.otf | sort > sammin.cmap
-# % sh cmap.sh otagi.otf | sort > otagi.cmap
-# % join sammin.cmap otagi.cmap | while read cid codesam codeota
-# do
-# if [ "x$codesam" != "x$codeota" ]
-# then
-# echo "$cid      $codesam        $codeota"
-# fi
-# done
-#
-
-BEGIN {
-	FS="/"
-	print "mergeFonts"
-}
-{
-	     if($2 == 23058){print $2,23059}
-	else if($2 == 23059){print $2,23058}
-	else                {print $2,$2}
-}


Use mv -f.  Otherwise if you accidently build as root, and then as a user,
it keeps asking you if you want to overwrite it or not.

Submitted by:	peter

--- sys/tools/makeobjops.awk
+++ sys/tools/makeobjops.awk
@@ -474,9 +474,9 @@
 	}
 	else {
 		if (opt_c)
-			system_check("mv " ctmpfilename " " cfilename);
+			system_check("mv -f " ctmpfilename " " cfilename);
 		if (opt_h)
-			system_check("mv " htmpfilename " " hfilename);
+			system_check("mv -f " htmpfilename " " hfilename);
 	}
 }


asn.1 comments

asn.1 comments


oops typo

oops typo

--- dev/cardbus/devlist2h.awk
+++ dev/cardbus/devlist2h.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: devlist2h.awk,v 1.2 2000/05/15 06:29:09 niklas Exp $
+#	$OpenBSD: devlist2h.awk,v 1.3 2000/05/15 06:31:37 niklas Exp $
 #	$NetBSD: devlist2h.awk,v 1.1 1999/10/15 06:07:22 haya Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -48,7 +48,7 @@
 	printf(" *\t%s\n", VERSION) > dfile
 	printf(" */\n") > dfile

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


Add support for case/esac blocks in test cases

--- src/testify.awk
+++ src/testify.awk
@@ -5,13 +5,17 @@

 BEGIN {
 	# Define states
-	ST_REG = 0    # Regular state
-	ST_SQUOT = 1  # Inside single quotes
-	ST_DQUOT = 2  # Inside double quotes
-	ST_DSQUOT = 3 # Inside dollar single quotes
+	ST_REG = 0      # Regular state
+	ST_SQUOT = 1    # Inside single quotes
+	ST_DQUOT = 2    # Inside double quotes
+	ST_DSQUOT = 3   # Inside dollar single quotes
+	ST_CASE_BLK = 4 # Inside case/esac
+	ST_CASE_REG = 5 # Inside case match

 	TOP = 0
 	STATE[TOP] = ST_REG
+	REG_STATES[ST_REG]
+	REG_STATES[ST_CASE_REG]
 }

 #
@@ -32,6 +36,7 @@
 	do {
 		for (i = 1; i <= length; ++i) {
 			ch = substr($0, i, 1)
+			front = substr($0, i)
 			# Single quotes are simple
 			if (STATE[TOP] == ST_SQUOT) {
 				if (ch == "'") {
@@ -69,6 +74,32 @@
 				}
 				continue
 			}
+			# Inside case match
+			if (STATE[TOP] == ST_CASE_REG) {
+				if (front ~ /^;;.*/) {
+					++i
+					--TOP
+					continue
+				}
+			}
+			# Inside case block
+			if (STATE[TOP] == ST_CASE_BLK) {
+				if (ch == ")") {
+					STATE[++TOP] = ST_CASE_REG
+					# Output the parsed section so
+					# a check is only appended if the
+					# closing parentheses are followed
+					# by code
+					printf("%s", substr($0, 1, i))
+					$0 = substr($0, i + 1)
+					continue
+				}
+				if (front ~ /^esac([ \t#].*)?/) {
+					--TOP
+					i += 3
+					continue
+				}
+			}
 			# Regular state, or command substitution
 			if (ch == "'") {
 				STATE[++TOP] = ST_SQUOT
@@ -85,17 +116,19 @@
 				STATE[++TOP] = ST_REG
 			} else if (ch == ")") {
 				--TOP
+			} else if (front ~ /^case[ \t].+[ \t]in([ \t#].*)?/) {
+				STATE[++TOP] = ST_CASE_BLK
 			}
 		}
 		# About to get the next line, print this one
-		if (STATE[TOP] != ST_REG) {
+		if (!(STATE[TOP] in REG_STATES)) {
 			print
 		}
-	} while (STATE[TOP] != ST_REG && getline > 0)
+	} while (!(STATE[TOP] in REG_STATES) && getline > 0)
 }

 # Do not append error checks to lines not ending in a command.
-/((^|then|else|do|in|[({&;])|[ \t]*\\)$/ {
+/((^|then|else|do|[({&;])|[ \t]*\\)[ \t]*$/ {
 	print
 	next
 }


TestUtils: add test cases for dump()

TestUtils: add test cases for dump()

--- test/TestUtils.awk
+++ test/TestUtils.awk
@@ -30,5 +30,17 @@
         assertTrue(newerVersion("2", "1.9.9999"))
     }

+    T("dump()", 3)
+    {
+        delete group
+        assertEqual(dump("a", group), 1)
+
+        delete group
+        assertEqual(dump("Århus", group), 6)
+
+        delete group
+        assertEqual(dump("안녕하세요 세계", group), 22)
+    }
+
     END_TEST()
 }


Correct field numbers used in verification

--- verifyBBoxDownloadsFrom-webscraper.awk
+++ verifyBBoxDownloadsFrom-webscraper.awk
@@ -41,11 +41,14 @@
     cmd = "grep " target " " SEASONS_FILE
     while ((cmd | getline seasonLine) > 0) {
         split (seasonLine, fields, "\"")
-        seasonField = fields[20]
-        episodeField = fields[24]
+        seasonField = fields[16]
+        # print "seasonField = " seasonField
+        episodeField = fields[20]
+        # print "episodeField = " episodeField
         if (seasonField == "")
             continue
         print "          " target seasonField " has "episodeField >> EPISODE_INFO_FILE
+        # print "          " target seasonField " has "episodeField
     }
     close (cmd)
 }


improve readability of script

improve readability of script

--- generateIMDbScriptsFrom-titles.awk
+++ generateIMDbScriptsFrom-titles.awk
@@ -4,11 +4,11 @@
         sub (/^"/,"\"The ", title)
         sub (/, The"$/,"\"", title)
     }
-    printf ("echo ==\\> %3d: %s\n",NR,title) >> TITLES_SCRIPT
+    printf ("echo '==> %3d: %s'\n",NR,title) >> TITLES_SCRIPT
     printf ("./getIMDbInfoFrom-titles.py %s\n",title) >> TITLES_SCRIPT
     printf ("echo \n\n") >> TITLES_SCRIPT

-    printf ("echo ==\\> %3d: %s\n",NR,title) >> ID_SCRIPT
+    printf ("echo '==> %3d: %s'\n",NR,title) >> ID_SCRIPT
     printf ("./getIMDb_IDsFrom-titles.py %s | head -7\n",title) >> ID_SCRIPT
     printf ("echo \n\n") >> ID_SCRIPT
 }


remove check_miss.awk

remove check_miss.awk


show dictionary

show dictionary

--- include/Translate.awk
+++ include/Translate.awk
@@ -79,10 +79,11 @@
 function getTranslation(text, sl, tl, hl,
                         isVerbose, toSpeech, returnPlaylist,
                         ####
-                        altTranslations, article, ast, content,
-                        explanation, group, i, il, ils,
-                        isPhonetic, j, original, phonetics,
-                        r, rtl, saveSortedIn, segments,
+                        altTranslations, article, ast, content, example,
+                        explanation, group, i, il, ils, isPhonetic, j, k,
+                        oExamples, oPhonetics, oRefs, oSeeAlso, oSynonyms,
+                        oWords, oWordClasses, original, phonetics,
+                        r, ref, rtl, saveSortedIn, segments,
                         temp, tokens, translation, translations,
                         word, words, wordClasses) {
     isPhonetic = match(tl, /^@/)
@@ -123,27 +124,58 @@
             append(original, literal(ast[i]))
         if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "2$")
             append(phonetics, literal(ast[i]))
-
+        if (i ~ "^0" SUBSEP "0" SUBSEP "[[:digit:]]+" SUBSEP "3$")
+            append(oPhonetics, literal(ast[i]))
+
+        # 1 - word classes and explanations
         if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
             wordClasses[group[1]] = literal(ast[i])
-
         if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "([[:digit:]]+)$", group))
             words[group[1]][group[2]][group[3]] = literal(ast[i])
         if (match(i, "^0" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)$", group))
             words[group[1]][group[2]]["1"][group[3]] = literal(ast[i])

+        # 5 - alternative translations
         if (match(i, "^0" SUBSEP "5" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group)) {
             segments[group[1]] = literal(ast[i])
             altTranslations[group[1]][0] = ""
         }
-
         if (match(i, "^0" SUBSEP "5" SUBSEP "([[:digit:]]+)" SUBSEP "2" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
             altTranslations[group[1]][group[2]] = postprocess(literal(ast[i]))

-        # Identified source languages
+        # 8 - identified source languages
         if (i ~ "^0" SUBSEP "8" SUBSEP "0" SUBSEP "[[:digit:]]+$" ||
             i ~ "^0" SUBSEP "2$")
             append(ils, literal(ast[i]))
+
+        # 11 - (original) word classes and synonyms
+        if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
+            oWordClasses[group[1]] = literal(ast[i])
+        if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
+            if (ast[i]) {
+                oRefs[literal(ast[i])][1] = group[1]
+                oRefs[literal(ast[i])][2] = group[2]
+            }
+        if (match(i, "^0" SUBSEP "11" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group))
+            oSynonyms[group[1]][group[2]][group[3]] = literal(ast[i])
+
+        # 12 - (original) word classes and explanations
+        if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
+            oWordClasses[group[1]] = literal(ast[i])
+        if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
+            oWords[group[1]][group[2]][0] = literal(ast[i])
+        if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "1$", group))
+            oWords[group[1]][group[2]][1] = literal(ast[i])
+        if (match(i, "^0" SUBSEP "12" SUBSEP "([[:digit:]]+)" SUBSEP "1" SUBSEP "([[:digit:]]+)" SUBSEP "2$", group))
+            oWords[group[1]][group[2]][2] = postprocess(literal(ast[i]))
+
+        # 13 - (original) examples
+        if (match(i, "^0" SUBSEP "13" SUBSEP "0" SUBSEP "([[:digit:]]+)" SUBSEP "0$", group))
+            oExamples[group[1]] = postprocess(literal(ast[i]))
+
+        # 14 - (original) see also
+        if (match(i, "^0" SUBSEP "14" SUBSEP "0" SUBSEP "([[:digit:]]+)$", group))
+            oSeeAlso[group[1]] = literal(ast[i])
     }
     PROCINFO["sorted_in"] = saveSortedIn

@@ -167,7 +199,68 @@
     } else {
         # Verbose mode

-        r = AnsiCode["bold"] s(translation, tl) AnsiCode["no bold"] # target language
+        r = AnsiCode["bold"] show(join(original), il) AnsiCode["no bold"]
+        if (anything(oPhonetics))
+            r = r "\n" AnsiCode["bold"] "/" join(oPhonetics) "/" AnsiCode["no bold"]
+        r = r "\n"
+        # Dictionary mode
+        if (isarray(oWordClasses) && anything(oWordClasses)) {
+            for (i = 0; i < length(oWordClasses); i++) {
+                r = r "\n" AnsiCode["negative"] AnsiCode["bold"]        \
+                    show(oWordClasses[i], hl) AnsiCode["no bold"] AnsiCode["positive"]
+                if (isarray(oWords[i])) {
+                    # Detailed explanation
+                    for (j = 0; j < length(oWords[i]); j++) {
+                        explanation = oWords[i][j][0]
+                        ref = oWords[i][j][1]
+                        example = oWords[i][j][2]
+
+                        r = r "\n    " AnsiCode["bold"] show(explanation, il) AnsiCode["no bold"]
+                        if (example)
+                            r = r "\n    - \"" show(example, il) "\""
+                        if (ref && isarray(oRefs[ref])) {
+                            r = r "\n    * synonyms: " AnsiCode["underline"] \
+                                show(oSynonyms[oRefs[ref][1]][oRefs[ref][2]][0], il) AnsiCode["no underline"]
+                            for (k = 1; k < length(oSynonyms[oRefs[ref][1]][oRefs[ref][2]]); k++)
+                                r = r ", " AnsiCode["underline"]        \
+                                    show(oSynonyms[oRefs[ref][1]][oRefs[ref][2]][k], il) AnsiCode["no underline"]
+                        }
+                        r = r "\n"
+                    }
+                } else {
+                    # Synonyms only
+                    for (j = 0; j < length(oSynonyms[i]); j++) {
+                        r = r "\n  * " show(oSynonyms[i][j][0], il)
+                        for (k = 1; k < length(oSynonyms[i][j]); k++)
+                            r = r ", " show(oSynonyms[i][j][k], il)
+                    }
+                    r = r "\n"
+                }
+            }
+        }
+        # Examples
+        if (isarray(oExamples) && anything(oExamples)) {
+            r = r "\n" "Examples:"
+            for (i = 0; i < length(oExamples); i++) {
+                example = oExamples[i]
+                sub(/\u003cb\u003e/, AnsiCode["negative"], example)
+                sub(/\u003c\/b\u003e/, AnsiCode["positive"], example)
+                r = r "\n  - " show(example, il)
+                r = r "\n"
+            }
+        }
+        # See also
+        if (isarray(oSeeAlso) && anything(oSeeAlso)) {
+            r = r "\n" "See also:"
+            r = r "\n" AnsiCode["underline"] show(oSeeAlso[0], il) AnsiCode["no underline"]
+            for (k = 1; k < length(oSeeAlso); k++)
+                r = r ", " AnsiCode["underline"] show(oSeeAlso[k], il) AnsiCode["no underline"]
+            r = r "\n"
+        }
+
+
+
+        r = r "\n" AnsiCode["bold"] s(translation, tl) AnsiCode["no bold"] # target language
         if (anything(phonetics))
             r = r "\n" AnsiCode["bold"] join(phonetics) AnsiCode["no bold"] # phonetic transcription


Move down the functions.

Move down the functions.

--- gfwlist2dnsmasq.awk
+++ gfwlist2dnsmasq.awk
@@ -1,43 +1,4 @@
 #!/usr/bin/awk -f
-
-# Extract domain name from non-regex line
-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
-
-	if (match(line, /([A-Za-z0-9\-]+\.)+[A-Za-z0-9\-]+/)) {
-		domains[++domain_count] = line
-	} else {
-		print "[WARN] <NR>" NR "</NR><original>" original_line "</original><extracted>" line "</extracted>" | "cat >&2"
-		close("cat >&2")
-	}
-}
-
-# Extract domain name from regex line
-function extract_regex(line, original_line) {
-
-	# Expand the lines like (aa|bb|cc) into multiple records
-	pos = match(line, /\([A-Za-z0-9\.\|]+\)/)
-	if (pos != 0) {
-		in_bracket = substr(line, RSTART + 1, RLENGTH - 2)
-		n = split(in_bracket, arr, "|")
-		for (i = 1; i <= n; i++) {
-			expanded_line = line
-			sub(/\([A-Za-z0-9\.\|]+\)/, arr[i], expanded_line)
-			extract_regex(expanded_line, original_line)
-		}
-	} else {
-		sub(/.*:\\\/\\\//, "", line)    # remove everything till :\/\/ in regex, :// in plain text, such as http:// https://
-		gsub(/\([^\)]+\)\*?/, "", line) # remove (...)*? such as ([^\/]+\.)
-		gsub(/\[.*\]\+/, "", line)      # remove [...]
-		sub(/\\\/.*/, "", line)         # remove everything from \/ in regex, / in plaint text
-		gsub(/\\\./, ".", line)         # replace \. to .
-		extract(line, original_line)
-	}
-}

 BEGIN {
 	"date \"+%Y-%m-%d %H:%M:%S\"" | getline now
@@ -48,6 +9,7 @@
 	host = host != "" ? host : "127.0.0.1"
 	port = port != "" ? port : 5353
 }
+
 {
 	original_line = $0

@@ -90,9 +52,49 @@
 		extract($0, original_line)
 	}
 }
+
 END {
 	for (i = 1; i <= domain_count; i++) {
 		printf "server=/.%s/%s#%d\n", domains[i], host, port | "sort | uniq"
 	}
 	close("sort | uniq")
 }
+
+# Extract domain name from non-regex line
+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
+
+	if (match(line, /([A-Za-z0-9\-]+\.)+[A-Za-z0-9\-]+/)) {
+		domains[++domain_count] = line
+	} else {
+		print "[WARN] <NR>" NR "</NR><original>" original_line "</original><extracted>" line "</extracted>" | "cat >&2"
+		close("cat >&2")
+	}
+}
+
+# Extract domain name from regex line
+function extract_regex(line, original_line) {
+
+	# Expand the lines like (aa|bb|cc) into multiple records
+	pos = match(line, /\([A-Za-z0-9\.\|]+\)/)
+	if (pos != 0) {
+		in_bracket = substr(line, RSTART + 1, RLENGTH - 2)
+		n = split(in_bracket, arr, "|")
+		for (i = 1; i <= n; i++) {
+			expanded_line = line
+			sub(/\([A-Za-z0-9\.\|]+\)/, arr[i], expanded_line)
+			extract_regex(expanded_line, original_line)
+		}
+	} else {
+		sub(/.*:\\\/\\\//, "", line)    # remove everything till :\/\/ in regex, :// in plain text, such as http:// https://
+		gsub(/\([^\)]+\)\*?/, "", line) # remove (...)*? such as ([^\/]+\.)
+		gsub(/\[.*\]\+/, "", line)      # remove [...]
+		sub(/\\\/.*/, "", line)         # remove everything from \/ in regex, / in plaint text
+		gsub(/\\\./, ".", line)         # replace \. to .
+		extract(line, original_line)
+	}
+}


[rnc2rng.awk] Support namespaced element and attribute names


x86: Don't use POSIX character classes in gen-insn-attr-x86.awk

Not all awk implementations (including the default awk in Ubuntu 9.10)
support POSIX character classes.  Since x86-opcode-map.txt is plain
ASCII, we can just use explicit ranges for lower case, alphabetic, and
alphanumeric characters instead.

Signed-off-by: Roland Dreier <91e9b5f7ca0bb6300133ed378670d64af90dde66@cisco.com>
Acked-by: Masami Hiramatsu <308c3db2ad395e67f502db11a9ceb1603d4442e0@redhat.com>
LKML-Reference: <114d9d49de02dde04eecef799da927cfb6fa13bf@roland-alpha.cisco.com>
Signed-off-by: H. Peter Anvin <8a453bad9912ffe59bc0f0b8abe03df9be19379e@zytor.com>

--- arch/x86/tools/gen-insn-attr-x86.awk
+++ arch/x86/tools/gen-insn-attr-x86.awk
@@ -6,8 +6,6 @@

 # Awk implementation sanity check
 function check_awk_implement() {
-	if (!match("abc", "[[:lower:]]+"))
-		return "Your awk doesn't support charactor-class."
 	if (sprintf("%x", 0) != "0")
 		return "Your awk has a printf-format problem."
 	return ""
@@ -44,12 +42,12 @@
 	delete gtable
 	delete atable

-	opnd_expr = "^[[:alpha:]/]"
+	opnd_expr = "^[A-Za-z/]"
 	ext_expr = "^\\("
 	sep_expr = "^\\|$"
-	group_expr = "^Grp[[:alnum:]]+"
-
-	imm_expr = "^[IJAO][[:lower:]]"
+	group_expr = "^Grp[0-9A-Za-z]+"
+
+	imm_expr = "^[IJAO][a-z]"
 	imm_flag["Ib"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)"
 	imm_flag["Jb"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)"
 	imm_flag["Iw"] = "INAT_MAKE_IMM(INAT_IMM_WORD)"
@@ -62,7 +60,7 @@
 	imm_flag["Ob"] = "INAT_MOFFSET"
 	imm_flag["Ov"] = "INAT_MOFFSET"

-	modrm_expr = "^([CDEGMNPQRSUVW/][[:lower:]]+|NTA|T[012])"
+	modrm_expr = "^([CDEGMNPQRSUVW/][a-z]+|NTA|T[012])"
 	force64_expr = "\\([df]64\\)"
 	rex_expr = "^REX(\\.[XRWB]+)*"
 	fpu_expr = "^ESC" # TODO


Adding color to loop flow

Adding color to loop flow

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


Move GLN testing to 2015.

Move GLN testing to 2015.

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

 {
   # add a loop to add line only if either [status is _not_ manifest] OR [journal_year (or journal end year) is gt or eq to 2005 && journal year (or journal end year) is lt or eq to the current year we are testing]
-  current_year = 2014
+  current_year = 2015
   end_year = 0
   incontract = 0
   test_year = ""


aux/sys/cmd/mapr.awk: add pseudo-hashbang for syntax colouring

--- lib/modernish/aux/sys/cmd/mapr.awk
+++ lib/modernish/aux/sys/cmd/mapr.awk
@@ -1,3 +1,5 @@
+#! /modernish/helper/script/for/awk -f
+#
 # awk script belonging to modernish sys/cmd/mapr.mm
 #
 # This converts the input to commands for the shell to 'eval', based


Parser: fix parseJson() for empty objects

--- include/Parser.awk
+++ include/Parser.awk
@@ -275,6 +275,8 @@
         else if (belongsTo(token, commas)) {
             if (isnum(stack[p])) # array
                 stack[p]++ # increase index
+            else # anyway
+                flag = 0 # ready to read key
         } else if (belongsTo(token, colons)) {
             flag = 1 # ready to read value
         } else if (isnum(stack[p]) || flag) {


devtools: fix directory filter in forbidden token check

checkpatches.sh current complains on a patch [1] adding
ALLOW_EXPERIMENTAL_API in an example while this check is for app, lib
and drivers directories:

Warning in examples/ethtool/ethtool-app/Makefile:
Using experimental build flag for in-tree compilation

The regexp on entering files concerned by this filter is incorrect.
In the [1] case, the file full name is matched against "app" rather than
"+++ b/app".

1: https://patchwork.dpdk.org/patch/83902/

Fixes: 7413e7f2aeb3 ("devtools: alert on new calls to exit from libs")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <f28529695cfa9e3e1eb84e7072aa626af4abb18e@redhat.com>

--- devtools/check-forbidden-tokens.awk
+++ devtools/check-forbidden-tokens.awk
@@ -54,7 +54,7 @@
 	}
 	for (i in deny_folders) {
 		re = "^\\+\\+\\+ b/" deny_folders[i];
-		if ($0 ~ deny_folders[i]) {
+		if ($0 ~ re) {
 			in_file = 1
 			last_file = $0
 		}


Remove unnecessary global data variables

--- awk/colortbl.awk
+++ awk/colortbl.awk
@@ -38,7 +38,7 @@
 	v = v * 255.0;
 }

-BEGIN	{ s = ARGV[1]; gsub("\\.","_",s); printf("hsvrgbacolor_t %s[] = {\n",s); }
+BEGIN	{ s = ARGV[1]; gsub("\\.","_",s); printf("static hsvrgbacolor_t %s[] = {\n",s); }
 /^$/	{ next; }
 /^#/	{ next; }
 		{


Simplify toloka.awk

Simplify toloka.awk

--- misc/toloka.awk
+++ misc/toloka.awk
@@ -5,11 +5,15 @@
 }
 NR == 1 {
     for (i=1; i<=NF; i++) ix[$i] = i;
+    next;
 }
-NR > 1 && $ix["found"] {
+!$ix["found"] {
+    next;
+}
+{
     hypernyms[$ix["hypernym"] OFS $ix["genitive"]];
 }
-NR > 1 && $ix["found"] && $ix["hyponym"] != hyponym {
+$ix["hyponym"] != hyponym {
     for (hypernym_genitive in hypernyms) {
         print $ix["hyponym"], hypernym_genitive, "", "";
     }


Removed unused code

Removed unused code

--- jni/scripts/gen_jvalue_go.awk
+++ jni/scripts/gen_jvalue_go.awk
@@ -14,11 +14,6 @@
 	j_to_g_map["jfloat"] = "float32"
 	j_to_g_map["jdouble"] = "float64"
 	j_to_g_map["jobject"] = "JObject"
-
-	# Go to Java Map
-	for (k in j_to_g_map) {
-		g_to_k_map[j_to_g_map[k]] = k
-	}
 }

 function capitalize(s, count) {


Add a layout for the french Apple black usb keyboard (fr.apple). With help from Jean-Marc Harang, thanks!

--- dev/usb/makemap.awk
+++ dev/usb/makemap.awk
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$OpenBSD: makemap.awk,v 1.3 2005/05/12 16:21:24 miod Exp $
+#	$OpenBSD: makemap.awk,v 1.4 2005/05/19 10:40:48 miod Exp $
 #
 # Copyright (c) 2005, Miodrag Vallat
 #
@@ -31,11 +31,12 @@
 #

 BEGIN {
-	rcsid = "$OpenBSD: makemap.awk,v 1.3 2005/05/12 16:21:24 miod Exp $"
+	rcsid = "$OpenBSD: makemap.awk,v 1.4 2005/05/19 10:40:48 miod Exp $"
 	ifdepth = 0
 	ignore = 0
 	declk = 0
 	haskeys = 0
+	kbfr = 0

 	# PS/2 id -> UKBD conversion table, or "sanity lossage 102"
 	# (101 is for GSC keyboards!)
@@ -312,9 +313,21 @@
 		haskeys = 0

 		#
-		# Apple portuguese USB keyboards use a slightly different
-		# layout. We define it here.
+		# Apple black USB keyboards use a slightly different
+		# layout. We define them here.
 		#
+		if (mapname == "ukbd_keydesc_fr[]") {
+			print $0
+			print "\nstatic const keysym_t ukbd_keydesc_fr_apple[] = {"
+			print "    KC(35),\tKS_section,\tKS_6,"
+			print "    KC(37),\tKS_exclam,\tKS_8,"
+			print "    KC(46),\tKS_minus,\tKS_underscore,"
+			print "    KC(48),\tKS_dollar,\tKS_asterisk,"
+			print "    KC(50),\tKS_backslash,\tKS_sterling,"
+			print "    KC(53),\tKS_at,\tKS_numbersign,"
+			print "    KC(56),\tKS_equal,\tKS_plus,"
+			print "    KC(103),\tKS_KP_Equal,"
+		} else
 		if (mapname == "ukbd_keydesc_pt[]") {
 			print $0
 			print "\nstatic const keysym_t ukbd_keydesc_pt_apple[] = {"
@@ -324,8 +337,17 @@
 			print "    KC(50),\tKS_backslash,\tKS_bar,"
 			print "    KC(52),\tKS_dead_tilde,\tKS_dead_circumflex"
 		}
-
 	}
+}
+/KB_FR/ {
+	print $0
+	if (kbfr++ == 0) {
+		print "\tKBD_MAP(KB_FR | KB_APPLE,\tKB_FR,\tukbd_keydesc_fr_apple),"
+	} else {
+		print "\tKBD_MAP(KB_FR | KB_APPLE | KB_SWAPCTRLCAPS,\tKB_FR | KB_APPLE,"
+		print "\t\tukbd_keydesc_swapctrlcaps),"
+	}
+	next
 }
 /KB_PT/ {
 	print $0


seems to function...

seems to function...

--- scripts/distill_dot.awk
+++ scripts/distill_dot.awk
@@ -1,21 +1,68 @@
-#! /usr/bin/awk -f
+#! /usr/bin/gawk -f
 # distill_dot.awk <numbered.gv>  > <filtered_weighted.gv>
 #

 # I have dot files with edge lables that terminate with a number in parens `(nnn)`.
-# the numbers may be simple counts (n > 0) or may be differences [nil neg zero pos ]
-#
+# the numbers may be simple counts (n > 0) or may be differences [nil neg zero pos ]
+#
 # I'm initally intrested in the case where the numbers are a difference
-# and will filter out small differences and colorize/weight larger changes.
+# and will filter out small differences and colorize/weight larger changes.
+#
+# To normalize, will need to read through first then output
+
+BEGIN {hi = -2^PREC; lo = 2^PREC; THRESHOLD = 10}
+
+# there is an unfortunate case where the label contains parens e.g.
+# ZFIN -> LITERAL [label=<dc:title ! title (dce) (30783)>];
+
+# AspGD -> GO [label=<RO:0002331 ! involved in (-12)>, color="pink"];

-BEGIN: {hi=-1000000; lo=1000000}
+/.*label=<.*\(-?[0-9]+\).*;$/{

-# there is an unfortunate case where the label cantains parens e.g.
-# ZFIN -> LITERAL [label=<dc:title ! title (dce) (30783)>];
-# will need to
+    n = split($0, a, /[()]/)
+    # for(i in  a) print a[i]
+    val = a[length(a)-1]
+    sfx = a[length(a)]
+    # print "Val=" val
+    if(val > hi) hi = val
+    if(val < lo) lo = val
+    aval = (val < 0.0) ? -val : val
+    if(aval > THRESHOLD){
+        a[length(a)] = ""
+        a[length(a)-1] = ""
+        key=""
+        for(x in a) key = key a[x]
+        value[key] = val
+        sufix[key] = substr(sfx,2)
+    }
+}

-/^[^ ]+ -> [^ ]+ \[label=<.*([^)]+>.*];$/ {
+# not processed
+!/.*label=<.*\(-?[0-9]+\).*;$/ {
+    pass_on[pss++] = $0
+}

-    #
+END {
+    SCALE =  (hi > -lo)? hi: -lo
+    # Threshold could extended as a fraction of scale ...
+    THRESHOLD =  SCALE / 200
+
+#    if (SCALE < 1){
+#       print "ERROR not to scale: " SCALE
+#        SCALE = 1
+#    }
+
+
+    for(i = 0; i < pss; i++)  # not the last line
+        if( (pass_on[i]!="") && (pass_on[i]!="}")) print pass_on[i]
+
+    for(key in value)   {
+        val = value[key]
+        aval = (val < 0.0) ? -val : val
+        if(aval >= THRESHOLD)
+            print key ">, penwidth = \""(aval/SCALE*5)"\", weight = \"" aval "\"" sufix[key]
+    }
+
+    print "}"
 }


Output whitespace cleanup.

Output whitespace cleanup.

--- src/cloudfront.awk
+++ src/cloudfront.awk
@@ -6,7 +6,11 @@
         split(pairs[j], keyValue, "=")
         k = keyValue[1]
         v = keyValue[2]
-        printf "\t\t\"%s\": \"%s\",\n", k, urlDecode(urlDecode(v))
+        printf "\t\t\t\t\"%s\": \"%s\"", k, urlDecode(urlDecode(v))
+        if (j + 1 < len) {
+            printf ","
+        }
+        printf "\n"
     }
 }

@@ -34,6 +38,7 @@
 }

 END {
+    printf "\n\t]\n"
     print "}"
 }

@@ -45,6 +50,7 @@
     rest = substr($0, length("#Fields: ") + 1)
     split(rest, fields, " ")
     numFields = length(fields)
+    printf "\t\"records\": [\n"
 }

 /^#/ {
@@ -58,7 +64,7 @@
     split($0, fieldsThisLine, " ")
     urlIndex = 0
     if (NF == numFields) {
-        print "\t{"
+        print "\t\t{"
         for(i = 1; i < NF; i++)
         {
             fieldName = fields[i]
@@ -68,18 +74,18 @@
             }
             fieldValue = fieldsThisLine[i]
             maybeDecoded = (fieldName == "cs-uri-query" ? urlDecode(fieldValue) : fieldValue)
-            printf "\t\t\"%s\": \"%s\"", fieldName, fieldValue
+            printf "\t\t\t\"%s\": \"%s\"", fieldName, fieldValue
             if (i + 1 < NF && urlIndex > 0) {
                 printf ","
             }
             printf "\n"
         }
         if (urlIndex > 0) {
-            printf "\t\t\"cs-url-query\": {\n"
+            printf "\t\t\t\"cs-url-query\": {\n"
             printUrlQueryString(fieldsThisLine[urlIndex])
-            printf "}\n"
+            printf "\t\t\t}\n"
         }
-        printf "\t}"
+        printf "\t\t}"
     }
     logLineSeen = 1;
 }


ahrf.awk: Allow _ for paragraphs

ahrf.awk: Allow _ for paragraphs


ahrf.awk: Comment a dirty I wrote (don't remember why...)

--- ahrf.awk
+++ ahrf.awk
@@ -38,7 +38,7 @@
 			printf("%s\n", $c)
 		}
 		# Solve "space" bug! Less crado (gsub).
-		gsub(/^ +/,"",$NF)
+		#gsub(/^ +/,"",$NF)
 		printf("%s
\n", $NF)
 	}
 	next


optimization ;-)

optimization ;-)


Move out edge and node guts into macros.

--- share/bin/plain2mp.awk
+++ share/bin/plain2mp.awk
@@ -65,6 +65,110 @@
 #	print "	fi";
 #	print "enddef;";

+	# TODO: centralise to my equivalent of automata.mp, and include that
+
+	print "vardef fsmnode(expr node, diam, final, lab) =";
+	print "	draw fullcircle scaled diam shifted node withpen pencircle scaled 1bp;"
+	print "	if final:"
+	print "		draw fullcircle scaled (diam - 8bp) shifted node withpen pencircle scaled 1bp;"
+	print "	fi;"
+	print "	if lab <> \"\":"
+	print "		label(lab, node);"
+	print "	fi;"
+	print "enddef;";
+
+
+	print "vardef fsmloop(expr node, diam, p, q, lab, loops) ="
+	print "	path pp; pp = node -- 0.5[p, q];"
+	print "	draw p -- q withpen pencircle scaled 0.5bp withcolor green;"
+	print "	draw 0.5[p, q] withpen pencircle scaled 0.8bp withcolor green;"
+	print "	draw node -- 0.5[p, q] withpen pencircle scaled 0.8bp withcolor green;"
+
+	# extend loop 1.25 * diameter
+	# count number of self-loops for this node, and increment extension
+	print "	l := length pp;"
+	print "	pair m; m := (0.5 + 2 * mlog(loops + 1) / 256) * diam * unitvector(direction l of pp) shifted node;"
+	# u3 = u1 projectedalong u2;
+	print "	draw node -- m withpen pencircle scaled 0.5bp withcolor green;"
+
+	print "	if lab <> \"\":"
+	# TODO: top or bottom, depending on green line direction
+	print "		label.top(lab, m);"
+	print "	fi;"
+
+	print "	path b; b := node .. q .. m .. p .. node;"
+	print "	drawarrow b cutbefore q cutafter p withpen pencircle scaled 1bp;";
+
+	print "enddef;";
+
+	print "vardef fsmgvedge(expr tail, taildiam, head, headdiam, e, lab, lxy, loops) =";
+	print "	draw e withpen pencircle scaled 0.25bp withcolor red;";
+
+	# TODO: better explain this
+	# TODO: explain reversed for q, else we'd find p again, where head == tail
+	print "	path sn; sn := fullcircle scaled headdiam shifted head;" # outline
+	print "	path st; st := fullcircle scaled taildiam shifted tail;" # outline
+	print "	pair p; p = e intersectionpoint sn;\n";
+	print "	pair q; q = (reverse e) intersectionpoint st;\n";
+
+	print "	if head = tail:"
+	print "		fsmloop(head, headdiam, p, q, lab, loops);"
+	print "	else:"
+
+	print "		path b; b = tail .. q .. p .. head;"
+
+	# TODO: explain this. we permit a 2% lengthening threshold relative to graphviz's b-spline
+	# this affects NFA especially
+	print "		r := arclength b / arclength e;";
+	print "		boolean g; g := (r > 1.02) or (r < 0.93);"; # XXX: or (arclength b > 6in);"; - no, wigglyness instead
+
+	print "		if g:"
+	print "			b := e;"
+	print "		fi;"
+
+	print "		if lab <> \"\":"
+	print "			pair bl;";
+	print "			pair ml; ml := .5[tail, head];"
+
+	# TODO: new idea; draw right angle from midpoint, and use that to find intersection with b
+	# this way it should always align for multiple edges, even if on a slant
+
+	print "			draw lxy withpen pencircle scaled 5bp withcolor red;"
+	print "			draw point (length b / 2) of b withpen pencircle scaled 4bp withcolor blue;"
+#	print "			draw tail -- head withpen pencircle scaled 1bp withcolor green;"
+#	print "			draw ml withpen pencircle scaled 5bp withcolor green;"
+
+	print "			if g:"
+	print "				bl := lxy;"
+	print "			else:"
+	print "				bl := point (length b / 2) of b;"
+	print "			fi;"
+
+	# TODO: plus label delta, distancing it from point. make a label function
+	# TODO: maybe an "extend" function, to extend a path in its direction. use dotprod for that?
+
+	# lft | rt | top | bot | ulft | urt | llft | lrt
+	# labels ought to be below, if they're below the straight line from head-tail, or above otherwise
+	# TODO: round label coordinates to grid? quantize rather
+
+	# XXX: if using graphviz's point, label exactly on the spot
+	print "			if g:";
+	# TODO: still want to distance by +/- 4bp or so
+	print "				label(lab, bl);"
+	print "			else:"
+	print "				if ypart bl < ypart ml:" # TODO: threshold for considering "below"
+	print "					label.bot(lab, bl shifted (0, -3bp));"
+	print "				else:"
+	print "					label.top(lab, bl shifted (0, +3bp));"
+	print "				fi;"
+	print "			fi;"
+	print "		fi;"
+
+	print "	drawarrow b cutbefore q cutafter p withpen pencircle scaled 1bp;";
+
+	print "	fi;"
+
+	print "enddef;";
 }

 /^graph / {
@@ -84,9 +188,9 @@
 	shape  = $9;
 	# TODO: label delimited by <>, may contain spaces

+	# TODO: quantise node positions
+	printf "\t%s := (%fin, %fin);\n", name, x, y
 	printf "\t%s.loops := 0;\n", name
-
-	printf "\t%s := (%fin, %fin);\n", name, x, y

 # TODO: when plotting in graphviz, assume all nodes have the same width (not zero!). enough for "SXX" perhaps
 # that should align them all on the same centre line. and pass fixedsize=true
@@ -97,25 +201,16 @@
 # ignore graphviz height and width, because it scales with label width and that looks bad for S1 vs S5
 	diam = 0.3 + length(label) * 0.05;

-	if (shape == "doublecircle") {
+	final = shape == "doublecircle";
+
+	if (final) {
 		printf "\t%s.diam = %fin + 8bp;\n", name, diam;
 	} else {
 		printf "\t%s.diam = %fin;\n", name, diam;
 	}

-	if (shape == "doublecircle") {
-# TODO: would rather && together paths to %s.n or somesuch
-		printf "\tdraw fullcircle scaled (%s.diam - 8bp) shifted %s withpen pencircle scaled 1bp;\n", name, name
-	}
-
-	printf "\t%s.n := fullcircle scaled %s.diam shifted %s;\n", name, name, name
-
 	if ($2 != "start") {
-		printf "\tdraw %s.n withpen pencircle scaled 1bp;\n", name
-
-		if (label != "") {
-			printf "\tlabel(\"%s\", %s);\n", label, name
-		}
+		printf "\tfsmnode(%s, %s.diam, %s, \"%s\");\n", name, name, final ? "true" : "false", label
 	}
 }

@@ -167,13 +262,6 @@
 		printf "\t(%fin, %fin);\n", ox, oy;
 	}

-	printf "\tdraw e withpen pencircle scaled 0.25bp withcolor red;\n";
-
-	# TODO: better explain this
-	# TODO: explain reversed for q, else we'd find p again, where head == tail
-	printf "pair p; p = e intersectionpoint %s.n;\n", head;
-	printf "pair q; q = (reverse e) intersectionpoint %s.n;\n", tail;
-
 	# XXX: assuming no space in label
 label = slabel(a[n * 2 + 5]);
 lx    = (a[n * 2 + 6]);
@@ -183,81 +271,11 @@
 		label = "";
 	}

+	printf "fsmgvedge(%s, %s.diam, %s, %s.diam, e, \"%s\", (%fin, %fin), %s.loops);", tail, tail, head, head, label, lx, ly, head;
+
 	if (head == tail) {
-		printf "path pp; pp = %s -- 0.5[p, q];\n", head;
-printf "draw p -- q withpen pencircle scaled 0.5bp withcolor green;\n";
-printf "draw 0.5[p, q] withpen pencircle scaled 0.8bp withcolor green;\n";
-printf "draw %s -- 0.5[p, q] withpen pencircle scaled 0.8bp withcolor green;\n", head;
-
-		# extend loop 1.25 * diameter
-		# count number of self-loops for this node, and increment extension
-		printf "\t%s.loops := %s.loops + 1;", head, head
-		print "l := length pp;"
-		printf "\tpair m; m := (0.5 + 2 * mlog(%s.loops + 1) / 256) * %s.diam * unitvector(direction l of pp) shifted %s;\n", head, head, head
-# u3 = u1 projectedalong u2;
-		printf "\tdraw %s -- m withpen pencircle scaled 0.5bp withcolor green;\n", head
-
-		printf "\tpath b; b = %s .. q .. m .. p .. %s;\n", tail, head;
-
-		if (label != "") {
-			# TODO: top or bottom, depending on green line direction
-			printf "\tlabel.top(\"%s\", m);\n", slabel(label)
-		}
-	} else {
-		printf "\tpath b; b = %s .. q .. p .. %s;\n", tail, head;
-
-		# TODO: explain this. we permit a 2% lengthening threshold relative to graphviz's b-spline
-		# this affects NFA especially
-		print "\tr := arclength b / arclength e;\n";
-		print "\tboolean g; g := (r > 1.02) or (r < 0.93);"; # XXX: or (arclength b > 6in);"; - no, wigglyness instead
-
-		print "\tif g:";
-		print "\t\tb := e;";
-		print "\tfi;";
-
-# if it wouldn't have been a straight line, go via the label point instead:
-# XXX: this idea doesn't work, because i don't know which side of the line the label point would be on
-#printf "\t\tb := %s .. q .. (%fin, %fin) .. p .. %s;\n", tail, lx, ly, head;
-
-		if (label != "") {
-			printf "\tpair bl;\n";
-			printf "\tpair ml; ml := .5[%s, %s];\n", tail, head;
-
-# TODO: new idea; draw right angle from midpoint, and use that to find intersection with b
-# this way it should always align for multiple edges, even if on a slant
-
-printf "draw (%fin, %fin) withpen pencircle scaled 5bp withcolor red;\n", lx, ly
-printf "draw point (length b / 2) of b withpen pencircle scaled 4bp withcolor blue;\n"
-#printf "draw %s -- %s withpen pencircle scaled 1bp withcolor green;\n", tail, head
-#printf "draw ml withpen pencircle scaled 5bp withcolor green;\n"
-
-			print "\tif g:";
-				printf "\t\tbl := (%fin, %fin);", lx, ly;
-			print "\telse:";
-				printf "\t\tbl := point (length b / 2) of b;\n";
-			print "\tfi;";
-
-# TODO: plus label delta, distancing it from point. make a label function
-# TODO: maybe an "extend" function, to extend a path in its direction. use dotprod for that?
-
-			# lft | rt | top | bot | ulft | urt | llft | lrt
-			# labels ought to be below, if they're below the straight line from head-tail, or above otherwise
-			# TODO: round label coordinates to grid? quantize rather
-# XXX: if using graphviz's point, label exactly on the spot
-print "\tif g:";
-# TODO: still want to distance by +/- 4bp or so
-			printf "\t\tlabel(\"%s\", bl);\n", label
-print "\telse:";
-			printf "\tif ypart bl < ypart ml:\n" # TODO: threshold for considering "below"
-			printf "\t\tlabel.bot(\"%s\", bl shifted (0, -3bp));\n", label
-			printf "\telse:\n"
-			printf "\t\tlabel.top(\"%s\", bl shifted (0, +3bp));\n", label
-			printf "\tfi;\n"
-print "\tfi;";
-		}
-	}
-
-	printf "drawarrow b cutbefore q cutafter p withpen pencircle scaled 1bp;\n";
+		print "	%s.loops := %s.loops + 1;", head, head
+	}
 }

 /^stop$/ {


(minor) fix symbol table gen script

(minor) fix symbol table gen script


Fix from Aero.  Note that this file is depercated, but for the record...

--- tmcd/linux/chipset.awk
+++ tmcd/linux/chipset.awk
@@ -31,6 +31,11 @@
     found = 1;
     exit
 }
+/^[ ]+PCI bridge: Intel Corp.*HI_C Virtual PCI-to-PCI Bridge/ {
+    print "HI_C";
+    found = 1;
+    exit
+}
 /^[ ]+PCI bridge: Intel Corp.*HI_B Virtual PCI-to-PCI Bridge/ {
     print "HI_B";
     found = 1;


updated makemega addstats to go with latest stats;

--- CPU/common/makemega_addstats.awk
+++ CPU/common/makemega_addstats.awk
@@ -26,24 +26,30 @@
 # Juicer version 1.5
 $1=="Sequenced"{
 gsub(/,/,"",$4);
- total=total+$4;
+ tot=tot+$4;
 }
 $1=="Unmapped:"{
 gsub(/,/,"",$2);
- unmapped=unmapped+$2
+ unm=unm+$2
 }
 $1=="Normal"{
 gsub(/,/,"",$3);
- regular=regular+$3}
+ norm=norm+$3}
 $1=="Chimeric" && $2=="Paired:"{
 gsub(/,/,"",$3);
- normal=normal+$3}
-$2=="Ambiguous:"{
+ chim=chim+$3}
+$1=="MAPQ" && $2=="0:"{
 gsub(/,/,"",$3);
- abnorm=abnorm+$3}
-$1=="Alignable"{
+ mapq0=mapq0+$3}
+$1=="Collisions:"{
+gsub(/,/,"",$2);
+ coll=coll+$2}
+$3=="Collisions:"{
 gsub(/,/,"",$4);
- alignable=alignable+$4}
+ lowc=lowc+$4}
+$1=="Ligation" {
+gsub(/,/,"",$4);
+ lig=lig+$4}
 $1=="Unique" {
 gsub(/,/,"",$3);
  dedup=dedup+$3}
@@ -54,13 +60,5 @@
 gsub(/,/,"",$3);
  optdups=optdups+$3}
 END{
- printf("%s %'d\n", "Sequenced Read Pairs:", total);
- printf(" %s %'d (%0.2f%)\n", "Normal Paired:", regular, regular*100/total);
- printf(" %s %'d (%0.2f%)\n", "Chimeric Paired:", normal, normal*100/total);
- printf(" %s %'d (%0.2f%)\n", "Chimeric Ambiguous:", abnorm, abnorm*100/total);
- printf(" %s %'d (%0.2f%)\n", "Unmapped:", unmapped, unmapped*100/total);
- printf(" %s %'d (%0.2f%)\n", "Alignable (Normal+Chimeric Paired):", alignable, alignable*100/total);
- printf("%s %'d\n", "Unique Reads:", dedup);
- printf("%s %'d\n", "PCR Duplicates:", dups);
-  printf("%s %'d\n", "Optical Duplicates:", optdups);
+  printf("Sequenced Read Pairs:  %'d\n Normal Paired: %'d (%0.2f%)\n Chimeric Paired: %'d (%0.2f%)\n Collisions: %'d (%0.2f%)\n Low MAPQ Collisions: %'d (%0.2f%)\n Unmapped: %'d (%0.2f%)\n MAPQ 0: %'d (%0.2f%)\n Ligation Motif Present: %'d (%0.2f%)\nAlignable (Normal+Chimeric Paired): %'d (%0.2f%)\n Unique Reads: %'d\n PCR Duplicates: %'d\n Optical Duplicates: %'d\n", tot, norm, norm*100/tot, chim, chim*100/tot, coll, coll*100/tot, lowc, lowc*100/tot, unm, unm*100/tot, mapq0, mapq0*100/tot, lig, lig*100/tot, norm+chim, (norm+chim)*100/tot, dedup, dups, optdups );
 }


remove todo

remove todo

--- lib/render.awk
+++ lib/render.awk
@@ -108,7 +108,6 @@
 }

 function run_filter(cmd, txt,   rand_date, tmpfile, rendered_txt, date_cmd, markdown_cmd, line) {
-  # TODO use mktemp instead
   date_cmd = "date +%Y%m%d%H%M%S"
   date_cmd | getline rand_date
   close(date_cmd)


Clarify that input must be sorted

Clarify that input must be sorted

--- tools/awk/median.awk
+++ tools/awk/median.awk
@@ -5,7 +5,7 @@
 # Usage: median
 #
 # Input:
-#   - a column of numbers
+#   - a sorted column of numbers
 #
 # Output:
 #   - median value


multiline whitespace fix: do not offer "PICK LINE" again after it has been run

--- src/port.default.awk
+++ src/port.default.awk
@@ -20,7 +20,7 @@
 func pick_line(s) {
     s = collapse(s)
     c = btick(nest(s, "menu"))
-    runHook(nest(c))
+    runHook(nest(trim(c)))
 }
 # this is a hack to reclassify full line, see main.head.awk:
 func merge_lines(s) {


build -target=awk: use a different shebang for OS X

--- build.awk
+++ build.awk
@@ -28,7 +28,7 @@
 }

 # Task: build
-function build(target,    group, inline, line) {
+function build(target,    group, inline, line, temp) {
     # Default target: bash
     if (!target) target = "bash"

@@ -77,6 +77,8 @@

     } else if (target == "awk" || target == "gawk") {

+        "uname -s" | getline temp
+
         if (fileExists(EntryPoint))
             while (getline line < EntryPoint) {
                 match(line, /^[[:space:]]*@include[[:space:]]*"(.*)"$/, group)
@@ -86,7 +88,11 @@
                         while (getline inline < (group[1] ".awk"))
                             print inline > Trans".awk"
                 } else {
-                    print line > Trans".awk"
+                    if (temp == "Darwin" && line == "#!/usr/bin/gawk -f")
+                        # OS X: gawk not in /usr/bin, use a better shebang
+                        print "#!/usr/bin/env gawk -f" > Trans".awk"
+                    else
+                        print line > Trans".awk"
                 }
             }


Languages: mark as stable: Kyrgyz

Languages: mark as stable: Kyrgyz

--- include/Languages.awk
+++ include/Languages.awk
@@ -166,15 +166,14 @@
     Locale["rw"]["glotto"]             = "kiny1244"
     Locale["rw"]["script"]             = "Latn"

-    #? Kyrgyz
-    Locale["ky"]["support"]            = "unstable"
+    # Kyrgyz
     Locale["ky"]["name"]               = "Kyrgyz"
     Locale["ky"]["endonym"]            = "Кыргызча"
-    #Locale["ky"]["translations-of"]
-    #Locale["ky"]["definitions-of"]
-    #Locale["ky"]["synonyms"]
-    #Locale["ky"]["examples"]
-    #Locale["ky"]["see-also"]
+    Locale["ky"]["translations-of"]    = "%s котормосу"
+    Locale["ky"]["definitions-of"]     = "%s аныктамасы"
+    Locale["ky"]["synonyms"]           = "Синонимдер"
+    Locale["ky"]["examples"]           = "Мисалдар"
+    Locale["ky"]["see-also"]           = "Дагы караңыз"
     Locale["ky"]["family"]             = "Turkic"
     Locale["ky"]["iso"]                = "kir"
     Locale["ky"]["glotto"]             = "kirg1245"


Languages: mark as stable: Hawaiian

Languages: mark as stable: Hawaiian

--- include/Languages.awk
+++ include/Languages.awk
@@ -475,8 +475,7 @@
     Locale["chr"]["glotto"]            = "cher1273"
     Locale["chr"]["script"]            = "Cher"

-    #? Hawaiian
-    Locale["haw"]["support"]           = "unstable"
+    # Hawaiian
     Locale["haw"]["name"]              = "Hawaiian"
     Locale["haw"]["endonym"]           = "ʻŌlelo Hawaiʻi"
     #Locale["haw"]["translations-of"]


Translate: fix play() with placeholder parameter "&tk"

--- include/Translate.awk
+++ include/Translate.awk
@@ -93,7 +93,7 @@
 # Play using Google Text-to-Speech engine.
 function play(text, tl,    url) {
     url = HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=t"	\
-        "&tl=" tl "&q=" preprocess(text)
+        "&tl=" tl "&tk" "&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"] " " parameterize(url) SUPOUT SUPERR)


added comment

added comment


Fix test output formatter

Fix test output formatter

The test output script was not handling the reformat correctly. As a
result, some tests fail with Lua51 due to some stack message not
correctly processed by this script.


Simplify prefix injection code

Simplify prefix injection code


Arbitrary fields are now handled by the line 1 edit! v1.0 released!

--- deshellswebshellsbytheseashore.awk
+++ deshellswebshellsbytheseashore.awk
@@ -1,15 +1,15 @@
 #!/bin/awk
+#v1.0, Authored by David Cunningham

 BEGIN { FS = "\\?><"; bound = 3}
 {
   #If line matches shell pattern, and is on the first line, and contains only webshell fields (as seen in every example), clear the line..
   if($0 ~ /<\?php if\(!isset\(\$GLOBALS\[\"\\x61\\156\\x75\\156\\x61\"\]\)\).*\$GLOBALS\[\"\\x61\\156\\x75\\156\\x61\"\]=1\; \} \?><\?php.*?>/ && NR == 1 && NF < 3)
     {print "======\n""Removed line 1, as it was all shellcode:",FILENAME,". See diff for changes.\n======" >> "/root/audit/run.log"}
-# print "bliggablau" > FILENAME".tmp"}
   #If line matches shell pattern, and is on the first line, modify the file in place, and log what was changed.
   else if($0 ~ /<\?php if\(!isset\(\$GLOBALS\[\"\\x61\\156\\x75\\156\\x61\"\]\)\).*\$GLOBALS\[\"\\x61\\156\\x75\\156\\x61\"\]=1\; \} \?><\?php.*?>/ && NR == 1 && NF >= 3)
     {print "======\n""Removed shellcode from line 1:",FILENAME,". See diff for changes.\n======" >> "/root/audit/run.log";
-      for(i=bound; i<=NF; i++) printf("%s%s%s","<", $(i), i<NF ? OFS : "\n") > FILENAME".tmp" }
+      for(i=bound; i<=NF; i++) printf("%s%s%s%s","<", $(i), i<NF ? OFS : "\n", i<NF ? i>bound ? "?>": "" : "") > FILENAME".tmp" }
   #If line matches shell pattern, but is not on the first line, just log it.
   else if($0 ~ /<\?php if\(!isset\(\$GLOBALS\[\"\\x61\\156\\x75\\156\\x61\"\]\)\).*\$GLOBALS\[\"\\x61\\156\\x75\\156\\x61\"\]=1\; \} \?><\?php.*?>/)
     { print "======\n""Found additional shellcode, logging only:",FILENAME,", line",NR".\n\nShellcode is:", $0"\n======" >> "/root/audit/run.log"; print $0> FILENAME".tmp"}


Translators/SpellChecker: allow to specify aspell or hunspell

--- include/Translators/SpellChecker.awk
+++ include/Translators/SpellChecker.awk
@@ -1,15 +1,33 @@
 ####################################################################
 # SpellChecker.awk                                                 #
 ####################################################################
-BEGIN { provides("spell") }
+BEGIN {
+    provides("spell")
+    provides("aspell")
+    provides("hunspell")
+}

-# Detect external spell checker.
+# Detect external (ispell -a compatible) spell checker.
 function spellInit() {
     Ispell = detectProgram("aspell", "--version") ? "aspell" :
         (detectProgram("hunspell", "--version") ? "hunspell" : "")

     if (!Ispell) {
         e("[ERROR] Spell checker (aspell or hunspell) not found.")
+        exit 1
+    }
+}
+
+function aspellInit() {
+    if (!(Ispell = detectProgram("aspell", "--version") ? "aspell" : "")) {
+        e("[ERROR] Spell checker (aspell) not found.")
+        exit 1
+    }
+}
+
+function hunspellInit() {
+    if (!(Ispell = detectProgram("hunspell", "--version") ? "hunspell" : "")) {
+        e("[ERROR] Spell checker (hunspell) not found.")
         exit 1
     }
 }
@@ -49,3 +67,13 @@
     r = r substr(text, i)
     return r
 }
+
+function aspellTranslate(text, sl, tl, hl,
+                         isVerbose, toSpeech, returnPlaylist, returnIl) {
+    return spellTranslate(text, sl, tl, hl)
+}
+
+function hunspellTranslate(text, sl, tl, hl,
+                           isVerbose, toSpeech, returnPlaylist, returnIl) {
+    return spellTranslate(text, sl, tl, hl)
+}


LanguageData: update section P

LanguageData: update section P

--- include/LanguageData.awk
+++ include/LanguageData.awk
@@ -1775,9 +1775,23 @@
     Locale["om"]["spoken-in"]          = "the Ethiopian state of Oromia; northeastern Kenya"
     Locale["om"]["supported-by"]       = "google"

-
-
-    #70 Pashto / Pushto
+    # Papiamento
+    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"]["branch"]            = "Portuguese Creole"
+    Locale["pap"]["iso"]               = "pap"
+    Locale["pap"]["glotto"]            = "papi1253"
+    Locale["pap"]["script"]            = "Latn"
+    Locale["pap"]["spoken-in"]         = "the Dutch Caribbean"
+    Locale["pap"]["supported-by"]      = "yandex"
+
+    # Pashto / Pushto
     Locale["ps"]["name"]               = "Pashto"
     Locale["ps"]["name2"]              = "Pushto"
     Locale["ps"]["endonym"]            = "پښتو"
@@ -1787,12 +1801,15 @@
     Locale["ps"]["examples"]           = "بېلګې"
     Locale["ps"]["see-also"]           = "دا هم ووینئ"
     Locale["ps"]["family"]             = "Indo-European"
+    Locale["ps"]["branch"]             = "Iranian"
     Locale["ps"]["iso"]                = "pus"
     Locale["ps"]["glotto"]             = "pash1269"
     Locale["ps"]["script"]             = "Arab"
     Locale["ps"]["rtl"]                = "true" # RTL language
-
-    #71 Persian / Farsi (Western Farsi / Iranian Persian)
+    Locale["ps"]["spoken-in"]          = "Afghanistan; Pakistan"
+    Locale["ps"]["supported-by"]       = "google; bing"
+
+    # Persian / Farsi (Western Farsi / Iranian Persian)
     Locale["fa"]["name"]               = "Persian"
     Locale["fa"]["name2"]              = "Farsi"
     Locale["fa"]["endonym"]            = "فارسی"
@@ -1802,12 +1819,15 @@
     Locale["fa"]["examples"]           = "مثال‌ها"
     Locale["fa"]["see-also"]           = "همچنین مراجعه کنید به"
     Locale["fa"]["family"]             = "Indo-European"
+    Locale["fa"]["branch"]             = "Iranian"
     Locale["fa"]["iso"]                = "fas"
     Locale["fa"]["glotto"]             = "west2369"
     Locale["fa"]["script"]             = "Arab"
     Locale["fa"]["rtl"]                = "true" # RTL language
-
-    #72 Polish
+    Locale["fa"]["spoken-in"]          = "Iran"
+    Locale["fa"]["supported-by"]       = "google; bing; yandex"
+
+    # Polish
     Locale["pl"]["name"]               = "Polish"
     Locale["pl"]["endonym"]            = "Polski"
     Locale["pl"]["translations-of"]    = "Tłumaczenia %s"
@@ -1816,11 +1836,14 @@
     Locale["pl"]["examples"]           = "Przykłady"
     Locale["pl"]["see-also"]           = "Zobacz też"
     Locale["pl"]["family"]             = "Indo-European"
+    Locale["pl"]["branch"]             = "West Slavic"
     Locale["pl"]["iso"]                = "pol"
     Locale["pl"]["glotto"]             = "poli1260"
     Locale["pl"]["script"]             = "Latn"
-
-    #73 Portuguese (Brazilian)
+    Locale["pl"]["spoken-in"]          = "Poland"
+    Locale["pl"]["supported-by"]       = "google; bing; yandex"
+
+    # Portuguese (Brazilian)
     Locale["pt-BR"]["name"]            = "Portuguese (Brazilian)"
     Locale["pt-BR"]["endonym"]         = "Português Brasileiro"
     Locale["pt-BR"]["translations-of"] = "Traduções de %s"
@@ -1829,12 +1852,31 @@
     Locale["pt-BR"]["examples"]        = "Exemplos"
     Locale["pt-BR"]["see-also"]        = "Veja também"
     Locale["pt-BR"]["family"]          = "Indo-European"
+    Locale["pt-BR"]["branch"]          = "Western Romance"
     Locale["pt-BR"]["iso"]             = "por"
     Locale["pt-BR"]["glotto"]          = "braz1246"
     Locale["pt-BR"]["script"]          = "Latn"
     Locale["pt-BR"]["dictionary"]      = "true" # has dictionary
-
-    #74 Punjabi, Gurmukhī alphabet
+    Locale["pt-BR"]["spoken-in"]       = "Portugal; Brazil; Cape Verde; Angola; Mozambique; Guinea-Bissau; Equatorial Guinea; São Tomé and Príncipe; East Timor; Macau"
+    Locale["pt-BR"]["supported-by"]    = "google; bing; yandex"
+
+    # Portuguese (European)
+    Locale["pt-PT"]["name"]            = "Portuguese (European)"
+    Locale["pt-PT"]["endonym"]         = "Português Europeu"
+    Locale["pt-PT"]["translations-of"] = "Traduções de %s"
+    Locale["pt-PT"]["definitions-of"]  = "Definições de %s"
+    Locale["pt-PT"]["synonyms"]        = "Sinônimos"
+    Locale["pt-PT"]["examples"]        = "Exemplos"
+    Locale["pt-PT"]["see-also"]        = "Veja também"
+    Locale["pt-PT"]["family"]          = "Indo-European"
+    Locale["pt-PT"]["branch"]          = "Western Romance"
+    Locale["pt-PT"]["iso"]             = "por"
+    Locale["pt-PT"]["glotto"]          = "port1283"
+    Locale["pt-PT"]["script"]          = "Latn"
+    Locale["pt-PT"]["spoken-in"]       = "Portugal; Brazil; Cape Verde; Angola; Mozambique; Guinea-Bissau; Equatorial Guinea; São Tomé and Príncipe; East Timor; Macau"
+    Locale["pt-PT"]["supported-by"]    = "bing"
+
+    # Punjabi, Gurmukhī alphabet
     Locale["pa"]["name"]               = "Punjabi"
     Locale["pa"]["endonym"]            = "ਪੰਜਾਬੀ"
     Locale["pa"]["translations-of"]    = "ਦੇ ਅਨੁਵਾਦ%s"
@@ -1843,9 +1885,14 @@
     Locale["pa"]["examples"]           = "ਉਦਾਹਰਣਾਂ"
     Locale["pa"]["see-also"]           = "ਇਹ ਵੀ ਵੇਖੋ"
     Locale["pa"]["family"]             = "Indo-European"
+    Locale["pa"]["branch"]             = "Indo-Aryan"
     Locale["pa"]["iso"]                = "pan"
     Locale["pa"]["glotto"]             = "panj1256"
     Locale["pa"]["script"]             = "Guru"
+    Locale["pa"]["spoken-in"]          = "the Punjab region of India and Pakistan"
+    Locale["pa"]["supported-by"]       = "google; bing; yandex"
+
+

     # Quechua
     Locale["qu"]["name"]               = "Quechua"
@@ -2395,20 +2442,6 @@
     Locale["zu"]["glotto"]             = "zulu1248"
     Locale["zu"]["script"]             = "Latn"

-    #* Portuguese (European)
-    Locale["pt-PT"]["support"]         = "bing-only"
-    Locale["pt-PT"]["name"]            = "Portuguese (European)"
-    Locale["pt-PT"]["endonym"]         = "Português Europeu"
-    Locale["pt-PT"]["translations-of"] = "Traduções de %s"
-    Locale["pt-PT"]["definitions-of"]  = "Definições de %s"
-    Locale["pt-PT"]["synonyms"]        = "Sinônimos"
-    Locale["pt-PT"]["examples"]        = "Exemplos"
-    Locale["pt-PT"]["see-also"]        = "Veja também"
-    Locale["pt-PT"]["family"]          = "Indo-European"
-    Locale["pt-PT"]["iso"]             = "por"
-    Locale["pt-PT"]["glotto"]          = "port1283"
-    Locale["pt-PT"]["script"]          = "Latn"
-
     #* Querétaro Otomi
     Locale["otq"]["support"]           = "bing-only"
     Locale["otq"]["name"]              = "Querétaro Otomi"
@@ -2472,20 +2505,6 @@
     Locale["oc"]["iso"]                = "oci"
     Locale["oc"]["glotto"]             = "occi1239"
     Locale["oc"]["script"]             = "Latn"
-
-    #? 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"


update slice.awk

update slice.awk


Languages: add Cherokee script

Languages: add Cherokee script

--- include/Languages.awk
+++ include/Languages.awk
@@ -1774,6 +1774,7 @@
     case "Arab": return "Arabic"
     case "Armn": return "Armenian"
     case "Beng": return "Bengali"
+    case "Cher": return "Cherokee"
     case "Cyrl": return "Cyrillic"
     case "Deva": return "Devanagari"
     case "Ethi": return "Ethiopic (Geʻez)"


Translators/GoogleTranslate: strip whitespace before punctuation mark

--- include/Translators/GoogleTranslate.awk
+++ include/Translators/GoogleTranslate.awk
@@ -373,6 +373,8 @@

                     temp = prettify("original-dictionary-examples-example", ins(1, "- "))
                     split(example, group, /(<b>|<\/b>)/)
+                    if (group[3] ~ / [[:punct:].]/)
+                        group[3] = substr(group[3], 2)
                     if (isRTL(il)) # target language is R-to-L
                         temp = temp show(group[1] group[2] group[3], il)
                     else # target language is L-to-R


PP-648: sgigenvnodelist.awk fails on SLES 12 and RHEL 7

--- src/cmds/scripts/sgigenvnodelist.awk
+++ src/cmds/scripts/sgigenvnodelist.awk
@@ -93,6 +93,9 @@
 #	that belong to CPU sets not claimed by PBS.

 BEGIN {
+	# Sort cpus, mems, and vnodes numerically
+	PROCINFO["sorted_in"] = "@ind_num_asc";
+
 	nas_mode = 0;			#	enable NAS mod 80
 	deftype = "m";			#	by default, output for pbs_mom
 	exitval = 0;			#	used to elide END actions
@@ -111,8 +114,11 @@
 	#	command to find "cpus" and "mems" files that do not belong to
 	#	PBS (CPU sets that are not the root, and not under /PBSPro)
 	#	in the "cpuset" file system
-	findcmd = "find /dev/cpuset -name cpus -print -o -name mems -print | \
-		egrep -v '/dev/cpuset/cpus|/dev/cpuset/mems|/PBSPro/'";
+	findcmd = "find /dev/cpuset -name cpus -o -name cpuset.cpus \
+		-o -name mems -o -name cpuset.mems | \
+		egrep -v -e '/dev/cpuset/cpus$' -e '/dev/cpuset/cpuset.cpus$' \
+		-e '/dev/cpuset/mems$' -e '/dev/cpuset/cpuset.mems$' \
+		-e '/PBSPro/'";

 	topology_version_min = 1;	#	the versions we understand
 	topology_version_max = 2;	#	the versions we understand
@@ -299,11 +305,11 @@
 {
 	if (debug)
 		printf("read_excludelist:  listfile %s\n", listfile);
-	if (listfile ~ "/cpus$") {
+	if (listfile ~ "/cpus$" || listfile ~ "/cpuset.cpus$") {
 		while ((getline cpumemlist < listfile) > 0)
 			parse_CPUs(cpumemlist);
 		close(listfile);
-	} else if (listfile ~ "/mems$") {
+	} else if (listfile ~ "/mems$" || listfile ~ "/cpuset.mems$") {
 		while ((getline cpumemlist < listfile) > 0)
 			parse_mems(cpumemlist);
 		close(listfile);


Add Diversion as valid SIP header

Add Diversion as valid SIP header

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

--- scripts/long2html.awk
+++ scripts/long2html.awk
@@ -168,6 +168,7 @@
       if ($1 ~ "Content-Type:" ) MARK = "sip"
       if ($1 ~ "CSeq:" ) MARK = "sip"
       if ($1 ~ "Date:" ) MARK = "sip"
+      if ($1 ~ "Diversion:" ) MARK = "sip"
       if ($1 ~ "Expires:" ) MARK = "sip"
       if ($1 ~ "From:" ) MARK = "sip"
       if ($1 ~ "Max-Forwards:" ) MARK = "sip"


print raw strings in hinter ( avoids interpreting %s within matches )

--- scripts/hinter.awk
+++ scripts/hinter.awk
@@ -111,7 +111,7 @@
           token = sprintf(compound_format, token, hint);
       }

-      printf token
+      printf "%s", token
     }

     if (line_index < n_lines - 1) {


Languages: fix Wikipedia link for Serbian

--- include/Languages.awk
+++ include/Languages.awk
@@ -1885,7 +1885,8 @@
     split(getISO(code), group, "-")
     iso = group[1]
     split(getName(code), group, " ")
-    language = length(group) == 1 ? group[1] "_language" : join(group, "_")
+    language = length(group) == 1 ? group[1] "_language" :
+        group[2] ~ /^\(.*\)$/ ? group[1] "_language" : join(group, "_")
     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)))   \