interp_utils.awk	-- down to actually interpolating the vectors

--- lib/interp_utils.awk
+++ lib/interp_utils.awk
@@ -1,4 +1,4 @@
-function IU_init(config, interp, name, k_values, k_breaks,   work, n_ary, ary, c_rng, i, nv) {
+function IU_init(config, interp, name, k_values, k_breaks,   work, n_ary, ary, c_rng, i, nv, v_pat) {

 	interp["name"] = name

@@ -11,22 +11,19 @@
 	nv = n_ary = split(work, ary, "|")
 	interp["nvalues"] = n_ary
 	c_rng = 0
+	v_ob_info = ""
 	for(i = 1; i <= n_ary; i++){
 		work = ary[i]
-		if(index(work, ":") != 0)
+		if(index(work, ":") != 0){
 			c_rng++
+			v_pat = v_pat "g"
+		}else
+			v_pat = v_pat "b"
 		sub(/^[ \t]*/, "", work)
 		sub(/[ \t]*$/, "", work)
 		interp["values", i] = work
 	}
-	if(c_rng == 0)
-		interp["is_grad"] = 0
-	else if(c_rng == n_ary)
-		interp["is_grad"] = 1
-	else{
-		printf("ERROR: IU_init: k_values can not include both gradient and bin values\n") > "/dev/stderr"
-		return 1
-	}
+	interp["is_grad"] = c_rng > 0

 	# get the breaks
 	work = config["_globals", k_breaks]
@@ -42,8 +39,32 @@
 		sub(/[ \t]*$/, "", work)
 		interp["breaks", i] = work + 0	# force numeric
 	}
-	if(interp["nbreaks"] != interp["nvalues"] - 1){
-		printf("ERROR: IU_init: nbreaks (%d) != nvalues - 1 (%d)\n", interp["nbreaks"], interp["nvalues"] - 1) > "/dev/stderr"
+	if(!interp["is_grad"]){
+		if(interp["nbreaks"] != interp["nvalues"] - 1){
+			printf("ERROR: IU_init: nbreaks (%d) != nvalues - 1 (%d)\n", interp["nbreaks"], interp["nvalues"] - 1) > "/dev/stderr"
+			return 1
+		}
+	}else if(interp["nbreaks"] == interp["nvalues"] + 1){
+		if(!match(v_pat, /^gg*$/)){
+			printf("ERROR: IU_init: nbreaks (%d) = nvalues + 1 (%d): all values must be gradients\n", interp["nbreaks"], interp["nvalues"] + 1) > "/dev/stderr"
+			return 1
+		}
+		interp["v_ob_info"] = ""
+	}else if(interp["nbreaks"] == interp["nvalues"]){
+		if(!match(v_pat, /^bgg*$/) && !match(v_pat, /^gg*b$/)){
+			printf("ERROR: IU_init: nbreaks (%d) = nvalues (%d): All but first or last, but not both  values must grad\n", inter["nbreaks"], interp["nvalues"]) > "/dev/stderr"
+			return 1
+		}
+		interp["v_ob_info"] = v_pat ~ /^b/ ? "^" : "$"
+	}else if(interp["nbreaks"] = interp["nvalues"] - 1){
+		printf("DEBUG: IU_init: nb = nv - 1: chk that we have v[1] = bin, v[2:$-1] = grad, v[$] = bin\n") > "/dev/stderr"
+		if(!match(v_pat, /^bgg*b$/)){
+			printf("ERROR: IU_init: nbreaks (%d) = nvalues - 1 (%d): all values but first and last must be gread\n", interp["nbreaks"], interp["nvalues"] - 1) > "/dev/stderr"
+			return 1
+		}
+		interp["v_ob_info"] = "^$"
+	}else{
+		printf("ERROR: IU_init: nbreaks (%d) != nvalues +/- 1 (%d, %d, %d)\n", interp["nbreaks"], interp["nvalues"] - 1, interp["nvalues"], interp["nvalues"] + 1) > "/dev/stderr"
 		return 1
 	}

@@ -60,6 +81,7 @@
 	printf("interp = {\n") > file
 	printf("\tname          = %s\n", interp["name"]) > file
 	printf("\tis_grad       = %d\n", interp["is_grad"]) > file
+	printf("\tv_ob_info     = %s\n", interp["v_ob_info"]) > file
 	printf("\tnvalues       = %d\n", interp["nvalues"]) > file
 	printf("\tvalues        = %s", interp["values", 1]) > file
 	for(i = 2; i <= interp["nvalues"]; i++)
@@ -78,15 +100,66 @@
 	printf("}\n") > file
 }

-function IU_interpolate(interp, v,   idx) {
+function IU_interpolate(interp, v,   idx, work, n_ary, ary, i) {

 	idx = IU_search(interp, v)
 	interp["tcounts"]++
+	interp["counts", idx]++
 	if(!interp["is_grad"]){
-		interp["counts", idx]++
 		return interp["values", idx]
+	}else{
+		# nbreaks = nvalues - 1
+		if(interp["v_ob_info"]  == ""){	# ^gg*$, take out of bounds values from first and last grad elemnt
+			if(idx == 1){
+				work = interp["values", 1]
+				n_ary = split(work, ary, ":")
+				return ary[1]
+			}else if(idx == interp["nbreaks"] + 1){
+				work = interp["values", interp["nvalues"]]
+				n_ary = split(work, ary, ":")
+				return ary[2]
+			}else{
+				# TODO: do the actual interpolation
+				IU_interpolate_vec(interp["values", idx - 1], v, interp["breaks", idx - 1], interp["breaks", idx])
+				return interp["values", idx - 1]
+			}
+		}else if(interp["v_ob_info"] == "^"){	# ^bgg*$, lower out of bounds specified, take higher ob from last grad element
+			if(idx == 1)
+				return interp["values", 1]
+			else if(idx == interp["nbreaks"] + 1){
+				work = interp["values", interp["nvalues"]]
+				n_ary = split(work, ary, ":")
+				return ary[2]
+			}else{
+				# TODO: do the actual interpolation
+				return interp["values", idx]
+			}
+		}else if(interp["v_ob_info"] == "$"){	# ^gg*b$, upper out of bounds specified, take lower ob from first grad element
+			if(idx == 1){
+				work = interp["values", 1]
+				n_ary = split(work, ary, ":")
+				return ary[1]
+			}else if(idx == interp["nbreaks"] + 1){
+				return interp["values", idx - 1]
+			}else{
+				# TODO: do the actual interpolation
+				return interp["values", idx - 1]
+			}
+		}else{	# ^bgg*b$, lower & upper ob info specified
+			if(idx == 1 || idx == interp["nbreaks"] + 1)
+				return interp["values", idx]
+			else{
+				# TODO: do the actual interpolation
+				return interp["values", idx]
+			}
+		}
+		return v_type
 	}
+}

+function IU_interpolate_vec(vec, v, v_min, v_max) {
+
+	printf("DEBUG: IU_interpolate_vec: vec = %s, v = %g, v_min = %g, v_max = %g\n", vec, v, v_min, v_max)
 	return ""
 }


perf.awk: be less strict with the necessary messages to handle serial logs

--- awk/perf.awk
+++ awk/perf.awk
@@ -1,8 +1,4 @@
 #! /usr/bin/gawk -f
-
-#
-# PowerUp performance using logs
-#

 func die(msg, a, b, c, d, e, f)
 {
@@ -89,157 +85,187 @@
 function print_arr(arr, \
 		   _col, _index)
 {
-
-    _col = 0
-    for (_index in title) {
-	if (title[_index] == "")
-	    continue;
-
-	if (_col != 0)
-	    printf(",")
-	printf("%s", arr[_index])
-	_col++;
-    }
-
-    printf("\n");
-
+
+	for (_index = 0; _index < length(p); ++_index) {
+#	for (_index in p) {
+		if (_index != 0)
+			printf(",")
+		printf("%s", arr[p[_index]])
+		_col++;
+	}
+	printf("\n");
 }

 function print_header()
 {
-    print_arr( title );
-
-    delete avg
-    averages = 0;
+	print_arr( title );
+
+	delete avg
+	averages = 0;
 }

 function print_stats()
 {
-    if (!boot_start)
-	return
-
-    print_arr( time );
+	if (!start[boot])
+		return
+
+	printf("%d)", boot_index )
+	print_arr( time );

 # update average
-    for (i in title) {
-	avg[i] = avg[i] + time[i];
-    }
-    averages++;
+	for (i in title) {
+		avg[i] = avg[i] + time[i];
+	}
+	averages++;

 #    printf("%s\t%s\t%s\n", dal_time, powerup_time, ready_to_watch_time)
-    boot_start = 0;
-
+#    start[boot] = 0;
 }

 function print_final()
 {
-    print_stats();
-
-    print "---";
-    if (averages) {
-	for (i in title) {
-	    avg[i] = int(avg[i] / averages);
-	}
-    }
-
-    print_arr( avg )
-
-    delete avg
-    averages = 0;
+	print_stats();
+
+	print "---";
+	if (averages) {
+		for (i in title) {
+			avg[i] = int(avg[i] / averages);
+		}
+	}
+
+	print_arr( avg )
+
+	delete avg
+	averages = 0;
+}
+
+function begin_boot()
+{
+	if (state != none) {
+		state=none
+		delete start
+		boot_index++;
+		fixtime = 0;
+
+		delete start
+		delete time
+		close( out );
+		out = FILENAME ".part" boot_index ".log";
+		printf("") > out;
+#		print "BOOT: " boot_index ")", $0
+	}
 }

 BEGINFILE {
-    boot_start = 0;
-    fixtime = 0;
-    boot_index = 0;

 # indices
-    boot = 0
-    dal  = 1
-    powerup = 2
-    ready_to_watch = 3
+	first = -1
+	none = 0
+	boot = 1
+	dal  = 2
+	powerup = 3
+	ready_to_watch = 4
+
+	platform=100

 # titles
-    title[ boot ] = ""
-    title[ dal  ] = "dal"
-    title[ powerup ] = "powerup"
-    title[ ready_to_watch ] = "ready_to_watch"
-
-    print "*** " FILENAME;
-    print_header();
+	title[ boot ] = ""
+	title[ dal  ] = "dal"
+	title[ powerup ] = "powerup"
+	title[ ready_to_watch ] = "ready_to_watch"
+	title[ platform ] = "Platform"
+
+# print
+	p[0] = dal
+	p[1] = powerup
+	p[2] = platform
+	p[3] = ready_to_watch
+
+# env
+	state = first
+	fixtime = 0;
+	boot_index = 0;
+	start[boot] = 0;
+
+	print "*** " FILENAME;
+	print_header();
 }

 # line time is in $2 and $3
 # [DBG] 13.08.2015 06:04:16.501
-
-/Thread::init\('LogBufferThread'\)/ { # first supervisor message
-
-    fixtime = 0;
-
-    delete start
-    delete time
-
-    start[ boot ] = boot_start = gettime($2, $3)
-    boot_index++;
-
-    close( out );
-    out = FILENAME ".boot" boot_index ".log";
-
-#    print "start: " boot_start, ts2str(boot_start);
-}
-
+/BCM74130011|main: starting supervisor/ {  # first supervisor message, reset stage
+	begin_boot();
+}
+
+!start[ boot ] && /\[SUPERVISOR\]/ {
+    begin_boot();
+    start[ boot ] = gettime($2, $3)
+    state = boot
+#    print "SUPERVISOR: ", $0
+#    print "start: " start[boot], ts2str(start[boot]), $0;
+}
+
+#!start[dal] && /\[DalManager\]/ {
 /DAL: main: DAL version/ { # first DAL message
-    if (!boot_start) {
+    if (!start[boot]) {
 	print "no start message found"
 	next;
     }

     start[dal] = gettime($2, $3) - fixtime
     time[dal]  = start[dal] - start[boot]
+    state = dal
 }

 /DAL: PosixProcess::run: run \[powerup-launcher\]/ {
-    if (!boot_start) {
+    if (!start[boot]) {
 	print "no start message found"
 	next;
     }

     start[powerup] = gettime($2, $3) - fixtime
     time[powerup] = start[powerup] - start[dal]
+    state = powerup
 }

 /Registry: set: \[registry\] ready_to_watch <-- 1 \[added, 0\]/ {
-    if (!boot_start) {
+    if (!start[boot]) {
 	print "no start message found"
 	next;
     }

     start[ready_to_watch] = gettime($2, $3) - fixtime
     time[ready_to_watch] = start[ready_to_watch] - start[powerup]
+    state = ready_to_watch

     print_stats();
 }

+/LifeCycleManager: initialization of the component DOB2 complete/ {
+    now = gettime($2, $3) - fixtime
+    time[ platform ] = now - start[ powerup ]
+}
+
 /system time changed from .* to .*/ { # time fix message
-    if (!boot_start)
-	next
-
-    if (!match($0, /system time changed from (.*) to (.*)/, arr))
-	die("Unable to match time");
-
-    delta1 = gettime(arr[1])
-    delta2 = gettime(arr[2])
-    fixtime += (delta2 - delta1)
+	if (!start[boot])
+		next
+
+	if (!match($0, /system time changed from (.*) to (.*)/, arr))
+		die("Unable to match time");
+
+	delta1 = gettime(arr[1])
+	delta2 = gettime(arr[2])
+	fixtime += (delta2 - delta1)
 }

 ENDFILE {
-    print_final()
-    close( out );
-}
-
-{
-    if (boot_start) {
-	print $0 >> out;
-    }
-}
+	print_final()
+	close( out );
+}
+
+{
+	if (start[boot]) {
+		print $0 >> out;
+	}
+}


Update filter_en_uk.awk

Update filter_en_uk.awk

added €

--- filter_en_uk.awk
+++ filter_en_uk.awk
@@ -37,6 +37,10 @@
             }
             if ($x == "$") {
                 macroLine = macroLine "+lshift,+4,-4,-lshift";
+                break;
+            }
+            if ($x == "€") {
+                macroLine = macroLine "+ralt,+4,-4,-ralt";
                 break;
             }
             if ($x == "%") {


use SGR code 22 instead of 21

use SGR code 22 instead of 21

* fix #38

--- include/Commons.awk
+++ include/Commons.awk
@@ -216,14 +216,14 @@
 # See: <https://en.wikipedia.org/wiki/ANSI_escape_code>
 function initAnsiCode() {
     # Dumb terminal: no ANSI escape code whatsoever
-    if(ENVIRON["TERM"] == "dumb") return
+    if (ENVIRON["TERM"] == "dumb") return

     AnsiCode["reset"]         = AnsiCode[0] = "\33[0m"

     AnsiCode["bold"]          = "\33[1m"
     AnsiCode["underline"]     = "\33[4m"
     AnsiCode["negative"]      = "\33[7m"
-    AnsiCode["no bold"]       = "\33[21m"
+    AnsiCode["no bold"]       = "\33[22m" # SGR code 21 (bold off) not widely supported
     AnsiCode["no underline"]  = "\33[24m"
     AnsiCode["positive"]      = "\33[27m"


handle one line struct {}, multiline comments, whitespaces when parsing header for structs

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

--- mkstructinfo.awk
+++ mkstructinfo.awk
@@ -2,11 +2,35 @@
 # vim:ts=4:sw=4
 BEGIN {
 	brace = 0;
+	incomment = 0;
 	buffer_len = 0;
 }
+
+# multiline comment handling
+{
+	# removes one line comment
+	gsub(/\/\*(.+?)\*\//, " ");
+}
+/\*\// {
+	if (incomment) {
+		sub(/.*\*\//, "");
+		incomment = 0;
+	}
+}
+incomment {
+	next;
+}
+/\/\*/ {
+	sub(/\/\*.*/, "");
+	incomment = 1;
+	# fall through
+}
+
+# skip file/line mark here to be faster
 /^#/ {
 	next;
 }
+
 /^}.*;/ {
 	if (instruct) {
 		sub(";", "");
@@ -53,7 +77,7 @@

 {
 	if (brace == 1 && instruct) {
-		gsub(/\/\*(.+?)\*\//, " "); # removes one line comment
+		gsub(/(^[\t ]+|[\t ]+$)/, ""); # trim whitespaces
 		sub(/.*[{}]/, "");
 		gsub(/\[[^\]]+\]/, ""); # ignore [...]
 		gsub(/:[0-9]+/, ""); # ignore struct bit
@@ -66,6 +90,8 @@
 			buffer_len ++;
 		}
 		else {
+			# process normal variables
+
 			# ignore any ()s
 			while (gsub(/(\([^)]*\))/, "")) {
 			}
@@ -82,6 +108,7 @@
 			if (!match($0, /;/)) {
 				next;
 			}
+			# print "=DEBUG=" $0 "==";
 			split($0, chunks, ";");
 			# [unsigned int a, b, c]

@@ -101,7 +128,9 @@
 					delete pieces[j];
 				}
 				if (last_piece == "") {
-					print "=====" chunks[i];
+					# print "=ERROR=" chunks[i] "==";
+					delete chunks[i];
+					continue;
 				}
 				# a
 				# b
@@ -122,7 +151,7 @@
 	typedefs[$3] = $4;
 	next;
 }
-/^typedef struct .*\{/ {
+/^typedef struct .*\{[^}]*$/ {
 	brace = 1;
 	instruct = 1;
 	next;


Change column count err message

Change column count err message

see: https://trello.com/c/ShoI6Sr2/350-user-interprets-his-upload-violations

--- bin/bawlk.awk
+++ bin/bawlk.awk
@@ -82,9 +82,9 @@
     print pkeycheck
     cat = "error"
     test = "NF != field_width"
-    msg = "row \" NR \" in \" CSVFILENAME \" has \" NF \" records and \" field_width \" was expected"
-    mini_msg = "row \" NR \" has an invalid column number"
-    rule_type = "field-width-missmatch"
+    msg = "row \" NR \" in \" CSVFILENAME \" has \" NF \" columns and \" field_width \" was expected"
+    mini_msg = "row \" NR \" has an invalid column count"
+    rule_type = "invalid-column-count"
     # print "action ~ /^validate/ && NR > 1 { if(NF != field_width) { print \"row \" NR \" in \" CSVFILENAME \" has \" NF \" records and \" field_width \" was expected\"; next;} }"
 }


interp_utils.awk	-- macro expansion added

--- lib/interp_utils.awk
+++ lib/interp_utils.awk
@@ -1,4 +1,4 @@
-function IU_init(config, interp, name,    key, work, n_ary, ary, i, v_pat, v_len) {
+function IU_init(config, interp, name,    key, work, n_ary, ary, i, v_pat, parms) {

 	interp["name"] = name

@@ -28,22 +28,32 @@
 	for(i = 1; i <= n_ary; i++){
 		sub(/^[ \t]*/, "", ary[i])
 		sub(/[ \t]*$/, "", ary[i])
+		parms["grad"] = ary[i]
 		if(index(ary[i], ":") != 0){
 			interp["is_grad"] = 1
 			v_pat = v_pat "g"
-			v_len = _IU_check_grad(ary[i])
-			if(v_len == 0){
+			parms["v_len"] = 0
+			if(_IU_check_grad(config, parms)){
 				printf("ERROR: IU_init: _IU_check_grad failed for value %d (%s)\n", i, ary[i]) > "/dev/stderr"
 				return 1
 			}else if(interp["v_len"] == 0){
-				interp["v_len"] = v_len
-			}else if(v_len != interp["v_len"]){
-				printf("ERROR: IU_init: v_len (%d) for value %d (%s) differs from current v_len (%d)\n", v_len, i, ary[i], interp["v_len"]) > "/dev/stderr"
+				interp["v_len"] = parms["v_len"]
+			}else if(parms["v_len"] != interp["v_len"]){
+				printf("ERROR: IU_init: v_len (%d) for value %d (%s) differs from current v_len (%d)\n", parms["v_len"], i, ary[i], interp["v_len"]) > "/dev/stderr"
 				return 1
 			}
-		}else
+		}else{
+			if(substr(ary[i], 1, 1) == "$"){
+				work = config["_globals", substr(ary[i], 2)]
+				if(work == ""){
+					printf("ERROR: IU_init: macro %s not defined\n", ary[i]) > "/dev/stderr"
+					return 1
+				}else
+					parms["grad"] = work
+			}
 			v_pat = v_pat "b"
-		interp["values", i] = ary[i]
+		}
+		interp["values", i] = parms["grad"]
 	}

 	# get the breaks
@@ -101,7 +111,7 @@
 	key = name ".exceptions"
 	work = config["_globals", key]
 	if(work != ""){
-		if(_IU_parse_exceptions(interp, work))
+		if(_IU_parse_exceptions(config, interp, work))
 			return 1
 	}

@@ -208,28 +218,38 @@
 	printf("}\n") > file
 }

-function _IU_check_grad(grad,   v_len, n_ary, ary, i, n_ary2, ary2, j) {
-
-	v_len = 0
-	n_ary = split(grad, ary, ":")
+function _IU_check_grad(config, parms,    v_len, n_ary, ary, i, work, n_ary2, ary2, j, xgrad, xval) {
+
+	parms["v_len"] = 0
+	n_ary = split(parms["grad"], ary, ":")
 	if(n_ary != 2){
 		printf("ERROR: _IU_check_grad: grad %s has %d fields, must have %d\n", grad, n_ary, 2) > "/dev/stderr"
-		return 0
-	}
+		return 1
+	}
+	xgrad = ""
 	for(i = 1; i <= n_ary; i++){
 		n_ary2 = split(ary[i], ary2, ",")
-		if(v_len == 0)
-			v_len = n_ary2
-		else if(n_ary2 != v_len){
-			printf("ERROR: _IU_check_grad: vector %s has %d elements, must have %d\n", ary[i], n_ary2, v_len) > "/dev/stderr"
-			return 0
-		}
-	}
-
-	return v_len
-}
-
-function _IU_parse_exceptions(interp, str,   err, n_ary, ary, i, colon, cond, op, opnd, value) {
+		if(parms["v_len"] == 0)
+			parms["v_len"] = n_ary2
+		else if(n_ary2 != parms["v_len"]){
+			printf("ERROR: _IU_check_grad: vector %s has %d elements, must have %d\n", ary[i], n_ary2, parms["v_len"]) > "/dev/stderr"
+			return 1
+		}
+		if(substr(ary[i], 1, 1) == "$"){
+			xval = config["_globals", substr(ary[i], 2)]
+			if(xval == ""){
+				printf("ERROR: _IU_check_grad: macro %s is not defined\n", ary[i]) > "/dev/stderr"
+				return 1
+			}
+			xgrad = xgrad (i > 1 ? ":" : "") xval
+		}
+	}
+	parms["grad"] = xgrad
+
+	return 0
+}
+
+function _IU_parse_exceptions(config, interp, str,   err, n_ary, ary, i, work, colon, cond, op, opnd, value, xvalue) {

 	err = 0
 	interp["exceptions"] = str
@@ -268,7 +288,7 @@
 		sub(/^  */, "", opnd)
 		sub(/  *$/, "", opnd)
 		if(cond == ""){
-			print("ERROR: _IU_parse_exception: exception %d: %s: empty operand %s\n", i, ary[i]) > "/dev/stderr"
+			print("ERROR: _IU_parse_exception: exception %d: %s: empty operand\n", i, ary[i]) > "/dev/stderr"
 			return 1
 		}

@@ -276,6 +296,17 @@
 		sub(/^  */, "", value)
 		sub(/  *$/, "", value)
 		# TODO? value can be empty, is this OK?
+		if(value == ""){
+			printf("ERROR: _IU_parse_exception: exception %d: %s: empty value\n", i, ary[i]) > "/dev/stderr"
+			return 1
+		}else if(substr(value, 1, 1) == "$"){
+			xvalue = config["_globals", substr(value, 2)]
+			if(xvalue == ""){
+				printf("ERROR: _IU_parse_exception: macro %s is not defined\n", value) > "/dev/stderr"
+				return 1
+			}
+			value = xvalue
+		}

 		interp["exceptions", i, "op"] = op
 		interp["exceptions", i, "opnd"] = opnd + 0 # force numeric


pushing

pushing

--- auk/sdtree.auk
+++ auk/sdtree.auk
@@ -24,7 +24,7 @@
   use = best(ranges,sorted)
   for(r=length(sorted); r>=1; r--)
     if (sorted[r].column == use)
-        kids(use, sorted[r],max,k,pre)
+        kids(use, sorted[r],max,k,pre)
 }
 # Somethings to note:
 #


2015-03-12: parsegaspriceshtml.awk: Added substitution for Marathon pictures.

--- parsegaspriceshtml.awk
+++ parsegaspriceshtml.awk
@@ -42,6 +42,7 @@
    gsub("","Thorntons")
    gsub("","Thorntons")
    gsub("","Certified")
+   gsub("","Marathon")
    expectName=False
    sub("[ ]*$","")
    sub("^.*>","")


Revert "Update awk file to match rupa's z (#42)"

This reverts commit 6962f589a495b80e35ed9c2678b9fd53cd670afa.


CWS swlayoutrefactoring: last portion of m100 merged


Main: escape embedded bracket in regexp (fix #55 for gawk 4.1.2)


make option -version and -interactive a little more comprehensive

--- include/Main.awk
+++ include/Main.awk
@@ -79,6 +79,10 @@
         match(ARGV[pos], /^--?(vers(i(on?)?)?|V)$/)
         if (RSTART) {
             print getVersion()
+            print
+            printf("%-22s%s\n", "gawk (GNU Awk)", PROCINFO["version"])
+            printf("%s\n", FriBidi ? FriBidi : "fribidi (GNU FriBidi) [NOT INSTALLED]")
+            printf("%-22s%s\n", "User Language", Locale[getCode(UserLang)]["name"] " (" show(Locale[getCode(UserLang)]["endonym"]) ")")
             exit
         }

@@ -346,6 +350,9 @@
         }
     }

+    if (Option["interactive"])
+        print AnsiCode["bold"] AnsiCode[tolower(Option["prompt-color"])] getVersion() AnsiCode[0] > "/dev/stderr"
+
     # Initialize browser
     if (!Option["browser"]) {
         "xdg-mime query default text/html 2>/dev/null" |& getline Option["browser"]


Define BRLAPI_DOT_CHORD. (dm)

Define BRLAPI_DOT_CHORD. (dm)

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

--- Programs/brlapi_constants.awk
+++ Programs/brlapi_constants.awk
@@ -89,4 +89,7 @@
   }

   print "#define BRLAPI_DOTS(" arguments ") (\\\n" expression " \\\n)"
+
+  print ""
+  writeMacroDefinition("BRLAPI_DOT_CHORD", 0X100, "space key")
 }


Created output level constants. Output styles. Variables in function moved to local scope. Improved multi-file support.

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

--- test/scripts/tdb.awk
+++ test/scripts/tdb.awk
@@ -1,13 +1,15 @@
 #!/usr/bin/awk -f

-#
+#######
 # BEGIN
-#
+#######

 BEGIN {
- # Constants
+ # Boolean
  false = 0;
  true = 1;
+
+ # Format codes
  CODE_ATTRIBUTE      = "@"
  CODE_ESTIMATED_SIZE = "e"
  CODE_JOURNAL_TITLE  = "j"
@@ -19,6 +21,8 @@
  CODE_SKIP_2         = "X"
  CODE_STATUS         = "S"
  CODE_TITLE          = "t"
+
+ # Archival unit statuses
  STATUS_DOES_NOT_EXIST = "does_not_exist"
  STATUS_DO_NOT_PROCESS = "do_not_process"
  STATUS_DOWN           = "down"
@@ -29,110 +33,238 @@
  STATUS_RELEASED       = "released"
  STATUS_RETRACTED      = "retracted"
  STATUS_TESTING        = "testing"
- LEVEL_CONSERVATIVE_TESTING = "conservativeTesting"
- LEVEL_CONTENT_TESTING      = "contentTesting"
- LEVEL_DANGEROUS            = "dangerous"
- LEVEL_PRE_RELEASE          = "preRelease"
- LEVEL_PRODUCTION           = "production"
- LEVEL_VERY_DANGEROUS       = "veryDangerous"
- LEVEL_DEFAULT              = LEVEL_PRODUCTION
+
+ # Output levels and corresponding archival unit statuses
+ LEVEL_PRODUCTION              = "production"
+ STATUSES_PRODUCTION           = STATUS_RETRACTED "," STATUS_DOWN "," STATUS_RELEASED
+ LEVEL_CONTENT_TESTING         = "contentTesting"
+ STATUSES_CONTENT_TESTING      = STATUSES_PRODUCTION "," STATUS_PRE_RELEASED "," STATUS_READY "," STATUS_TESTING "," STATUS_MANIFEST "," STATUS_EXISTS
+ LEVEL_DANGEROUS               = "dangerous"
+ STATUSES_DANGEROUS            = STATUSES_CONTENT_TESTING "," STATUS_DO_NOT_PROCESS
+ LEVEL_VERY_DANGEROUS          = "veryDangerous"
+ STATUSES_VERY_DANGEROUS       = STATUSES_DANGEROUS "," STATUS_DOES_NOT_EXIST
+ LEVEL_PRE_RELEASE             = "preRelease"
+ STATUSES_PRE_RELEASE          = STATUS_PRE_RELEASED
+ LEVEL_CONSERVATIVE_TESTING    = "conservativeTesting"
+ STATUSES_CONSERVATIVE_TESTING = STATUS_RELEASED "," STATUS_PRE_RELEASED "," STATUS_READY "," STATUS_TESTING "," STATUS_MANIFEST
+ LEVEL_DEFAULT                 = LEVEL_PRODUCTION
+
+ # Output styles
+ STYLE_XML         = "xml"
+ STYLE_XML_ENTRIES = "xmlEntries"
+ STYLE_XML_LEGACY  = "xmlLegacy"
+ STYLE_DEFAULT     = STYLE_XML_ENTRIES
+
+ # Exit codes
  EXIT_NO_FORMAT_STRING = 11

  # Initial setup
  FS="\t"
- preamble = true
- numAdditionalAttributes = 0
+ parseCommandLine()
+
+ # Preamble
+ if (outputStyle == STYLE_XML || outputStyle == STYLE_XML_LEGACY) { preambleXml() }
+}
+
+###########
+# FUNCTIONS
+###########
+
+#
+# parseCommandLine
+#
+function parseCommandLine() {
+ # Disallow overrides
+ formatString = ""
+ namePrefix = ""
+
+ # Defaults
+ if (outputStyle == "") { outputStyle = STYLE_DEFAULT }
+ if (outputLevel == "") { outputLevel = LEVEL_DEFAULT }
+
+ # Parse
+ parseOutputLevel()
+}
+
+#
+# parseFormatString
+#
+function parseFormatString(        _splitFormatString, _numFields, _field, _code) {
+ # Reset format information
+ delete indexOf
+ numAdditionalParameters = 0
+ delete indexAdditionalAttributes
  numParameters = 0
- parseCommandLine()
-}
-
-#
-# FUNCTIONS
-#
-
-# parseCommandLine
-function parseCommandLine() {
- if (formatString != "") { parseFormatString() }
- if (outputLevel == "") { outputLevel = LEVEL_DEFAULT }
- parseOutputLevel()
-}
-
-# parseFormatString
-function parseFormatString() {
- numFields = split(formatString, _fields, ",")
- for (_field = 1 ; _field <= numFields ; ++_field) {
-  _code = _fields[_field]
+ delete indexParameters
+
+ # For each format code...
+ _numFields = split(formatString, _splitFormatString, ",")
+ for (_field = 1 ; _field <= _numFields ; ++_field) {
+  _code = _splitFormatString[_field]
   if (_code == CODE_SKIP_1 || _code == CODE_SKIP_2) { continue }
   else if (_code == CODE_ESTIMATED_SIZE || _code == CODE_JOURNAL_TITLE || _code == CODE_PLUGIN || _code == CODE_TITLE || _code == CODE_PUBLISHER || _code == CODE_STATUS || _code == CODE_RIGHTS) { indexOf[_code] = _field }
   else if (_code == CODE_ATTRIBUTE) { indexAdditionalAttributes[++numAdditionalAttributes] = _field }
   else if (_code == CODE_PARAMETER) { indexParameters[++numParameters] = _field }
- }
-}
-
+  # FIXME: unknown code
+ }
+}
+
+#
 # parseOutputLevel
-function parseOutputLevel() {
- split(outputLevel, _levels, ",")
- for (_i in _levels) {
-  if (_levels[_i] == LEVEL_PRODUCTION) { _status = STATUS_RETRACTED "," STATUS_DOWN "," STATUS_RELEASED }
-  else if (_levels[_i] == LEVEL_PRE_RELEASE) { _status = STATUS_PRE_RELEASED }
-  else if (_levels[_i] == LEVEL_CONTENT_TESTING) { _status = STATUS_RETRACTED "," STATUS_DOWN "," STATUS_RELEASED "," STATUS_PRE_RELEASED "," STATUS_READY "," STATUS_TESTING "," STATUS_MANIFEST "," STATUS_EXISTS }
-  else if (_levels[_i] == LEVEL_CONSERVATIVE_TESTING) { _status = STATUS_RELEASED "," STATUS_PRE_RELEASED "," STATUS_READY "," STATUS_TESTING "," STATUS_MANIFEST }
-  else if (_levels[_i] == LEVEL_DANGEROUS) { _status = STATUS_RETRACTED "," STATUS_DOWN "," STATUS_RELEASED "," STATUS_PRE_RELEASED "," STATUS_READY "," STATUS_TESTING "," STATUS_MANIFEST "," STATUS_EXISTS "," STATUS_DO_NOT_PROCESS }
-  else if (_levels[_i] == LEVEL_VERY_DANGEROUS) { _status = STATUS_RETRACTED "," STATUS_DOWN "," STATUS_RELEASED "," STATUS_PRE_RELEASED "," STATUS_READY "," STATUS_TESTING "," STATUS_MANIFEST "," STATUS_EXISTS "," STATUS_DO_NOT_PROCESS "," STATUS_DOES_NOT_EXIST }
-  else { _status = _levels[_i] }
-  split(_status, _statuses, ",")
-  for (_j in _statuses) { outputLevels[_statuses[_j]] = true; }
- }
-}
-
-# printOneEntry
-function printOneEntry() {
+#
+function parseOutputLevel(        _splitOutputLevel, _i, _statuses, _splitStatuses, _j) {
+ # Reset output level information
+ delete outputLevels
+
+ # For each output level...
+ split(outputLevel, _splitOutputLevel, ",")
+ for (_i in _splitOutputLevel) {
+  # Synonyms
+  if (_splitOutputLevel[_i] == LEVEL_PRODUCTION) { _statuses = STATUSES_PRODUCTION }
+  else if (_splitOutputLevel[_i] == LEVEL_PRE_RELEASE) { _statuses = STATUSES_PRE_RELEASE }
+  else if (_splitOutputLevel[_i] == LEVEL_CONTENT_TESTING) { _statuses = STATUSES_CONTENT_TESTING }
+  else if (_splitOutputLevel[_i] == LEVEL_CONSERVATIVE_TESTING) { _statuses = STATUSES_CONSERVATIVE_TESTING }
+  else if (_splitOutputLevel[_i] == LEVEL_DANGEROUS) { _statuses = STATUSES_DANGEROUS }
+  else if (_splitOutputLevel[_i] == LEVEL_VERY_DANGEROUS) { _statuses = STATUSES_VERY_DANGEROUS }
+  else { _statuses = _splitOutputLevel[_i] } # Not a synonym
+  # For each status...
+  split(_statuses, _splitStatuses, ",")
+  for (_j in _splitStatuses) { outputLevels[_splitStatuses[_j]] = true; }
+ }
+}
+
+#
+# preambleXml
+#
+function preambleXml() {
+ xmlInOrgLockssTitle = false;
+
+ printf  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ printf  "<!DOCTYPE lockss-config [\n"
+ printf  "<!ELEMENT lockss-config (if|property)+>\n"
+ printf  "<!ELEMENT property (property|list|value|if)*>\n"
+ printf  "<!ELEMENT list (value)+>\n"
+ printf  "<!ELEMENT value (#PCDATA)>\n"
+ printf  "<!ELEMENT test EMPTY>\n"
+ printf  "<!ELEMENT and (and|or|not|test)*>\n"
+ printf  "<!ELEMENT or (and|or|not|test)*>\n"
+ printf  "<!ELEMENT not (and|or|not|test)*>\n"
+ printf  "<!ELEMENT if (and|or|not|then|else|test|property)*>\n"
+ printf  "<!ELEMENT then (if|property)*>\n"
+ printf  "<!ELEMENT else (if|property)*>\n"
+ printf  "<!ATTLIST property name CDATA #REQUIRED>\n"
+ printf  "<!ATTLIST property value CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test hostname CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test group CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test daemonVersionMin CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test daemonVersionMax CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test daemonVersion CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test platformVersionMin CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test platformVersionMax CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test platformVersion CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST test platformName CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if hostname CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if group CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if daemonVersionMin CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if daemonVersionMax CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if daemonVersion CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if platformVersionMin CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if platformVersionMax CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if platformVersion CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST if platformName CDATA #IMPLIED>\n"
+ printf  "<!ATTLIST list append CDATA #IMPLIED>\n"
+ printf  "]>\n"
+ printf  "\n"
+ printf  "<lockss-config>\n"
+ printf  "\n"
+}
+
+#
+# postambleXml
+#
+function postambleXml() {
+ if (xmlInOrgLockssTitle) {
+  xmlInOrgLockssTitle = false;
+  printf " </property>\n"
+  printf "\n"
+ }
+ printf  "</lockss-config>\n"
+}
+
+#
+# printOneXmlEntry
+#
+function printOneXmlEntry(        _status, _param, _attr) {
+ # Skip based on output level
  _status = $indexOf[CODE_STATUS]
  if (!outputLevels[_status]) { return }

+ # Start config subtree if needed
+ if ((outputStyle == STYLE_XML || outputStyle == STYLE_XML_LEGACY) && !xmlInOrgLockssTitle) {
+  xmlInOrgLockssTitle = true;
+  printf " <property name=\"org.lockss.title\">\n"
+  printf "\n"
+ }
+
+ # Begin
  printf  "  <property name=\"%s\">\n", getOpaqueName($indexOf[CODE_TITLE])

- if (indexOf[CODE_PUBLISHER] != "") { printOneAttribute("publisher=" xml($indexOf[CODE_PUBLISHER])) }
+ # First the publisher if there is one
+ if (indexOf[CODE_PUBLISHER] != "") { printOneXmlAttribute("publisher=" xml($indexOf[CODE_PUBLISHER])) }
+
+ # Then the journal title, archival unit title and plugin
  printf  "   <property name=\"journalTitle\" value=\"%s\" />\n", xml($indexOf[CODE_JOURNAL_TITLE])
-   printf  "   <property name=\"title\" value=\"%s%s\" />\n", xml($indexOf[CODE_TITLE]), (_status == STATUS_PRE_RELEASED ? " (Pre-release)" : "")
+ printf  "   <property name=\"title\" value=\"%s%s\" />\n", xml($indexOf[CODE_TITLE]), (_status == STATUS_PRE_RELEASED ? " (Pre-release)" : "")
  printf  "   <property name=\"plugin\" value=\"%s\" />\n", $indexOf[CODE_PLUGIN]

+ # Then the parameters
  for (_param = 1 ; _param <= numParameters ; ++_param) {
   _pair = $indexParameters[_param]
   if (_pair == "") { continue }
-  printOneParameter(_param, _pair)
- }
- if (_status == STATUS_DOWN) { printOneParameter(99, "pub_down=true") }
-
+  printOneXmlParameter(_param, _pair)
+ }
+ # Down AUs are denoted by a parameter
+ if (_status == STATUS_DOWN) { printOneXmlParameter(99, "pub_down=true") }
+
+ # Then any additional parameters
  for (_attr = 1 ; _attr <= numAdditionalAttributes ; ++_attr) {
   _pair = $indexAdditionalAttributes[_attr]
   if (_pair == "") { continue }
-  printOneAttribute(_pair)
- }
- if (indexOf[CODE_RIGHTS] != "" && $indexOf[CODE_RIGHTS] == "openaccess") { printOneAttribute("rights=openaccess") }
+  printOneXmlAttribute(_pair)
+ }
+
+ # Then other tidbits
+ if (indexOf[CODE_RIGHTS] != "" && $indexOf[CODE_RIGHTS] == "openaccess") { printOneXmlAttribute("rights=openaccess") }
  if (indexOf[CODE_ESTIMATED_SIZE] != "" && $indexOf[CODE_ESTIMATED_SIZE] != "") {
   printf "   <property name=\"estSize\" value=\"%s\" />\n", $indexOf[CODE_ESTIMATED_SIZE]
  }
- if (_status == STATUS_PRE_RELEASED) { printOneAttribute("releaseStatus=pre-release") }
-
- printf  "  </property>\n\n"
-
-}
-
-# printOneParameter
-function printOneParameter(_num, _pair) {
+ if (_status == STATUS_PRE_RELEASED) { printOneXmlAttribute("releaseStatus=pre-release") }
+
+ # End
+ printf  "  </property>\n"
+ printf  "\n"
+}
+
+#
+# printOneXmlParameter
+#
+function printOneXmlParameter(_num, _pair) {
  printf  "   <property name=\"param.%d\">\n", _num
  printf  "    <property name=\"key\" value=\"%s\" />\n", getKey(_pair)
  printf  "    <property name=\"value\" value=\"%s\" />\n", getValue(_pair)
  printf  "   </property>\n"
 }

-# printOneAttribute
-function printOneAttribute(_pair) {
+#
+# printOneXmlAttribute
+#
+function printOneXmlAttribute(_pair) {
  printf  "   <property name=\"attributes.%s\" value=\"%s\" />\n", getKey(_pair), getValue(_pair)
 }

+#
 # getOpaqueName
+#
 function getOpaqueName(_str) {
  gsub(/ Volume /, "", _str); # FIXME
  gsub(/&/, "and", _str);
@@ -140,17 +272,23 @@
  return namePrefix _str
 }

+#
 # getKey
+#
 function getKey(_str) {
  return match(_str, /^[^=]+=/) ? substr(_str, 1, RLENGTH - 1) : _str
 }

+#
 # getValue
+#
 function getValue(_str) {
  return match(_str, /^[^=]+=/) ? substr(_str, RLENGTH + 1, length(_str) - RLENGTH) : _str
 }

+#
 # xml
+#
 function xml(_str) {
  gsub(/&/, "\&", _str);
  gsub(/</, "\<", _str);
@@ -158,31 +296,37 @@
  return _str
 }

-#
+##########
 # PATTERNS
-#
-
-# Blank lines
+##########
+
+#
+# Blank line
+#
 /^\t*$/ {
  next
 }

+#
 # Format line
+#
 /^# @formatString=/ {
- if (preamble && formatString == "") {
-  formatString = substr($1, 17, length($1) - 16)
-  parseFormatString()
- }
- next
-}
-
+ formatString = substr($1, 17, length($1) - 16)
+ parseFormatString()
+ next
+}
+
+#
 # Name prefix line
+#
 /^# @namePrefix=/ {
- if (preamble && namePrefix == "") { namePrefix = substr($1, 15, length($1) - 14) }
- next
-}
-
+ namePrefix = substr($1, 15, length($1) - 14)
+ next
+}
+
+#
 # Comment line
+#
 /^#/ {
  next
 }
@@ -190,8 +334,17 @@
 # Normal line
 # unconditional
 {
- preamble = false
  if (formatString == "") { exit EXIT_NO_FORMAT_STRING }
- printOneEntry()
-}
-
+ if (outputStyle == STYLE_XML || outputStyle == STYLE_XML_ENTRIES || outputStyle == STYLE_XML_LEGACY) { printOneXmlEntry() }
+ next
+}
+
+#####
+# END
+#####
+
+END {
+ # Postamble
+ if (outputStyle == STYLE_XML || outputStyle == STYLE_XML_LEGACY) { postambleXml() }
+}
+


Do not use invalid awk hash escape any more

--- assets/readproperties.awk
+++ assets/readproperties.awk
@@ -5,7 +5,7 @@
 	v="";
 	c=0; # Not a line continuation.
 }
-/^\#/ { # The line is a comment.  Breaks line continuation.
+/^#/ { # The line is a comment.  Breaks line continuation.
 	c=0;
 	next;
 }


INTEGRATION: CWS beta2regression03 (1.1.58); FILE MERGED 2003/04/30 15:35:19 er 1.1.58.1: #i13811# (not really); adapt to reality

--- i18npool/source/localedata/data/currency-check.awk
+++ i18npool/source/localedata/data/currency-check.awk
@@ -1,121 +1,192 @@
 #!/usr/bin/gawk -f
-#// Usage: gawk -f currency-check.awk *.xml
-#// Check any
-#// <FormatCode>...[$xxx-...]...</FormatCode>
-#// against every
-#// <CurrencySymbol>xxx</CurrencySymbol>
-#// definition of the same XML file and output symbols if no match was found.
-#// For formatindex="12" to formatindex="15" and for formatindex="17" it is
-#// checked if the used currency symbol is the usedInCompatibleFormatCodes
-#// currency symbol as it is needed by the number formatter.
-#// Also generates output if the generic currency symbol (UTF8 string 0xC2A4)
-#// is used instead of a real currency symbol.
-#// Author: Eike Rathke <erack@sun.com>
+# Usage: gawk -f currency-check.awk *.xml
+# Check any
+# <FormatCode>...[$xxx-...]...</FormatCode>
+# against every
+# <CurrencySymbol>xxx</CurrencySymbol>
+# definition of the same XML file and output symbols if no match was found.
+# For formatindex="12" to formatindex="15" and for formatindex="17" it is
+# checked if the used currency symbol is the usedInCompatibleFormatCodes
+# currency symbol as it is needed by the number formatter.
+# Also generates output if the generic currency symbol (UTF8 string 0xC2A4)
+# is used instead of a real currency symbol.
+# Author: Eike Rathke <er@openoffice.org>

 BEGIN {
-	file = ""
-	while ( getline > 0 )
-	{
-		if ( file != FILENAME )
-		{
-			if ( file )
-				checkIt()
-			file = FILENAME
-			line = 0
-			nFormats = 0
-			nSymbols = 0
-			bSymbolDefault = 0
+    file = ""
+}
+
+
+file != FILENAME {
+    if ( file )
+        checkIt()
+    file = FILENAME
+    line = 0
+    nFormats = 0
+    nSymbols = 0
+    bSymbolDefault = 0
+    bSymbolCompati = 0
+    bFormatAuto = 0
+    sReplaceFrom = ""
+    sReplaceTo = ""
+    sMatchReplace = ""
+    sRefCurrencyFromLocale = ""
+}
+
+{
+    ++line
+    if ( $1 ~ /^<LC_FORMAT$/ )
+    {
+        if ( $0 ~ /replaceFrom="\[CURRENCY\]"/ )
+        {
+            sReplaceFrom = "\\[CURRENCY\\]"
+            sMatchReplace = "^<FormatCode>.*" sReplaceFrom
+        }
+        for ( j=2; j<=NF; ++j )
+        {
+            if ( $j ~ /^replaceTo="/ )
+            {
+                l = 12
+                if ( $j ~ />$/ )
+                    ++l
+                if ( $j ~ /\/>$/ )
+                    ++l
+                sReplaceTo = substr( $j, 12, length($j)-l )
+            }
+        }
+    }
+    else if ( $1 ~ /^<FormatElement$/ )
+    {
+        if ( $0 ~ /usage="CURRENCY"/ )
+        {
+            if ( $0 ~ /formatindex="1[23457]"/ )
+                bFormatAuto = 1
+            else
+                bFormatAuto = 0
+        }
+    }
+    else if ( $0 ~ /^<FormatCode>.*\[\$.*-[0-9a-fA-F]+\]/ ||
+            (sMatchReplace && $0 ~ sMatchReplace ) )
+    {
+        if ( sReplaceFrom )
+            gsub( sReplaceFrom, sReplaceTo )
+        split( $0, arr, /<|>/ )
+        split( arr[3], code, /(\[\$)|(-[0-9a-fA-F]+\])/ )
+        for ( j in code )
+        {
+            if ( code[j] && code[j] !~ /\#|0/ )
+            {
+                FormatLine[nFormats] = file " line " line
+                FormatAuto[nFormats] = bFormatAuto
+                Formats[nFormats++] = code[j]
+            }
+        }
+        bFormatAuto = 0
+    }
+    else if ( $1 ~ /^<LC_CURRENCY$/ )
+    {
+        for ( j=2; j<=NF; ++j )
+        {
+            if ( $j ~ /^ref="/ )
+            {
+                l = 6
+                if ( $j ~ />$/ )
+                    ++l
+                if ( $j ~ /\/>$/ )
+                    ++l
+                locale = substr( $j, 6, length($j)-l )
+                sRefCurrencyFromLocale = file
+                oldfile = file
+                oldline = line
+                file = locale ".xml"
+                line = 0
+                while ( (getline <file) > 0 )
+                {
+                    ++line
+                    getCurrencyParams()
+                }
+                close( file )
+                if ( !line )
+                    print "ref locale not available: " file \
+                        " (from " oldfile " line " oldline ")"
+                file = oldfile
+                line = oldline
+                sRefCurrencyFromLocale = ""
+            }
+        }
+    }
+    else
+        getCurrencyParams()
+}
+
+
+END {
+    if ( file )
+        checkIt()
+}
+
+
+function getCurrencyParams() {
+    if ( $1 ~ /^<Currency$/ )
+    {
+        if ( $0 ~ /default="true"/ )
+            bSymbolDefault = 1
+        else
+            bSymbolDefault = 0
+        if ( $0 ~ /usedInCompatibleFormatCodes="true"/ )
+            bSymbolCompati = 1
+        else
             bSymbolCompati = 0
-			bFormatAuto = 0
-		}
-		++line
-		if ( $1 ~ /^<FormatElement$/ )
-		{
-			if ( $5 ~ /^usage="CURRENCY"$/ )
-			{
-				if ( $6 ~ /^formatindex="1[23457]">$/ )
-					bFormatAuto = 1
-				else
-					bFormatAuto = 0
-			}
-		}
-		else if ( $0 ~ /^<FormatCode>.*\[\$.*-[0-9a-fA-F]+\]/ )
-		{
-			split( $0, arr, /<|>/ )
-			split( arr[3], code, /(\[\$)|(-[0-9a-fA-F]+\])/ )
-			for ( j in code )
-			{
-				if ( code[j] && code[j] !~ /\#|0/ )
-				{
-					FormatLine[nFormats] = file " line " line
-					FormatAuto[nFormats] = bFormatAuto
-					Formats[nFormats++] = code[j]
-				}
-			}
-			bFormatAuto = 0
-		}
-		else if ( $1 ~ /^<Currency$/ )
-		{
-            if ( $2 ~ /^default="true"/ )
-				bSymbolDefault = 1
-			else
-				bSymbolDefault = 0
-            if ( $3 ~ /^usedInCompatibleFormatCodes="true"/ )
-                bSymbolCompati = 1
-			else
-                bSymbolCompati = 0
-		}
-		else if ( $0 ~ /^<CurrencySymbol>/ )
-		{
-			split( $0, arr, /<|>/ )
-			SymbolLine[nSymbols] = file " line " line
-			SymbolDefault[nSymbols] = bSymbolDefault
-            SymbolCompati[nSymbols] = bSymbolCompati
-			Symbols[nSymbols++] = arr[3]
-			bSymbolDefault = 0
-            bSymbolCompati = 0
-		}
-	}
-	checkIt()
-}
-
-
-END {
+    }
+    else if ( $0 ~ /^<CurrencySymbol>/ )
+    {
+        split( $0, arr, /<|>/ )
+        if ( sRefCurrencyFromLocale )
+            SymbolLine[nSymbols] = file " line " line \
+                " (referenced from " sRefCurrencyFromLocale ")"
+        else
+            SymbolLine[nSymbols] = file " line " line
+        SymbolDefault[nSymbols] = bSymbolDefault
+        SymbolCompati[nSymbols] = bSymbolCompati
+        Symbols[nSymbols++] = arr[3]
+        bSymbolDefault = 0
+        bSymbolCompati = 0
+    }
 }

 function checkIt() {
-	bad = 0
-	for ( j=0; j<nFormats; ++j )
-	{
-		state = FormatInSymbol( Formats[j] )
-		if ( Formats[j] == "\xc2\xa4" )
-		{
-			bad = 1
-			print "    bad: `" Formats[j] "'   (" FormatLine[j] ")"
-		}
-		else if ( state == 0 )
-		{
-			bad = 1
-			print "unknown: `" Formats[j] "'   (" FormatLine[j] ")"
-		}
-		else if ( FormatAuto[j] && state < 2 )
-		{
-			bad = 1
-			print "badauto: `" Formats[j] "'   (" FormatLine[j] ")"
-		}
-	}
-	if ( bad )
-	{
-		for ( j=0; j<nSymbols; ++j )
-		{
+    bad = 0
+    for ( j=0; j<nFormats; ++j )
+    {
+        state = FormatInSymbol( Formats[j] )
+        if ( Formats[j] == "\xc2\xa4" )
+        {
+            bad = 1
+            print "    bad: `" Formats[j] "'   (" FormatLine[j] ")"
+        }
+        else if ( state == 0 )
+        {
+            bad = 1
+            print "unknown: `" Formats[j] "'   (" FormatLine[j] ")"
+        }
+        else if ( FormatAuto[j] && state < 2 )
+        {
+            bad = 1
+            print "badauto: `" Formats[j] "'   (" FormatLine[j] ")"
+        }
+    }
+    if ( bad )
+    {
+        for ( j=0; j<nSymbols; ++j )
+        {
             bDef = 0
-			if ( Symbols[j] == "\xc2\xa4" )
-				print "def bad: `" Symbols[j] "'   (" SymbolLine[j] ")"
+            if ( Symbols[j] == "\xc2\xa4" )
+                print "def bad: `" Symbols[j] "'   (" SymbolLine[j] ")"
             if ( SymbolDefault[j] )
             {
                 bDef = 1
-				print "default: `" Symbols[j] "'   (" SymbolLine[j] ")"
+                print "default: `" Symbols[j] "'   (" SymbolLine[j] ")"
             }
             if ( SymbolCompati[j] )
             {
@@ -123,20 +194,20 @@
                 print "compati: `" Symbols[j] "'   (" SymbolLine[j] ")"
             }
             if ( !bDef )
-				print "defined: `" Symbols[j] "'   (" SymbolLine[j] ")"
-		}
-	}
-	else
-	{
+                print "defined: `" Symbols[j] "'   (" SymbolLine[j] ")"
+        }
+    }
+    else
+    {
         bHasDefault = 0
         bHasCompati = 0
-		for ( j=0; j<nSymbols; ++j )
-		{
-			if ( Symbols[j] == "\xc2\xa4" )
-			{
-				bad = 1
-				print "def bad: `" Symbols[j] "'   (" SymbolLine[j] ")"
-			}
+        for ( j=0; j<nSymbols; ++j )
+        {
+            if ( Symbols[j] == "\xc2\xa4" )
+            {
+                bad = 1
+                print "def bad: `" Symbols[j] "'   (" SymbolLine[j] ")"
+            }
             if ( SymbolDefault[j] )
             {
                 if ( !bHasDefault )
@@ -157,7 +228,7 @@
                     print "dupe compati: `" Symbols[j] "'   (" SymbolLine[j] ")"
                 }
             }
-		}
+        }
         if ( !bHasDefault )
         {
             bad = 1
@@ -168,22 +239,24 @@
             bad = 1
             print "  no compati: (" file ")"
         }
-	}
-	if ( bad )
-		print ""
+    }
+    if ( bad )
+        print ""
 }

 function FormatInSymbol( format ) {
-	for ( nSym=0; nSym<nSymbols; ++nSym )
-	{
-		if ( format == Symbols[nSym] )
-		{
+    for ( nSym=0; nSym<nSymbols; ++nSym )
+    {
+        if ( format == Symbols[nSym] )
+        {
             if ( SymbolCompati[nSym] )
-				return 2
-			else
-				return 1
-		}
-	}
-	return 0
-}
+                return 2
+            else
+                return 1
+        }
+    }
+    return 0
+}
+
+# vim: ts=4 sw=4 expandtab


Escape $$ in $OpenBSD$, it's not supposed to be expanded.

--- dev/onewire/devlist2h.awk
+++ dev/onewire/devlist2h.awk
@@ -1,4 +1,4 @@
-# $OpenBSD: devlist2h.awk,v 1.1 2006/03/04 16:27:03 grange Exp $
+# $OpenBSD: devlist2h.awk,v 1.2 2006/03/04 16:32:40 grange Exp $

 #
 # Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -25,10 +25,10 @@
 	VERSION = $0
 	gsub("\\$", "", VERSION)

-	printf("/*\t$OpenBSD: devlist2h.awk,v 1.1 2006/03/04 16:27:03 grange Exp $\t*/\n\n" \
+	printf("/*\t\$OpenBSD\$\t*/\n\n" \
 	       "/*\n * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n" \
 	       " *\n * Generated from:\n *\t%s\n */\n\n", VERSION) > hfile
-	printf("/*\t$OpenBSD: devlist2h.awk,v 1.1 2006/03/04 16:27:03 grange Exp $\t*/\n\n" \
+	printf("/*\t\$OpenBSD\$\t*/\n\n" \
 	       "/*\n * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.\n" \
 	       " *\n * Generated from:\n *\t%s\n */\n\n", VERSION) > dfile
 	printf("static const struct onewire_family " \


Remove obsolete tv_season reference

Remove obsolete tv_season reference

--- calculateBBoxShowDurations.awk
+++ calculateBBoxShowDurations.awk
@@ -23,11 +23,6 @@
 # No processing on header and other lines unrelated to shows
 $1 == "" || $1 == "Sortkey" {
     print
-    next
-}
-
-# Don't add seasons to short spreadsheet
-$10 == "tv_season" {
     next
 }


Filter out invalid domain name like "newstarnet.com--NN--".

--- gfwlist2domainlist.awk
+++ gfwlist2domainlist.awk
@@ -49,7 +49,7 @@
 		# IPv4 string
 		print "Skipping line " NR ". " line | "cat >&2"
 		close("cat >&2")
-	} else if (line ~ /^([A-Za-z0-9\-]+\.)+[A-Za-z0-9\-]+$/) {
+	} else if (line ~ /^([A-Za-z0-9\-]+\.)+(xn\-\-)?[A-Za-z0-9]+$/) {
 		domains[++domain_count] = line
 	} else {
 		print "Skipping line " NR ". " line | "cat >&2"


Save rearranged titles

Save rearranged titles

We may later want to prevent renaming "The Queen" and others

--- getBritBoxProgramsFrom-webscraper.awk
+++ getBritBoxProgramsFrom-webscraper.awk
@@ -37,8 +37,10 @@
         HMS = ""

     # Titles starting with "The" should not sort based on "The"
-    if (match (showTitle, /^The /))
+    if (match (showTitle, /^The /)) {
+        print "==> Rearranging " showTitle >> ERROR_FILE
         showTitle = substr(showTitle, 5) ", The"
+    }

     # Indicate different types of programs
     URL ~ /^\/us\/movie\// ? showtype = "M" : showtype = "S"


Check for errors when registering and unregistering firmware modules.  This
prevents the unfortunate situation whereby one might kldload a firmware
module by hand and later kldunload it while a driver still has an open
reference to it.

MFC after:	1 week
Glanced at by:	iedowse

--- sys/tools/fw_stub.awk
+++ sys/tools/fw_stub.awk
@@ -125,7 +125,8 @@
 printc("\nstatic int\n"\
 opt_m "_fw_modevent(module_t mod, int type, void *unused)\
 {\
-	struct firmware *fp;\
+	struct firmware *fp, *parent;\
+	int error;\
 	switch (type) {\
 	case MOD_LOAD:");

@@ -136,11 +137,7 @@
 	# '-', '.' and '/' are converted to '_' by ld/objcopy
 	gsub(/-|\.|\//, "_", symb);

-	if (file_i == 0)
-		reg = "\t\tfp = ";
-	else
-		reg = "\t\t(void)";
-
+	reg = "\t\tfp = ";
 	reg = reg "firmware_register(\"" short "\", _binary_" symb "_start , ";
 	reg = reg "(size_t)(_binary_" symb "_end - _binary_" symb "_start), ";
 	reg = reg version ", ";
@@ -148,21 +145,37 @@
 	if (file_i == 0)
 		reg = reg "NULL);";
 	else
-		reg = reg "fp);";
+		reg = reg "parent);";

 	printc(reg);
-}
-
-printc("\t\treturn (0);\
-	case MOD_UNLOAD:");
+
+	printc("\t\tif (fp == NULL)");
+	printc("\t\t\tgoto fail_" file_i ";");
+	if (file_i == 0)
+		printc("\t\tparent = fp;");
+}
+
+printc("\t\treturn (0);");
+
+for (file_i = num_files - 1; file_i > 0; file_i--) {
+	printc("\tfail_" file_i ":")
+	printc("\t\t(void)firmware_unregister(\"" shortnames[file_i - 1] "\");");
+}
+
+printc("\tfail_0:");
+printc("\t\treturn (ENXIO);");
+
+printc("\tcase MOD_UNLOAD:");

 for (file_i = 1; file_i < num_files; file_i++) {
-	printc("\t\tfirmware_unregister(\"" shortnames[file_i] "\");");
-}
-
-printc("\t\tfirmware_unregister(\"" shortnames[0] "\");");
-
-printc("\t\treturn (0);\
+	printc("\t\terror = firmware_unregister(\"" shortnames[file_i] "\");");
+	printc("\t\tif (error)");
+	printc("\t\t\treturn (error);");
+}
+
+printc("\t\terror = firmware_unregister(\"" shortnames[0] "\");");
+
+printc("\t\treturn (error);\
 	}\
 	return (EINVAL);\
 }\


add all backgrounds in one place

add all backgrounds in one place

--- tools/backgrounds.awk
+++ tools/backgrounds.awk
@@ -7,6 +7,11 @@
   print ""
   print "
"
   print "  "
+  print "  Gabor.Greif@alcatel-lucent.com"
+  print "
"
+  print ""
+  print "
"
+  print "  "
   print "
"
   print ""
 }
@@ -15,12 +20,6 @@
   slidecount++
   if (slidecount == 2)
   {
-    print ""
-    print "
"
-    print "  "
-    print "
"
-    print ""
-
     sub(/slide/, "slide haskell")
   }
 }


Translate: add initAudioPlayer() and initSpeechSynthesizer()

--- lib/Translate.awk
+++ lib/Translate.awk
@@ -1,8 +1,27 @@
 #!/usr/bin/gawk -f

 @include "lib/Commons"
+@include "lib/Languages"
 @include "lib/PLTokenizer"
 @include "lib/PLParser"
+
+# Detect external audio player (mplayer, mpg123).
+function initAudioPlayer() {
+    AudioPlayer = !system("mplayer >/dev/null 2>/dev/null") ?
+        "mplayer" :
+        (!system("mpg123 >/dev/null 2>/dev/null") ?
+         "mpg123" :
+         "")
+}
+
+# Detect external speech synthesizer (say, espeak).
+function initSpeechSynthesizer() {
+    SpeechSynthesizer = !system("say '' >/dev/null 2>/dev/null") ?
+        "say" :
+        (!system("espeak '' >/dev/null 2>/dev/null") ?
+         "espeak" :
+         "")
+}

 # Initialize `HttpService`.
 function initHttpService() {


Function-local variable.

Function-local variable.

--- src/cloudfront.awk
+++ src/cloudfront.awk
@@ -1,4 +1,4 @@
-function printUrlQueryString(queryString)
+function printUrlQueryString(queryString, j)
 {
     split(queryString, pairs, "&", seps)
     len = length(pairs)


Respect setting of NM to allow cross-building.

--- sys/conf/kmod_syms.awk
+++ sys/conf/kmod_syms.awk
@@ -2,7 +2,7 @@

 # Read global symbols from object file.
 BEGIN {
-        while ("nm -g " ARGV[1] | getline) {
+        while ("${NM:='nm'} -g " ARGV[1] | getline) {
                 if (match($0, /^[^[:space:]]+ [^AU] (.*)$/)) {
                         syms[$3] = $2
                 }


Languages: tlhIngan Hol chel!

Languages: tlhIngan Hol chel!

--- include/Languages.awk
+++ include/Languages.awk
@@ -1732,6 +1732,24 @@
     Locale["yua"]["iso"]               = "yua"
     Locale["yua"]["glotto"]            = "yuca1254"
     Locale["yua"]["script"]            = "Latn"
+
+    #* Klingon, Latin alphabet
+    Locale["tlh"]["support"]           = "bing-only"
+    Locale["tlh"]["name"]              = "Klingon"
+    Locale["tlh"]["endonym"]           = "tlhIngan Hol"
+    Locale["tlh"]["family"]            = "Artificial Language"
+    Locale["tlh"]["iso"]               = "tlh"
+    #Locale["tlh"]["glotto"]
+    Locale["tlh"]["script"]            = "Latn"
+
+    #* Klingon, pIqaD
+    Locale["tlh-Qaak"]["support"]      = "bing-only"
+    Locale["tlh-Qaak"]["name"]         = "Klingon (pIqaD)"
+    Locale["tlh-Qaak"]["endonym"]      = " "
+    Locale["tlh-Qaak"]["family"]       = "Artificial Language"
+    Locale["tlh-Qaak"]["iso"]          = "tlh"
+    #Locale["tlh-Qaak"]["glotto"]
+    Locale["tlh-Qaak"]["script"]       = "Piqd"

     for (i in Locale) {
         # Initialize strings for displaying endonyms of locales
@@ -1761,6 +1779,8 @@
     LocaleAlias["zh"]      = "zh-CN" # Chinese: default to Chinese Simplified
     LocaleAlias["zho"]     = "zh-CN"
     LocaleAlias["chinese"] = "zh-CN"
+    LocaleAlias["tlh-Latn"] = "tlh"
+    LocaleAlias["tlh-Piqd"] = "tlh-Qaak"
     # TODO: more aliases
 }

@@ -1893,6 +1913,7 @@
     case "Mlym": return "Malayalam"
     case "Mymr": return "Myanmar"
     case "Orya": return "Oriya"
+    case "Piqd": return "Klingon (pIqaD)"
     case "Sinh": return "Sinhala"
     case "Taml": return "Tamil"
     case "Telu": return "Telugu"


Remove extra spaces

Remove extra spaces

--- misc/rdf-nt.awk
+++ misc/rdf-nt.awk
@@ -45,12 +45,12 @@
             if (!(word in windex)) {
                 windex[word] = wcount++;

-                print "<" URN "w" windex[word] ">", TYPE,          WORD,                             ".";
-                print "<" URN "w" windex[word] ">", LABEL,         "\"" word "\"",                   ".";
-                print "<" URN "f" windex[word] ">", TYPE,          FORM,                             ".";
-                print "<" URN "f" windex[word] ">", LABEL,         "\"" word "\"",                   ".";
-                print "<" URN "f" windex[word] ">", WRITTENREP,    "\"" word "\"",                   ".";
-                print "<" URN "w" windex[word] ">", CANONICALFORM, "<" URN "f" windex[word] ">",     ".";
+                print "<" URN "w" windex[word] ">", TYPE,          WORD,                         ".";
+                print "<" URN "w" windex[word] ">", LABEL,         "\"" word "\"",               ".";
+                print "<" URN "f" windex[word] ">", TYPE,          FORM,                         ".";
+                print "<" URN "f" windex[word] ">", LABEL,         "\"" word "\"",               ".";
+                print "<" URN "f" windex[word] ">", WRITTENREP,    "\"" word "\"",               ".";
+                print "<" URN "w" windex[word] ">", CANONICALFORM, "<" URN "f" windex[word] ">", ".";
             }

             print "<" URN "s" sindex[sense] ">", TYPE,          LEXICALSENSE,                  ".";


Better error formatting, capture warnings too

--- xcodebuild.awk
+++ xcodebuild.awk
@@ -3,12 +3,15 @@
     fflush(stdout)
 }

-/[0-9]+: error:/ {
+/[0-9]+: (error|warning):/ {
     errors = errors $0 "\n"
 }

 /(TEST|BUILD) FAILED/ {
-    print "\n" errors
+    if (length(errors) > 0) {
+        print "\n*** All errors:\n" errors
+    }
+
     fflush(stdout)

     # SYS_SOFTWARE


properly treat /*dev-only-stop*/ marker

properly treat /*dev-only-stop*/ marker

--- nodev.awk
+++ nodev.awk
@@ -7,9 +7,11 @@
   print "// dev-only: " $0;
   getline;
   while (index($0, "/*dev-only-stop*/") == 0) {
+      print "// dev-only: " $0;
       getline;
-      print "// dev-only: " $0;
   }
+  print "// dev-only: " $0;
+  getline;
 }

 /\/\*dev-only\*\// {


translate.awk: update disclaimer

translate.awk: update disclaimer

--- translate.awk
+++ translate.awk
@@ -1,30 +1,27 @@
 #!/usr/bin/gawk -f

-# This is free and unencumbered software released into the
-# public domain.
+# This is free and unencumbered software released into the public domain.
 #
-# This software is provided for the purpose of personal, reasonable
-# and convenient human use of the Google Translate Service, i.e.,
-# only for those who feel that their terminal is more accessible
-# than a web browser. For other purposes, please use the official
-# Google Translate API <https://developers.google.com/translate/>.
+# This software is provided for the purpose of reasonable personal use of
+# the Google Translate service, i.e., for those who prefer command line to
+# web interface. For other purposes, please refer to the official Google
+# Translate API <https://developers.google.com/translate/>.
 #
-# By using this software, you ("the user") agree that:
+# By using this software, you ("the user") are aware that:
 #
-# 1. Neither this software nor its author is affiliated with
-# Google Inc. ("Google").
+# 1. Google Translate is a proprietary service provided and owned by
+# Google Inc.
 #
-# 2. By using this software, the user is de facto using web
-# services provided by Google, therefore they are obliged to
-# follow the Google Terms of Service.
+# 2. Translate Shell is NOT a Google product. Neither this software nor
+# its author is affiliated with Google Inc.
 #
-# 3. This software is provided "as is". The user of this software
-# shall be fully liable for any possible infringement of, including
-# but not limited to, the Google Terms of Service; per contra,
-# the user must be aware that their data might be collected by
-# Google, therefore they shall be liable for their own privacy
-# concern, including but not limited to, possible disclosure of
-# personal information. See the (un)LICENSE file for more details.
+# 3. The software is provided "AS IS", without warranty of any kind,
+# express or implied, including but not limited to the warranties of
+# merchantability, fitness for a particular purpose and noninfringement. In
+# no event shall the authors be liable for any claim, damages or other
+# liability, whether in an action of contract, tort or otherwise, arising
+# from, out of or in connection with the software or the use or other
+# dealings in the software.

 @include "metainfo"


Add placeholder for back field.

Add placeholder for back field.

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


Revise "Maigret" title to clarify timeframe

--- getBBoxCatalogFrom-sitemap.awk
+++ getBBoxCatalogFrom-sitemap.awk
@@ -43,8 +43,8 @@
     split ($0,fld,"\"")
     contentType = fld[2]
     contentId = fld[4]
-    # print "contentType = " contentType
-    # print "contentId = " contentId
+    # print "contentType = " contentType  > "/dev/stderr"
+    # print "contentId = " contentId  > "/dev/stderr"
     # Make sure no fields will be carried over due to missing keys
     sortkey = ""
     title = ""
@@ -72,7 +72,7 @@
 /<title locale="en-US">/ {
     split ($0,fld,"[<>]")
     title = fld[3]
-    # print "title = " title
+    # print "title = " title  > "/dev/stderr"
 }

 # Grab genre
@@ -80,7 +80,7 @@
 /<genre>/ {
     split ($0,fld,"[<>]")
     genre = fld[3]
-    # print "genre = " genre
+    # print "genre = " genre  > "/dev/stderr"
 }

 # Grab description
@@ -88,7 +88,7 @@
 /<description>/ {
     split ($0,fld,"[<>]")
     description = fld[3]
-    # print "description = " description
+    # print "description = " description  > "/dev/stderr"
 }

 # Grab rating
@@ -96,7 +96,7 @@
 /<rating systemCode=/ {
     split ($0,fld,"[<>]")
     rating = fld[3]
-    # print "rating = " rating
+    # print "rating = " rating  > "/dev/stderr"
 }

 # Grab type
@@ -104,7 +104,7 @@
 /<type>/ {
     split ($0,fld,"[<>]")
     showType = fld[3]
-    # print "showType = " showType
+    # print "showType = " showType  > "/dev/stderr"
 }

 # Grab duration
@@ -112,7 +112,7 @@
 /<duration>/ {
     split ($0,fld,"[<>]")
     duration = fld[3]
-    # print "duration = " duration
+    # print "duration = " duration  > "/dev/stderr"
 }

 # Grab originalDate
@@ -125,9 +125,9 @@
     sub (/original/,"",dateType)
     originalDate = fld[3]
     year = substr (originalDate,1,4)
-    # print "dateType = " dateType
-    # print "originalDate = " originalDate
-    # print "year = " year
+    # print "dateType = " dateType  > "/dev/stderr"
+    # print "originalDate = " originalDate  > "/dev/stderr"
+    # print "year = " year  > "/dev/stderr"
 }

 # Grab showContentId
@@ -135,7 +135,7 @@
 /<showContentId>/ {
     split ($0,fld,"[<>]")
     showContentId = fld[3]
-    # print "showContentId = " showContentId
+    # print "showContentId = " showContentId  > "/dev/stderr"
 }

 # Grab seasonContentId
@@ -143,7 +143,7 @@
 /<seasonContentId>/ {
     split ($0,fld,"[<>]")
     seasonContentId = fld[3]
-    # print "seasonContentId = " seasonContentId
+    # print "seasonContentId = " seasonContentId  > "/dev/stderr"
 }

 # Grab seasonNumber
@@ -151,7 +151,7 @@
 /<seasonNumber>/ {
     split ($0,fld,"[<>]")
     seasonNumber = fld[3]
-    # print "seasonNumber = " seasonNumber
+    # print "seasonNumber = " seasonNumber  > "/dev/stderr"
 }

 # Grab episodeNumber
@@ -159,7 +159,7 @@
 /<episodeNumber>/ {
     split ($0,fld,"[<>]")
     episodeNumber = fld[3]
-    # print "episodeNumber = " episodeNumber
+    # print "episodeNumber = " episodeNumber  > "/dev/stderr"
 }

 # Grab EntityId from artwork
@@ -168,17 +168,19 @@
     sub (/.*EntityId='/,"")
     sub (/&apos.*/,"")
     EntityId = "_" $0
-    # print "EntityId = " EntityId
+    # print "EntityId = " EntityId  > "/dev/stderr"
     next
 }

 # Do any special end of item processing, then print raw data spreadsheet row
 /<\/item>/ {
+    # Add missing EntityId
     if (title == "Shallow Grave") {
         EntityId = "_23576"
-        # print "==> EntityId = " EntityId
-    }
-
+        # print "==> EntityId = " EntityId  > "/dev/stderr"
+    }
+
+    # "Porridge" needs to be revised to avoid duplicate names
     if (title == "Porridge") {
         if (EntityId == "_9509") {
             revisedTitles += 1
@@ -189,10 +191,13 @@
             printf ("==> Changed title '%s' to 'Porridge (2016-2017)'\n", title) >> ERROR_FILE
             title = "Porridge (2016-2017)"
         }
-        # print "==> title = " title
-        # print "==> EntityId = " EntityId
-    }
-
+        # print "==> title = " title  > "/dev/stderr"
+        # print "==> contentId = " contentId  > "/dev/stderr"
+        # print "==> EntityId = " EntityId  > "/dev/stderr"
+        # print "---"  > "/dev/stderr"
+    }
+
+    # "A Midsummer Night's Dream" needs to be revised to avoid duplicate names
     if (title == "A Midsummer Night's Dream") {
         if (EntityId == "_26179") {
             revisedTitles += 1
@@ -203,13 +208,31 @@
             printf ("==> Changed title '%s' to 'A Midsummer Night\'s Dream (2016)'\n", title) >> ERROR_FILE
             title = "A Midsummer Night's Dream (2016)"
         }
-        # print "==> title = " title
-        # print "==> EntityId = " EntityId
+        # print "==> title = " title  > "/dev/stderr"
+        # print "==> EntityId = " EntityId  > "/dev/stderr"
+    }
+
+    # "Maigret" needs to be revised to clarify timeframe
+    if (title ~ /^Maigret/ && contentType == "tv_show") {
+        if (EntityId == "_15928") {
+            revisedTitles += 1
+            printf ("==> Changed title '%s' to 'Maigret (1992-1993)'\n", title) >> ERROR_FILE
+            title = "Maigret (1992-1993)"
+        } else if (EntityId == "_15974") {
+            revisedTitles += 1
+            printf ("==> Changed title '%s' to 'Maigret (2016–2017)'\n", title) >> ERROR_FILE
+            title = "Maigret (2016–2017)"
+        }
+        # print "==> title = " title  > "/dev/stderr"
+        # print "==> originalDate = " originalDate  > "/dev/stderr"
+        # print "==> contentId = " contentId  > "/dev/stderr"
+        # print "==> EntityId = " EntityId  > "/dev/stderr"
+        # print "---"  > "/dev/stderr"
     }

     if (contentId == "p07gnw9f") {
         EntityId = "_23842"
-        # print "==> EntityId = " EntityId
+        # print "==> EntityId = " EntityId  > "/dev/stderr"
     }

     if (contentType == "movie") {


同じmodule/actionのルーティング名が複数ある場合に変換しない

同じmodule/actionのルーティング名が複数ある場合に変換しない

--- routename_auto_converter_2.awk
+++ routename_auto_converter_2.awk
@@ -6,13 +6,14 @@
   module_and_action = $1
   route_name = $2

-  if (table[module_and_action]) next
   table[module_and_action] = route_name
+  count[module_and_action]++;
 }

 END {
   printf("/include_partial/b\n"); # skip (until the end of sed script) if "include_partial"
   for (module_and_action in table) {
+    if (count[module_and_action] > 1) continue
     route_name = table[module_and_action]
     printf("s|'%s\\([\\?']\\)|'@%s\\1|g\n", module_and_action, route_name)
   }


compile: make version_gen work on alpine


LanguageData: update section N

LanguageData: update section N

--- include/LanguageData.awk
+++ include/LanguageData.awk
@@ -1609,8 +1609,9 @@
     Locale["mr"]["spoken-in"]          = "the Indian state of Maharashtra"
     Locale["mr"]["supported-by"]       = "google; bing; yandex"

-    # Eastern Mari / Meadow Mari
+    # Mari (Eastern Mari / Meadow Mari)
     Locale["mhr"]["name"]              = "Eastern Mari"
+    Locale["mhr"]["name2"]             = "Meadow Mari"
     Locale["mhr"]["endonym"]           = "Олык марий"
     #Locale["mhr"]["translations-of"]
     #Locale["mhr"]["definitions-of"]
@@ -1709,9 +1710,7 @@
     Locale["my"]["spoken-in"]          = "Myanmar"
     Locale["my"]["supported-by"]       = "google; bing; yandex"

-
-
-    #67 Nepali
+    # Nepali
     Locale["ne"]["name"]               = "Nepali"
     Locale["ne"]["endonym"]            = "नेपाली"
     Locale["ne"]["translations-of"]    = "%sका अनुवाद"
@@ -1720,11 +1719,14 @@
     Locale["ne"]["examples"]           = "उदाहरणहरु"
     Locale["ne"]["see-also"]           = "यो पनि हेर्नुहोस्"
     Locale["ne"]["family"]             = "Indo-European"
+    Locale["ne"]["branch"]             = "Indo-Aryan"
     Locale["ne"]["iso"]                = "nep"
     Locale["ne"]["glotto"]             = "nepa1254"
     Locale["ne"]["script"]             = "Deva"
-
-    #68 Norwegian
+    Locale["ne"]["spoken-in"]          = "Nepal; India"
+    Locale["ne"]["supported-by"]       = "google; bing; yandex"
+
+    # Norwegian
     Locale["no"]["name"]               = "Norwegian"
     Locale["no"]["endonym"]            = "Norsk"
     Locale["no"]["translations-of"]    = "Oversettelser av %s"
@@ -1733,9 +1735,14 @@
     Locale["no"]["examples"]           = "Eksempler"
     Locale["no"]["see-also"]           = "Se også"
     Locale["no"]["family"]             = "Indo-European"
+    Locale["no"]["branch"]             = "North Germanic"
     Locale["no"]["iso"]                = "nor"
     Locale["no"]["glotto"]             = "norw1258"
     Locale["no"]["script"]             = "Latn"
+    Locale["no"]["spoken-in"]          = "Norway"
+    Locale["no"]["supported-by"]       = "google; bing; yandex"
+
+

     #69 Odia / Oriya
     Locale["or"]["name"]               = "Odia"


Also considers introduced var arrays now


some simplifications, checkpoint

some simplifications, checkpoint


Fix the pair generation and also speed up the sorting

--- pairs.awk
+++ pairs.awk
@@ -1,6 +1,7 @@
 #!/usr/bin/awk -f
 BEGIN {
-    FS = OFS = "\t";
+    FS  = "\t";
+    OFS = "";
 }
 {
     len = split($3, words, ", ");
@@ -9,7 +10,7 @@

     for (i = 1; i <= len - 1; i++) {
         for (j = i + 1; j <= len; j++) {
-            print words[i], words[j], ORS, words[j], words[i] | "sort --parallel=$(nproc) -us";
+            print words[i], FS, words[j], ORS, words[j], FS, words[i] | "sort --parallel=$(nproc) -S1G -us";
         }
     }
 }


remove debug line

remove debug line

--- lib/config.awk
+++ lib/config.awk
@@ -29,7 +29,6 @@
     ext = exts[i]
     gsub(/ /, "", ext)
     filter[ext] = cmd
-    print cmd >> "awk.log"
   }
   next
 }


Fix for translating flatzinc where the output variables are indices of a var array.

--- fzn/fzn2py.awk
+++ fzn/fzn2py.awk
@@ -243,18 +243,32 @@
 	objective_type = "Maximize";
 }

+function trimvarindex(s) {
+	ind = index(s, "[");
+	if(ind > 0) {
+		return substr(s, 1, ind - 1);
+	}
+	return s;
+}
+
 END {
 	if (!error) {
-	output_vars = "";
-	if(objective) output_vars = objective;
+
+	# Create an array vars_array, keyed with the output variable names so that
+	# we output a set of unique variable names. We will also trim indexed vars.
+	if(objective) vars_array[trimvarindex(objective)] = 1;

 	n = asorti(output,varnames);
 	for (i=1; i<=n; i++) {
 		e = varnames[i];
 		if(e != objective) {
-			if(length(output_vars) > 0) output_vars = output_vars ", ";
-			output_vars = output_vars e;
-		}
+			vars_array[trimvarindex(e)] = 1;
+		}
+	}
+	output_vars = sep = "";
+	for (x in vars_array) {
+	    output_vars = output_vars sep x;
+	    sep = ", ";
 	}
 	print "    output_vars = (" output_vars ")";
 	print "    return model, output_vars";


grammar fix

grammar fix

--- lib/render.awk
+++ lib/render.awk
@@ -130,7 +130,7 @@
   return rendered_txt
 }

-# Prevent awk from replacing ampersand's with matched text
+# Prevent awk from replacing ampersands with matched text
 function escape_special_chars(  txt) {
   gsub(/&/, "\\\\&", txt)
   return txt


parse: add data validation to parser.

parse: add data validation to parser.

--- parse.awk
+++ parse.awk
@@ -1,3 +1,10 @@
+function validate_time(s) {
+	if (s !~ /^[0-9]+:[0-9]+/) {
+		printf "ERROR: Wrong input data! [%s]\n", s;
+		exit 1
+	}
+}
+
 BEGIN {
 	skipped_first = 0
 	skipped_first_right = 0
@@ -28,6 +35,8 @@

 	getline
 	while ($1 != "</div>") {
+		validate_time($1);
+		validate_time($3);
 		print $1 " - " substr($3, 0, length($3)-4)
 		getline
 	}


Allow -d and -h as command line flags.  These are used to generate only the .h or _data.h files respectively.  Restructure code to allow for this.

--- sys/tools/usbdevs2h.awk
+++ sys/tools/usbdevs2h.awk
@@ -30,207 +30,244 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
+function usage()
+{
+	print "usage: usbdevs2h.awk <srcfile> [-d|-h]";
+	exit 1;
+}
+
 BEGIN {
-	nproducts = nvendors = 0
-	dfile="usbdevs_data.h"
-	hfile="usbdevs.h"
-}
-NR == 1 {
+
+nproducts = nvendors = 0
+# Process the command line
+for (i = 1; i < ARGC; i++) {
+	arg = ARGV[i];
+	if (arg !~ /^-[dh]+$/ && arg !~ /devs$/)
+		usage();
+	if (arg ~ /^-.*d/)
+		dfile="usbdevs_data.h"
+	if (arg ~ /^-.*h/)
+		hfile="usbdevs.h"
+	if (arg ~ /devs$/)
+		srcfile = arg;
+}
+ARGC = 1;
+line=0;
+
+while ((getline < srcfile) > 0) {
+    line++;
+    if (line == 1) {
 	VERSION = $0
 	gsub("\\$", "", VERSION)

-	if (os == "NetBSD")
-		printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
-	else if (os == "FreeBSD")
-		printf("/* \$FreeBSD\$ */\n\n") > dfile
-	else if (os == "OpenBSD")
-		printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
-	else
-		printf("/* ??? */\n\n") > dfile
-	printf("/*\n") > dfile
-	printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
-	    > dfile
-	printf(" *\n") > dfile
-	printf(" * generated from:\n") > dfile
-	printf(" *\t%s\n", VERSION) > dfile
-	printf(" */\n") > dfile
-
-	if (os == "NetBSD")
-		printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
-	else if (os == "FreeBSD")
-		printf("/* \$FreeBSD\$ */\n\n") > hfile
-	else if (os == "OpenBSD")
-		printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
-	else
-		printf("/* ??? */\n\n") > hfile
-	printf("/*\n") > hfile
-	printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
-	    > hfile
-	printf(" *\n") > hfile
-	printf(" * generated from:\n") > hfile
-	printf(" *\t%s\n", VERSION) > hfile
-	printf(" */\n") > hfile
-
-	next
-}
-$1 == "vendor" {
+	if (dfile) {
+		if (os == "NetBSD")
+			printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
+		else if (os == "FreeBSD")
+			printf("/* \$FreeBSD\$ */\n\n") > dfile
+		else if (os == "OpenBSD")
+			printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
+		else
+			printf("/* ??? */\n\n") > dfile
+		printf("/*\n") > dfile
+		printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
+		    > dfile
+		printf(" *\n") > dfile
+		printf(" * generated from:\n") > dfile
+		printf(" *\t%s\n", VERSION) > dfile
+		printf(" */\n") > dfile
+	}
+
+	if (hfile) {
+		if (os == "NetBSD")
+			printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
+		else if (os == "FreeBSD")
+			printf("/* \$FreeBSD\$ */\n\n") > hfile
+		else if (os == "OpenBSD")
+			printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
+		else
+			printf("/* ??? */\n\n") > hfile
+		printf("/*\n") > hfile
+		printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
+		    > hfile
+		printf(" *\n") > hfile
+		printf(" * generated from:\n") > hfile
+		printf(" *\t%s\n", VERSION) > hfile
+		printf(" */\n") > hfile
+	}
+	continue;
+    }
+   if ($1 == "vendor") {
 	nvendors++

 	vendorindex[$2] = nvendors;		# record index for this name, for later.
 	vendors[nvendors, 1] = $2;		# name
 	vendors[nvendors, 2] = $3;		# id
-	printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
-	    vendors[nvendors, 2]) > hfile
-
+	if (hfile)
+		printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
+		    vendors[nvendors, 2]) > hfile
 	i = 3; f = 4;

 	# comments
 	ocomment = oparen = 0
 	if (f <= NF) {
-		printf("\t/* ") > hfile
+		if (hfile)
+			printf("\t/* ") > hfile
 		ocomment = 1;
 	}
 	while (f <= NF) {
 		if ($f == "#") {
-			printf("(") > hfile
+			if (hfile)
+				printf("(") > hfile
 			oparen = 1
 			f++
 			continue
 		}
 		if (oparen) {
-			printf("%s", $f) > hfile
-			if (f < NF)
+			if (hfile)
+				printf("%s", $f) > hfile
+			if (f < NF && hfile)
 				printf(" ") > hfile
 			f++
 			continue
 		}
 		vendors[nvendors, i] = $f
-		printf("%s", vendors[nvendors, i]) > hfile
-		if (f < NF)
+		if (hfile)
+			printf("%s", vendors[nvendors, i]) > hfile
+		if (f < NF && hfile)
 			printf(" ") > hfile
 		i++; f++;
 	}
-	if (oparen)
+	if (oparen && hfile)
 		printf(")") > hfile
-	if (ocomment)
+	if (ocomment && hfile)
 		printf(" */") > hfile
-	printf("\n") > hfile
-
-	next
-}
-$1 == "product" {
+	if (hfile)
+		printf("\n") > hfile
+
+	continue;
+    }
+    if ($1 == "product") {
 	nproducts++

 	products[nproducts, 1] = $2;		# vendor name
 	products[nproducts, 2] = $3;		# product id
 	products[nproducts, 3] = $4;		# id
-	printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
-	    products[nproducts, 2], products[nproducts, 3]) > hfile
+	if (hfile)
+		printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", \
+		  products[nproducts, 1], products[nproducts, 2], \
+		  products[nproducts, 3]) > hfile

 	i=4; f = 5;

 	# comments
 	ocomment = oparen = 0
 	if (f <= NF) {
-		printf("\t/* ") > hfile
+		if (hfile)
+			printf("\t/* ") > hfile
 		ocomment = 1;
 	}
 	while (f <= NF) {
 		if ($f == "#") {
-			printf("(") > hfile
+			if (hfile)
+				printf("(") > hfile
 			oparen = 1
 			f++
 			continue
 		}
 		if (oparen) {
-			printf("%s", $f) > hfile
-			if (f < NF)
+			if (hfile)
+				printf("%s", $f) > hfile
+			if (f < NF && hfile)
 				printf(" ") > hfile
 			f++
 			continue
 		}
 		products[nproducts, i] = $f
-		printf("%s", products[nproducts, i]) > hfile
-		if (f < NF)
+		if (hfile)
+			printf("%s", products[nproducts, i]) > hfile
+		if (f < NF && hfile)
 			printf(" ") > hfile
 		i++; f++;
 	}
-	if (oparen)
+	if (oparen && hfile)
 		printf(")") > hfile
-	if (ocomment)
+	if (ocomment && hfile)
 		printf(" */") > hfile
-	printf("\n") > hfile
-
-	next
-}
-{
+	if (hfile)
+		printf("\n") > hfile
+
+	continue;
+    }
 	if ($0 == "")
 		blanklines++
-	print $0 > hfile
-	if (blanklines < 2)
-		print $0 > dfile
-}
-END {
+	if (hfile)
+		print $0 > hfile
+	if (blanklines < 2 && dfile)
+	    print $0 > dfile
+}
 	# print out the match tables

-	printf("\n") > dfile
-
-	printf("const struct usb_knowndev usb_knowndevs[] = {\n") > dfile
-	for (i = 1; i <= nproducts; i++) {
-		printf("\t{\n") > dfile
-		printf("\t    USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
-		    products[i, 1], products[i, 1], products[i, 2]) \
-		    > dfile
-		printf("\t    ") > dfile
-		printf("0") > dfile
-		printf(",\n") > dfile
-
-		vendi = vendorindex[products[i, 1]];
-		printf("\t    \"") > dfile
-		j = 3;
-		needspace = 0;
-		while (vendors[vendi, j] != "") {
-			if (needspace)
-				printf(" ") > dfile
-			printf("%s", vendors[vendi, j]) > dfile
-			needspace = 1
-			j++
-		}
-		printf("\",\n") > dfile
-
-		printf("\t    \"") > dfile
-		j = 4;
-		needspace = 0;
-		while (products[i, j] != "") {
-			if (needspace)
-				printf(" ") > dfile
-			printf("%s", products[i, j]) > dfile
-			needspace = 1
-			j++
-		}
-		printf("\",\n") > dfile
-		printf("\t},\n") > dfile
-	}
-	for (i = 1; i <= nvendors; i++) {
-		printf("\t{\n") > dfile
-		printf("\t    USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
-		    > dfile
-		printf("\t    USB_KNOWNDEV_NOPROD,\n") \
-		    > dfile
-		printf("\t    \"") > dfile
-		j = 3;
-		needspace = 0;
-		while (vendors[i, j] != "") {
-			if (needspace)
-				printf(" ") > dfile
-			printf("%s", vendors[i, j]) > dfile
-			needspace = 1
-			j++
-		}
-		printf("\",\n") > dfile
-		printf("\t    NULL,\n") > dfile
-		printf("\t},\n") > dfile
-	}
-	printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
-	printf("};\n") > dfile
-}
+	if (dfile) {
+		printf("\n") > dfile
+
+		printf("const struct usb_knowndev usb_knowndevs[] = {\n") > dfile
+		for (i = 1; i <= nproducts; i++) {
+			printf("\t{\n") > dfile
+			printf("\t    USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
+			    products[i, 1], products[i, 1], products[i, 2]) \
+			    > dfile
+			printf("\t    ") > dfile
+			printf("0") > dfile
+			printf(",\n") > dfile
+
+			vendi = vendorindex[products[i, 1]];
+			printf("\t    \"") > dfile
+			j = 3;
+			needspace = 0;
+			while (vendors[vendi, j] != "") {
+				if (needspace)
+					printf(" ") > dfile
+				printf("%s", vendors[vendi, j]) > dfile
+				needspace = 1
+				j++
+			}
+			printf("\",\n") > dfile
+
+			printf("\t    \"") > dfile
+			j = 4;
+			needspace = 0;
+			while (products[i, j] != "") {
+				if (needspace)
+					printf(" ") > dfile
+				printf("%s", products[i, j]) > dfile
+				needspace = 1
+				j++
+			}
+			printf("\",\n") > dfile
+			printf("\t},\n") > dfile
+		}
+		for (i = 1; i <= nvendors; i++) {
+			printf("\t{\n") > dfile
+			printf("\t    USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
+			    > dfile
+			printf("\t    USB_KNOWNDEV_NOPROD,\n") \
+			    > dfile
+			printf("\t    \"") > dfile
+			j = 3;
+			needspace = 0;
+			while (vendors[i, j] != "") {
+				if (needspace)
+					printf(" ") > dfile
+				printf("%s", vendors[i, j]) > dfile
+				needspace = 1
+				j++
+			}
+			printf("\",\n") > dfile
+			printf("\t    NULL,\n") > dfile
+			printf("\t},\n") > dfile
+		}
+		printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
+		printf("};\n") > dfile
+	}
+}


INTEGRATION: CWS changefileheader (1.5.1038); FILE MERGED 2008/03/28 15:55:26 rt 1.5.1038.1: #i87441# Change license header to LPGL v3.

--- solenv/bin/getcsym.awk
+++ solenv/bin/getcsym.awk
@@ -1,35 +1,31 @@
 #*************************************************************************
 #
-#   OpenOffice.org - a multi-platform office productivity suite
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
 #
-#   $RCSfile: getcsym.awk,v $
+# OpenOffice.org - a multi-platform office productivity suite
 #
-#   $Revision: 1.5 $
+# $RCSfile: getcsym.awk,v $
 #
-#   last change: $Author: rt $ $Date: 2005-09-07 22:09:22 $
+# $Revision: 1.6 $
 #
-#   The Contents of this file are made available subject to
-#   the terms of GNU Lesser General Public License Version 2.1.
+# This file is part of OpenOffice.org.
 #
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
 #
-#     GNU Lesser General Public License Version 2.1
-#     =============================================
-#     Copyright 2005 by Sun Microsystems, Inc.
-#     901 San Antonio Road, Palo Alto, CA 94303, USA
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
 #
-#     This library is free software; you can redistribute it and/or
-#     modify it under the terms of the GNU Lesser General Public
-#     License version 2.1, as published by the Free Software Foundation.
-#
-#     This library is distributed in the hope that it will be useful,
-#     but WITHOUT ANY WARRANTY; without even the implied warranty of
-#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#     Lesser General Public License for more details.
-#
-#     You should have received a copy of the GNU Lesser General Public
-#     License along with this library; if not, write to the Free Software
-#     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-#     MA  02111-1307  USA
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
 #
 #*************************************************************************


accumulate hints and print lookup at the end of hinter

--- scripts/hinter.awk
+++ scripts/hinter.awk
@@ -109,6 +109,7 @@
   hint_format = "\033[1;33m[%s]\033[0m"
   highlight_format = "\033[1;33m%s\033[0m "
   printf "%s\n", finger_patterns | "cat 1>&4"
+  hint_lookup = ""
 }

 {
@@ -142,8 +143,12 @@

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

-    printf hint ":" line_match "\n" | "cat 1>&3"
+    hint_lookup = hint_lookup hint ":" line_match "\n"
   }

   printf "\n%s", output_line
 }
+
+END {
+  print hint_lookup | "cat 1>&3"
+}


Fix missing braces

Fix missing braces

--- verifyBBoxInfoFrom-webscraper.awk
+++ verifyBBoxInfoFrom-webscraper.awk
@@ -51,11 +51,12 @@

 /^         / {
     epis  = NF-1
-    if ($epis !~ /^[[:digit:]]*$/)
+    if ($epis !~ /^[[:digit:]]*$/) {
         print "    Bad input line " NR ":\n" $0
-    else
+    } else {
         seasonsFound[numShows] += 1
-    episodesInSeasons[numShows] += $epis
+        episodesInSeasons[numShows] += $epis
+    }
 }

 END {


Insert \ before # for auto-indent.

Insert \ before # for auto-indent.


the content we define, decide for names and labels includer is

--- arch/hppa/dev/devlist2h.awk
+++ arch/hppa/dev/devlist2h.awk
@@ -1,7 +1,7 @@
-#	$OpenBSD: devlist2h.awk,v 1.3 2000/02/09 07:23:19 mickey Exp $
+#	$OpenBSD: devlist2h.awk,v 1.4 2001/03/29 00:43:00 mickey Exp $

 #
-# Copyright (c) 1998-2000 Michael Shalayeff
+# Copyright (c) 1998-2001 Michael Shalayeff
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -65,9 +65,6 @@
 	       " * generated from:\n *\t%s\n */\n\n", VERSION) > cpud;
 	printf("/*\n * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n" \
 	       " * generated from:\n *\t%s\n */\n\n", VERSION) > cpuh;
-
-	printf("static const struct hppa_mod_info hppa_knownmods[] = {\n")\
-		> cpud;
 }

 $1 == "type"	{
@@ -80,7 +77,7 @@
 	if (tolower($1) in types) {
 		printf("#define\tHPPA_%s_%s\t%s\n", toupper($1),
 		       toupper($2), $3) > cpuh;
-		printf("\t{HPPA_TYPE_%s,\tHPPA_%s_%s,\t\"", toupper($1),
+		printf("{HPPA_TYPE_%s,\tHPPA_%s_%s,\t\"", toupper($1),
 		       toupper($1), toupper($2), $3) > cpud;
 		f = 4;
 		while (f <= NF) {
@@ -121,6 +118,6 @@
 		print("unteminated comment at the EOF\n");
 		exit(1);
 	}
-	printf("\t{ -1 }\n};\n") > cpud;
+	printf("{ -1 }\n") > cpud;
 }


Handle cases where system time is adjusted backwards (e.g. by NTP).

--- recipes-core/systemd/systemd-units/candump.awk
+++ recipes-core/systemd/systemd-units/candump.awk
@@ -5,8 +5,20 @@
         printf(";$FILEVERSION=1.3\n")
         printf(";$STARTTIME=%u.%u\n", mktime(strftime("%Y %m %d 0 0 0", startTimestamp)) / 86400 + 25569, \
                 10000000000 / 86400 * (mktime(strftime("%Y %m %d %H %M %S", startTimestamp)) - mktime(strftime("%Y %m %d 0 0 0", startTimestamp))))
+        currentTimeOffset = 0.0
     }
-    printf("%u) %.3f 1 Rx %s - %s", NR, (substr($1, 2, length($1) - 2) - startTimestamp) * 1000, $3, substr($4, 2, length($4) - 2))
+    else
+    {
+        previousTimeOffset = currentTimeOffset
+        currentTimestamp = substr($1, 2, length($1) - 2)
+        currentTimeOffset = currentTimestamp - startTimestamp
+        if (currentTimeOffset < 0)
+        {
+            startTimestamp = currentTimestamp + currentTimeOffset
+            currentTimeOffset = previousTimeOffset
+        }
+    }
+    printf("%u) %.3f 1 Rx %s - %s", NR, currentTimeOffset * 1000, $3, substr($4, 2, length($4) - 2))
     if (5<=NF)
     {
         for(i=5;i<=NF;i++)


LanguageData: update section O

LanguageData: update section O

--- include/LanguageData.awk
+++ include/LanguageData.awk
@@ -1742,9 +1742,7 @@
     Locale["no"]["spoken-in"]          = "Norway"
     Locale["no"]["supported-by"]       = "google; bing; yandex"

-
-
-    #69 Odia / Oriya
+    # Odia / Oriya
     Locale["or"]["name"]               = "Odia"
     Locale["or"]["name2"]              = "Oriya"
     Locale["or"]["endonym"]            = "ଓଡ଼ିଆ"
@@ -1754,9 +1752,12 @@
     #Locale["or"]["examples"]
     #Locale["or"]["see-also"]
     Locale["or"]["family"]             = "Indo-European"
+    Locale["or"]["branch"]             = "Indo-Aryan"
     Locale["or"]["iso"]                = "ori"
     Locale["or"]["glotto"]             = "macr1269"
     Locale["or"]["script"]             = "Orya"
+    Locale["or"]["spoken-in"]          = "the Indian state of Odisha"
+    Locale["or"]["supported-by"]       = "google; bing"

     # Oromo
     Locale["om"]["name"]               = "Oromo"
@@ -1767,9 +1768,14 @@
     #Locale["om"]["examples"]
     #Locale["om"]["see-also"]
     Locale["om"]["family"]             = "Afro-Asiatic"
+    Locale["om"]["branch"]             = "Cushitic"
     Locale["om"]["iso"]                = "orm"
     Locale["om"]["glotto"]             = "nucl1736"
     Locale["om"]["script"]             = "Latn"
+    Locale["om"]["spoken-in"]          = "the Ethiopian state of Oromia; northeastern Kenya"
+    Locale["om"]["supported-by"]       = "google"
+
+

     #70 Pashto / Pushto
     Locale["ps"]["name"]               = "Pashto"


TRANSLATE_PS -> TRANS_PS, TRANSLATE_PS_COLOR -> TRANS_PS_COLOR

--- include/Main.awk
+++ include/Main.awk
@@ -44,8 +44,8 @@

     Option["interactive"] = 0
     Option["no-rlwrap"] = 0
-    Option["prompt"] = ENVIRON["TRANSLATE_PS"] ? ENVIRON["TRANSLATE_PS"] : "%s>"
-    Option["prompt-color"] = ENVIRON["TRANSLATE_PS_COLOR"] ? ENVIRON["TRANSLATE_PS_COLOR"] : "blue"
+    Option["prompt"] = ENVIRON["TRANS_PS"] ? ENVIRON["TRANS_PS"] : "%s>"
+    Option["prompt-color"] = ENVIRON["TRANS_PS_COLOR"] ? ENVIRON["TRANS_PS_COLOR"] : "blue"

     Option["input"] = ""
     Option["output"] = "/dev/stdout"


handle one line struct {}, multiline comments, whitespaces when parsing header for structs

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

--- mkstructinfo.awk
+++ mkstructinfo.awk
@@ -2,11 +2,35 @@
 # vim:ts=4:sw=4
 BEGIN {
 	brace = 0;
+	incomment = 0;
 	buffer_len = 0;
 }
+
+# multiline comment handling
+{
+	# removes one line comment
+	gsub(/\/\*(.+?)\*\//, " ");
+}
+/\*\// {
+	if (incomment) {
+		sub(/.*\*\//, "");
+		incomment = 0;
+	}
+}
+incomment {
+	next;
+}
+/\/\*/ {
+	sub(/\/\*.*/, "");
+	incomment = 1;
+	# fall through
+}
+
+# skip file/line mark here to be faster
 /^#/ {
 	next;
 }
+
 /^}.*;/ {
 	if (instruct) {
 		sub(";", "");
@@ -53,7 +77,7 @@

 {
 	if (brace == 1 && instruct) {
-		gsub(/\/\*(.+?)\*\//, " "); # removes one line comment
+		gsub(/(^[\t ]+|[\t ]+$)/, ""); # trim whitespaces
 		sub(/.*[{}]/, "");
 		gsub(/\[[^\]]+\]/, ""); # ignore [...]
 		gsub(/:[0-9]+/, ""); # ignore struct bit
@@ -66,6 +90,8 @@
 			buffer_len ++;
 		}
 		else {
+			# process normal variables
+
 			# ignore any ()s
 			while (gsub(/(\([^)]*\))/, "")) {
 			}
@@ -82,6 +108,7 @@
 			if (!match($0, /;/)) {
 				next;
 			}
+			# print "=DEBUG=" $0 "==";
 			split($0, chunks, ";");
 			# [unsigned int a, b, c]

@@ -101,7 +128,9 @@
 					delete pieces[j];
 				}
 				if (last_piece == "") {
-					print "=====" chunks[i];
+					# print "=ERROR=" chunks[i] "==";
+					delete chunks[i];
+					continue;
 				}
 				# a
 				# b
@@ -122,7 +151,7 @@
 	typedefs[$3] = $4;
 	next;
 }
-/^typedef struct .*\{/ {
+/^typedef struct .*\{[^}]*$/ {
 	brace = 1;
 	instruct = 1;
 	next;


change compare and title heads

change compare and title heads

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

--- scripts/tdb/statuses_clockss.awk
+++ scripts/tdb/statuses_clockss.awk
@@ -8,14 +8,12 @@

 {
   # add a loop to add line only if ending year is gt or eq to contract year
-  end = 0
+  end_year = 0
   incontract = 0
-  if ((length($4) == 9) {
-    end = substr($4,6,4)
-  } else {
-    end = substr($4,1,4)
-  }
-  if (end >= $3) {
+  if ((length($4) > 3) {
+    end_year = substr($4,length($4)-3,4)
+  }
+  if (end_year >= $3) {
     incontract = 1
   }

@@ -68,7 +66,7 @@
   #print out header
   printf "Publisher\tPlugin\tContr\tYear\tT\tTotal"
   for (j = 0 ; j < scn ; j++) {
-  	if (x[s[j]] > 0) {
+    if (x[s[j]] > 0) {
     printf "\t%s", sc[j]
     }
   }
@@ -91,8 +89,8 @@
     #print out bottom line sums
     printf "Publisher\tPlugin\tContr\tYear\tT\t%d", tt
     for (j = 0 ; j < sn ; j++) {
-    	if (x[s[j]] > 0) {
-    		printf "\t%d", x[s[j]]
+      if (x[s[j]] > 0) {
+        printf "\t%d", x[s[j]]
       }
     }


Filter is executable

Filter is executable


stop quoting on item

stop quoting on item

--- tools/wiki2latex.awk
+++ tools/wiki2latex.awk
@@ -57,14 +57,14 @@

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

-quoting && /^ / {
-  sub(/^ /, "");
-  print;
-  next;
+## check itemness
+{ inItem = 0 }
+/^   *\*/ {
+  inItem = 1
+  ## print " ########## ITEM"
 }
-

 itemizing && !/^   *\*/ {
   print "\\end{itemize}";
@@ -75,7 +75,7 @@

 ## quoting stops when item appears
 ## or not indented any more
-quoting && (/^   *\*/ || !/^ /) {
+quoting && (inItem || !/^ /) {
   print "\\end{quotation}";
   print ""
   quoting = 0;
@@ -109,6 +109,12 @@
   next;
 }

+quoting && /^ / {
+  sub(/^ /, "");
+  print;
+  next;
+}
+
 !itemizing && /^   *\*/ {
   print "\\begin{itemize}";
   itemizing = 1;


Languages: add Pashto language

Languages: add Pashto language

--- include/Languages.awk
+++ include/Languages.awk
@@ -234,6 +234,20 @@
     Locale["or"]["iso"]                = "ori"
     Locale["or"]["glotto"]             = "macr1269"
     Locale["or"]["script"]             = "Orya"
+
+    #? Pashto
+    Locale["ps"]["name"]               = "Pashto"
+    Locale["ps"]["endonym"]            = "پښتو"
+    #Locale["ps"]["translations-of"]
+    #Locale["ps"]["definitions-of"]
+    #Locale["ps"]["synonyms"]
+    #Locale["ps"]["examples"]
+    #Locale["ps"]["see-also"]
+    Locale["ps"]["family"]             = "Indo-European"
+    Locale["ps"]["iso"]                = "pus"
+    Locale["ps"]["glotto"]             = "pash1269"
+    Locale["ps"]["script"]             = "Arab"
+    Locale["ps"]["rtl"]                = "true" # RTL language

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


Make progress on parsing

Make progress on parsing

--- getFullcastFrom-imdb.awk
+++ getFullcastFrom-imdb.awk
@@ -9,6 +9,10 @@
     Cast = $4
     Directors = $5
     Writers = $6
+    person = ""
+    role = ""
+    num_episodes = ""
+    episode_years = ""

     if (Cast == "" && Directors == "" && Writers == "")
         next
@@ -17,9 +21,13 @@
         next

     if (Cast != "") {
+        type = "Actor"
         gsub (/[[:blank:]]{3,99}\(uncredited\)/," (uncredited)",Cast)
+        gsub (/[[:blank:]]{3,99}\/ \.\.\./," / ...",Cast)
+        uncredited = sub (/\(uncredited\) ?/,"",Cast)
+        if (uncredited != 0)
+            type = type " (uncredited)"
         nflds1 = split (Cast,fld,/[[:blank:]]{3,99}/)
-        type = "Actor"
         person = fld[1]
         role = fld[3]
         sub (/\302\240/,"",role)
@@ -32,11 +40,13 @@
     }

     if (Directors != "") {
+        type = "Director"
         nflds1 = split (Directors,fld,/[[:blank:]]{3,99}/)
-        type = "Director"
-        role = ""
         person = fld[1]
         episodes = fld[3]
+        uncredited = sub (/\(uncredited\) /,"",episodes)
+        if (uncredited != 0)
+            type = type " (uncredited)"
         gsub (/[()]/,"",episodes)
         nflds2 = split (episodes,fld,/,/)
         num_episodes = fld[1]
@@ -46,19 +56,30 @@
     }

     if (Writers != "") {
+        type = "Writer"
         nflds1 = split (Writers,fld,/[[:blank:]]{3,99}/)
-        type = "Writer"
-        role = ""
         person = fld[1]
-        episodes = fld[3]
-        gsub (/[()]/,"",episodes)
-        nflds2 = split (episodes,fld,/,/)
-        num_episodes = fld[1]
-        sub (/ episodes?/,"",num_episodes)
-        episode_years = fld[2]
-        sub (/ /,"",episode_years)
+        parens = fld[3]
+        nparens = split (parens,fld,/[()]/)
+        # print "==> parens = " parens > "/dev/stderr"
+        for ( i = 2; i < nparens-1; i+=2 ) {
+            if (fld[i] != " ") {
+                # print "==> i = " i " - |"fld[i] "|" > "/dev/stderr"
+                type = type " (" fld[i] ")"
+            }
+        }
+        episodes = fld[nparens-1]
+        if (episodes !~ /episodes?/) {
+            type = type " (" episodes ")"
+        } else {
+            nflds2 = split (episodes,fld,/,/)
+            num_episodes = fld[1]
+            sub (/ episodes?/,"",num_episodes)
+            episode_years = fld[2]
+            sub (/ /,"",episode_years)
+        }
     }

-    printf ("%d - %s %s\t%s\t%s\t%s\t%s\t%s\n",nflds1,Title,Years,person,type,role,num_episodes,episode_years)
+    printf ("%s %s | %s | %s | %s | %s | %s\n",Title,Years,person,type,role,num_episodes,episode_years)

 }


set execute perm

set execute perm


geo_utis.awk	-- new funcs for determining handed ness of polygons

--- lib/geo_utils.awk
+++ lib/geo_utils.awk
@@ -1,3 +1,23 @@
+function GU_pi() {
+	return 4*atan2(1, 1)
+}
+function GU_d2r(d) {
+	return (d+0)*GU_pi()/180.0
+}
+function GU_r2d(r) {
+	return (r+0)*180.0/GU_pi()
+}
+function GU_is_righthanded(count, first, x, y,   area, p, x1, y1, x2, y2) {
+	area = 0
+	for(p = 0; p < p_count[poly]; p++){
+		x1 = x[p_first[poly] + p]
+		y1 = y[p_first[poly] + p]
+		x2 = x[p_first[poly] + p + 1]
+		y2 = y[p_first[poly] + p + 1]
+		area += GU_d2r(x2 - x1) * (2.0 + sin(GU_d2r(y1)) + sin(GU_d2r(y2)))
+	}
+	return area >= 0
+}
 function GU_pr_header(title, n_points) {

 	printf("{\n")


fix copyright headers

fix copyright headers

--- awk/stringize.awk
+++ awk/stringize.awk
@@ -1,7 +1,16 @@
-# Copyright (c) AT&T Corp. 1994, 1995.
-# This code is licensed by AT&T Corp.  For the
-# terms and conditions of the license, see
-# http://www.research.att.com/orgs/ssr/book/reuse
+#
+# /**********************************************************
+# *      This software is part of the graphviz package      *
+# *                http://www.graphviz.org/                 *
+# *                                                         *
+# *            Copyright (c) 1994-2005 AT&T Corp.           *
+# *                and is licensed under the                *
+# *            Common Public License, Version 1.0           *
+# *                      by AT&T Corp.                      *
+# *                                                         *
+# *        Information and Software Systems Research        *
+# *              AT&T Research, Florham Park NJ             *
+# **********************************************************/

 BEGIN	{ s = ARGV[1]; gsub (".*/", "", s); gsub("\\.","_",s); printf("char *%s[] = {\n",s); }
 /^#/	{ print $0; next; }


disable __gmon_start__ symbol

disable __gmon_start__ symbol

--- extra/scripts/defs.awk
+++ extra/scripts/defs.awk
@@ -23,5 +23,5 @@
 	print "#define ALIGN";

     print "#include <libc-symbols.h>";
-    print "weak_extern (__gmon_start__)";
+    #print "weak_extern (__gmon_start__)";
 }