add library.awk

add library.awk

error: pathspec 'library.awk' did not match any file(s) known to git

--- library.awk
+++ library.awk
@@ -0,0 +1,1349 @@
+# library.awk
+
+# globals EXITCODE, MISSING
+
+
+# if you call die, assert, or check*: start END blocks with
+#    { if (EXITCODE) exit EXITCODE; ... }
+function die(msg) {
+    EXITCODE=1
+    printf("%s: %s\n", ARGV[0], msg) > "/dev/stderr"
+    exit EXITCODE
+}
+
+
+function assert(test, msg) {
+    if (!test) die(msg ? msg : "assertion failed")
+}
+
+
+# missing values are only isnull(), isnum(), iszero(), isint(), isnat() when a true second arg is supplied
+# "" values (even if set from command-line) are only isnull()
+# 0 and "0" values are isnum(), iszero(), isint(), isnat(), but other values coercable to 0 aren't
+# floats are isnum() but not ispos(), isneg()
+
+
+# unitialized scalar
+function ismissing(u) {
+    return u == 0 && u == ""
+}
+
+
+function check(u, missing) {
+    if (u == 0 && u == "") {
+        MISSING = 1
+        return missing
+    }
+    MISSING = 0
+    return u
+}
+
+# explicit ""
+function isnull(s, u) {
+    if (u) return s == "" # accept missing as well
+    return !s && s != 0
+}
+
+
+function isnum(n, u) {
+    # return n ~ /^[+-]?[0-9]+$/
+    if (u) return n == n +0 # accept missing as well
+    return n "" == n +0
+    # NOTE: awk will also convert when there's leading space/trailing anything
+    #       and will convert any other non-numeric to 0
+}
+
+
+# returns num or missing, else die(msg)
+function checknum(n, missing, msg) {
+    if (n "" == n + 0) {
+        MISSING = 0
+        return n # explicit numbers are preserved
+    } else if (msg && n != n + 0) die(msg)
+    MISSING = 1
+    return missing
+}
+
+
+# explicit 0 or "0"
+function iszero(n, u) {
+    # return n + 0 == 0 # accept any coercable
+    if (u) return n == 0 # accept missing as well
+    return n == 0 && n != ""
+}
+
+
+function isint(n, u) {
+    if (u) return int(n) == n # accept missing as well
+    return int(n) == n && n != ""
+}
+
+
+# explicit isnum >= 0
+function isnat(n, u) {
+    if (u) return int(n) == n && n >= 0 # accept missing as well
+    return int(n) == n && n "" >= 0
+}
+
+
+# returns nat or missing, else die(msg)
+function checknat(n, missing, msg) {
+    if (int(n) == n) {
+        if (n "" >= 0) {
+            MISSING = 0
+            return n # explicit numbers are preserved
+        } else if (msg && n < 0) die(msg)
+    } else if (msg) die(msg)
+    MISSING = 1
+    return missing
+}
+
+
+# explicit isnum > 0
+function ispos(n) {
+    # return n "" == n +0 && n > 0 # accept float as well
+    return int(n) == n && n > 0
+}
+
+
+# returns pos or missing, else die(msg)
+function checkpos(n, missing, msg) {
+    if (int(n) == n) {
+        if (n "" > 0) {
+            MISSING = 0
+            return n # explicit numbers are preserved
+        } else if (msg && (n < 0 || n "" >=  0)) die(msg)
+    } else if (msg) die(msg)
+    MISSING = 1
+    return missing
+}
+
+
+function isneg(n) {
+    # return n "" == n +0 && n < 0 # accept float as well
+    return int(n) == n && n < 0
+}
+
+
+
+## numeric utils #########
+
+# might as well inline
+function max(m, n) { return (m > n) ? m : n }
+
+
+# might as well inline
+function min(m, n) { return (m < n) ? m : n }
+
+
+# return k=1 distinct random elements A[1 <= i <= n], separated by SUBSEP
+function choose(n,  k,   A, i, r, p) {
+    k = checkpos(k, 1, "choose: second argument must be positive")
+    if (!isempty(A)) {
+        # A is already populated, choose k elements from A[1]..A[n], ordered by index
+        p = r = ""
+        for (i = 1; n > 0; i++)
+            if (rand() < k/n--) {
+                p = p r A[i]
+                r = SUBSEP
+                k--
+            }
+        return p
+    }
+    # else choose k integers from 1..n, ordered
+    if (k == 1)
+        return int(n*rand())+1
+    for (i = n-k+1; i <= n; i++)
+        ((r = int(i*rand())+1) in A) ? A[i] : A[r]
+    p = r = ""
+    for (i=1; i<=n; i++)
+       if (i in A) {
+            p = p r i
+            r = SUBSEP
+        }
+    split("", A) # does it help to delete the aux array?
+    return p
+}
+
+
+# random permutation of k=n integers between 1 and n
+# the distribution of this isn't great, but it does cover the whole range of permutations
+# a random deck is: split(permute(52,52), deck)
+function permute(n,  k,   i, r, p) {
+    k = checkpos(k, n, "permute: second argument must be positive")
+    p = SUBSEP
+    for (i = n-k+1; i <= n; i++) {
+        if (p ~ SUBSEP (r = int(i*rand())+1) SUBSEP)
+            # since i is higher than before, p only contains r when r < i
+            sub(SUBSEP r SUBSEP, SUBSEP r SUBSEP i SUBSEP, p)    # put i after r
+        else p = SUBSEP r p                                      # put r at beginning
+    }
+    return substr(p, 2, length(p)-2)
+}
+
+
+# Shuffle an array with indexes from 1 to n. (Knuth or Fisher-Yates shuffle)
+function shuffle(A, n,    i, j, t) {
+    if (!n) {
+        n = 1
+        while (n in A) n++
+        n--
+    }
+    for (i = n; i > 1; i--) {
+            j = int(i * rand()) + 1 # random integer from 1 to i
+            t = A[i]; A[i] = A[j]; A[j] = t # swap A[i], A[j]
+    }
+}
+
+
+## array utils #########
+
+function isempty(array,   i) {
+    for (i in array) return 0
+    return 1
+}
+
+
+# insertion sort A[1..n]
+# stable, O(n^2) but fast for small arrays
+function sort(A,n,   i,j,t) {
+    if (!n) {
+        n = 1
+        while (n in A) n++
+        n--
+    }
+    for (i = 2; i <= n; i++) {
+        t = A[i]
+        for (j = i; j > 1 && A[j-1] > t; j--)
+            A[j] = A[j-1]
+        A[j] = t
+    }
+}
+
+# mergesort is stable, O(n log n) worst-case
+# on arrays uses O(n) auxiliary space; but on linked lists only a small constant space
+# implementation not provided here
+
+
+# in-place quicksort A[left..right]
+# for efficiency, left and right must be supplied, default values aren't calculated
+# unstable
+# on avg thought to be constantly better than heapsort, but has worst-case O(n^2)
+# choose random pivot to avoid worst-case behavior on already-sorted arrays
+# advantage over mergesort is that it only uses O(log n) auxiliary space (if we have tail-calls)
+function qsort(A,left,right,   i,last,t) {
+    if (left >= right)  # do nothing if array contains at most one element
+        return
+    i = left + int((right-left+1)*rand()) # choose pivot
+    t = A[left]; A[left] = A[i]; A[i] = t # swap A[left] and A[i]
+    last = left
+    for (i = left+1; i <= right; i++)
+        if (A[i] < A[left]) {
+            ++last
+            t = A[last]; A[last] = A[i]; A[i] = t # swap A[last] and A[i]
+        }
+    t = A[left]; A[left] = A[last]; A[last] = t # swap A[left] and A[last]
+    qsort(A, left, last-1)
+    qsort(A, last+1, right)
+}
+
+
+# heapsort
+# also unstable, and unlike merge and quicksort it relies on random-access so has poorer cache performance
+# advantage over quicksort is that its worst-case same as avg: O(n log n)
+# this presentation based on http://dada.perl.it/shootout/heapsort.lua5.html
+function hsort(A, n,   c, p, t, i) {
+    if (!n) {
+        n = 1
+        while (n in A) n++
+        n--
+    }
+    i = int(n/2) + 1
+    while (1) {
+        if (i > 1) {
+            i--
+            t = A[i]
+        } else {
+            t = A[n]
+            A[n] = A[1]
+            n--
+            if (n == 1) {
+                A[1] = t
+                return
+            }
+        }
+        for (p = i; (c = 2*p) <= n; p = c) {
+            if ((c < n) && (A[c] < A[c+1]))
+                c++
+            if (t < A[c])
+                A[p] = A[c]
+            else break
+        }
+        A[p] = t
+    }
+}
+
+# # one of the more usual presentations
+# function hsort(A,n,  i,t) {
+#     if (!n) {
+#         n = 1
+#         while (n in A) n++
+#         n--
+#     }
+#     for (i = int(n/2); i >= 1; i--)
+#         heapify(A, i, n)
+#     for (i = n; i > 1; i--) {
+#         t = A[1]; A[1] = A[i]; A[i] = t # swap A[1] and A[i]
+#         heapify(A, 1, i-1)
+#     }
+# }
+#
+# function heapify(A,left,right,   p,c,t) {
+#     for (p = left; (c = 2*p) <= right; p = c) {
+#         if (c < right && A[c] < A[c+1])
+#             c++
+#         if (A[p] < A[c]) {
+#             t = A[c]; A[c] = A[p]; A[p] = t # swap A[c] and A[p]
+#         } else break
+#     }
+# }
+
+
+
+# if used on $0, rewrites it using OFS
+#   if you want to preserve existing FS, need to use gsplit
+# can also be used on array
+# returns popped elements separated by SUBSEP
+function pop(start,  len, A,   stop, p, last) {
+    start = checkpos(start, 0, "pop: first argument must be positive")
+    len = checknat(len, 0, "pop: second argument must be >= 0")
+    if (isempty(A)) {
+        if (!start)
+            start = NF
+        if (!len && !MISSING)
+            return "" # explicit len=0
+        if (!len)
+            len = NF - start + 1
+        stop = start + len - 1
+        p = res = ""
+        for(; ++stop <= NF; ++start) {
+            if (len-- > 0) {
+                res = res p $start
+                p = SUBSEP
+            }
+            $start = $stop
+        }
+        stop = start - 1
+        for (; start <= NF; ++start) {
+            if (len-- > 0) {
+                res = res p $start
+                p = SUBSEP
+            }
+        }
+        NF = stop
+        if (!p) {
+            # nawk won't recompute $0 just because NF was mutated
+            if (NF) $1 = $1
+            else $0 = ""
+        }
+        return res
+    } else {
+        # using array
+        last = 1
+        while (last in A) last++
+        last--
+        if (!start)
+            start = last
+        if (!len && !MISSING)
+            return "" # explicit len=0
+        if (!len)
+            len = last - start + 1
+        stop = start + len - 1
+        p = res = ""
+        for(; ++stop <= last; ++start) {
+            if (len-- > 0) {
+                res = res p A[start]
+                p = SUBSEP
+            }
+            A[start] = A[stop]
+        }
+        for (; start <= last; ++start) {
+            if (len-- > 0) {
+                res = res p A[start]
+                p = SUBSEP
+            }
+            delete A[start]
+        }
+        return res
+    }
+}
+
+
+function insert(value, start,  A,   stop, last) {
+    start = checkpos(start, 0, "insert: second argument must be positive")
+    if (isempty(A)) {
+        if (!start)
+            start = NF + 1
+        for (stop = NF; stop >= start; stop--) {
+            $(stop+1) = $stop
+        }
+        $start = value
+        return NF
+    } else {
+        # using array
+        last = 1
+        while (last in A) last++
+        last--
+        if (!start)
+            start = last+1
+        for (stop = last; stop >= start; stop--) {
+            A[stop+1] = A[stop]
+        }
+        A[start] = value
+        return (start > last) ? start : last + 1
+    }
+}
+
+
+function extend(V, start,  A,   stop, lastV, last) {
+    start = checkpos(start, 0, "insert: second argument must be positive")
+    lastV = 1
+    while (lastV in V) lastV++
+    lastV--
+    if (isempty(A)) {
+        if (!lastV)
+            return NF
+        if (!start)
+            start = NF + 1
+        for (stop = NF; stop >= start; stop--) {
+            $(stop+lastV) = $stop
+        }
+        for (start--; lastV > 0; lastV--)
+            $(start+lastV) = V[lastV]
+        return NF
+    } else {
+        # using array
+        last = 1
+        while (last in A) last++
+        last--
+        if (!lastV)
+            return last
+        if (!start)
+            start = last+1
+        for (stop = last; stop >= start; stop--) {
+            A[stop+lastV] = A[stop]
+        }
+        last = (start > last) ? start + lastV - 1 : last + lastV
+        for (start--; lastV > 0; lastV--)
+            A[start + lastV] = V[lastV]
+        return last
+    }
+}
+
+
+function reverse(A,   i, t, last) {
+    if (isempty(A)) {
+        last = NF + 1
+        for (i=1; i < last--; i++) {
+            t = $i
+            $i = $last
+            $last = t
+        }
+    } else {
+        # using array
+        last = 1
+        while (last in A) last++
+        for (i=1; i < last--; i++) {
+            t = A[i]
+            A[i] = A[last]
+            A[last] = t
+        }
+    }
+}
+
+
+# defaults to fields $start..$NF, using OFS
+# if you want to preserve existing FS, need to use gsplit
+# to concat an array without specifying len: concat(start, <uninitialized>, OFS, array)
+function concat(start,  len, fs, A,   i, s, p, stop) {
+    fs = check(fs, OFS)
+    start = checkpos(start, 1, "concat: first argument must be positive")
+    len = checknat(len, 0, "concat: second argument must be >= 0")
+    if (!len && !MISSING)
+        return "" # explicit len=0
+    s = p = ""
+    if (isempty(A)) {
+        if (len)
+            stop = start + len - 1
+        else
+            stop = NF
+        # more with fields
+        for (i=start; i<=stop; i++) {
+            s = s p $i
+            p = fs
+        }
+    } else {
+        # using array
+        if (len)
+            stop = start + len - 1
+        for (i=start; len ? i<=stop : i in A; i++) {
+            s = s p A[i]
+            p = fs
+        }
+    }
+    return s
+}
+
+
+function has_value(A, value,   k) {
+    for (k in A)
+        if (k[A] == value)
+            return true
+    return false
+}
+
+
+# if onlykeys, values are ignored
+function includes(A, B,  onlykeys,   k) {
+    for (k in B)
+        if (!(k in A && (onlykeys || A[k] == B[k])))
+            return 0
+    return 1
+}
+
+
+# if conflicts=0, drop keys; else favor A1 or A2; default=1
+function union(A1, A2,  conflicts,   k) {
+    conflicts = checknat(conflicts, 1, "union: third argument must be 0, 1, or 2")
+    if (conflicts > 2) die("union: third argument must be 0, 1, or 2")
+    for (k in A2)
+        if (k in A1) {
+           if (conflicts == 2)
+                A1[k] = A2[k]
+            else if (conflicts == 0 && A1[k] != A2[k])
+                delete A1[k]
+        } else {
+            A1[k] = A2[k]
+        }
+}
+
+
+# if conflicts=0, drop keys; else favor A1 or A2; default=1
+function intersect(A1, A2,  conflicts,   k) {
+    conflicts = checknat(conflicts, 1, "intersect: third argument must be 0, 1, or 2")
+    if (conflicts > 2) die("intersect: third argument must be 0, 1, or 2")
+    for (k in A1)
+        if (k in A2) {
+            if (conflicts == 2)
+                A1[k] = A2[k]
+            else if (conflicts == 0 && A1[k] != A2[k])
+                delete A1[k]
+        } else {
+            delete A1[k]
+        }
+}
+
+
+# if conflicts=0, drop keys; else keep them (favoring A1); default=1
+function subtract(A1, A2,  conflicts,   k) {
+    conflicts = checknat(conflicts, 1, "subtract: third argument must be 0 or 1")
+    if (conflicts > 1) die("subtract: third argument must be 0 or 1")
+    for (k in A2)
+        if (k in A1) {
+            if (conflicts == 0 || A1[k] == A2[k])
+                delete A1[k]
+        }
+}
+
+
+## string utils #########
+
+
+# 'quote' str for shell
+function quote(str) {
+    gsub(/'/, "'\\''", str)
+    return "'" str "'"
+}
+
+
+# delete "quoted" spans, honoring \\ and \"
+function delete_quoted(str, q,  repl) {
+    if (q == "") q = "\""
+    gsub(q "((\\\\" q ")*([^" q "\\\\]|\\\\[^" q "])*)*" q, repl, str)
+    return str
+}
+
+
+# repeat str n times, from http://awk.freeshell.org/RepeatAString
+function rep(str, n,  sep,   remain, result) {
+    if (n < 2) {
+        remain = (n == 1)
+        result = sep = ""
+    } else {
+        remain = (n % 2 == 1)
+        result = rep(str, (n - remain) / 2, sep)
+        result = result sep result
+    }
+    return result (remain ? sep str  :"")
+}
+
+
+# -- remove trailing and leading whitespace from string
+function trim(str) {
+    if (match(str, /[^ \t\n].*[^ \t\n]/))
+        return substr(str, RSTART, RLENGTH)
+    else if (match(str, /[^ \t\n]/))
+        return substr(str, RSTART, 1)
+    else
+        return ""
+}
+
+# # faster than either of:
+# function trim2(str) {
+#     sub(/^[ \t\n]+/, "", str)
+#     sub(/[ \t\n]+$/, "", str)
+#     return str
+# }
+# function trim3(str,  from) {
+#     match(str, /^[ \t\n]*/)
+#     if ((from = RLENGTH) < length(str)) {
+#         match(str, /.*[^ \t\n]/)
+#         return substr(str, from+1, RLENGTH-from)
+#     } else return ""
+# }
+
+
+# -- remove leading whitespace from string
+function trimleft(str) {
+    if (match(str, /^[ \t\n]+/))
+        return substr(str, RLENGTH+1)
+    else
+        return str
+}
+
+# # nearly the same performance as
+# function trimleft2(str) {
+#     sub(/^[ \t\n]+/, "", str)
+#     return str
+# }
+
+
+# -- remove trailing whitespace from string
+function trimright(str) {
+    if (match(str, /.*[^ \t\n]/))
+        return substr(str, RSTART, RLENGTH)
+    else
+        return ""
+}
+
+# # faster than either of:
+# function trimright2(str,   n) {
+#     n = length(str)
+#     while (n && match(substr(str, n), /^[ \t\n]/)) n--
+#     return substr(str, 1, n)
+# }
+# function trimright3(str) {
+#     sub(/[ \t\n]+$/, "", str)
+#     return str
+# }
+
+
+# TODO
+## cut to max of 10 chars: `sprintf "%.10s", str`
+
+
+# TODO
+# function string:linewrap(width, indent)
+#     checktype(self, 1, "string")
+#     checkopt(width, 2, "positive!") or 72
+#     checkopt(indent, 3, "natural!") or 0
+#     local pos = 1
+#     -- rest needs to be converted from Lua
+#     return self:gsub("(%s+)()(%S+)()",
+#         function(sp, st, word, fi)
+#             if fi - pos > width then
+#                 pos = st
+#                 return "\n" .. rep(" ", indent) .. word
+#             end
+#         end)
+# end
+
+
+function has_prefix(str, pre,   len2) {
+        len2 = length(pre)
+        return substr(str, 1, len2) == pre
+}
+
+
+function has_suffix(str, suf,   len1, len2) {
+        len1 = length(str)
+        len2 = length(suf)
+        return len2 <= len1 && substr(str, len1 - len2 + 1) == suf
+}
+
+
+function detab(str, siz,    n, r, s, start) {
+    siz = checkpos(siz, 8, "detab: second argument must be positive")
+    r = ""
+    n = start = 0
+    while (match(str, "\t")) {
+        start += RSTART
+        s = siz - (start - 1 + n) % siz
+        n += s - 1
+        r = r substr(str, 1, RSTART-1) rep(" ", s)
+        str = substr(str, RSTART+1)
+    }
+    return r str
+}
+
+
+function entab(str, siz) {
+    siz = checkpos(siz, 8, "detab: second argument must be positive")
+    str = detab(str, siz)
+    gsub(".{" siz "}", "&\1", str)
+    gsub(" +\1", "\t", str)
+    gsub("\1", "", str)
+    return str
+}
+
+
+## regexp utils #########
+## WARNING: /re/ evaluates as boolean, so have to pass "re"s to user functions
+
+# populate array from str="key key=value key=value"
+# can optionally supply "re" for equals, space; if they're the same or equals is "", array will be setlike
+function asplit(str, array,  equals, space,   aux, i, n) {
+    n = split(str, aux, (space == "") ? "[ \n]+" : space)
+    if (space && equals == space)
+        equals = ""
+    else if (ismissing(equals))
+        equals = "="
+    split("", array) # delete array
+    for (i=1; i<=n; i++) {
+        if (equals && match(aux[i], equals))
+            array[substr(aux[i], 1, RSTART-1)] = substr(aux[i], RSTART+RLENGTH)
+        else
+            array[aux[i]]
+    }
+    split("", aux) # does it help to delete the aux array?
+    return n
+}
+
+
+# like lua's find("%b()"), --> RSTART and sets RSTART and RLENGTH
+function bmatch (s, opener, closer,   len, i, n, c) {
+    len = length(s)
+    n = 0
+    for (i=1; i <= len; ++i) {
+        c = substr(s, i, 1)
+        if (c == opener) {
+            if (n == 0) RSTART = i
+            ++n
+        } else if (c == closer) {
+            --n
+            if (n == 0) {
+                RLENGTH = i - RSTART + 1
+                return RSTART
+            }
+        }
+    }
+    return 0
+}
+
+
+# TODO
+# tail not defined for negative nth (doesn't make sense, will always be none)
+# negative nth with zero-length matches:
+#   - head returns one element too early, or sometimes wrongly?
+#   - matchstr diverges
+function tail(str,  re, nth, m,  start, n) {
+    nth = checkpos(nth, 1, "tail: third argument must be positive")
+    re = check(re, SUBSEP)
+    if (nth == 1) {
+        if (match(str, re)) {
+            m = substr(str, RSTART + RLENGTH)
+            RSTART += RLENGTH
+            RLENGTH = length(m)
+        }
+        return m
+    } else {
+        RLENGTH = -1
+        start = 1
+        while (nth--) {
+            if (RLENGTH > 0) {
+                str = substr(str, RSTART + RLENGTH)
+                start += RLENGTH - 1
+            } else if (RLENGTH == 0) {
+                start++
+                if ((str = substr(str, RSTART + 1)) == "") {
+                    nth--
+                    break
+                }
+            }
+            n = (RLENGTH > 0)
+            if (!match(str, re)) break
+            if (n && !RLENGTH) {
+                assert(RSTART == 1 && nth >= 0)
+                if ((str = substr(str, 2)) == "" || !match(str, re)) break
+                start++
+            }
+            start += RSTART + n - 1
+        }
+        if (nth >= 0) {
+            RSTART = 0
+            RLENGTH = -1
+        } else {
+            m = substr(str, RSTART + RLENGTH)
+            RSTART = start + RLENGTH
+            RLENGTH = length(m)
+        }
+        return m
+    }
+}
+
+
+# this returns items between "re"; matchstr returns what matches "re"
+# 3rd argument to specify which item (-1 for last)
+# defaults to re=SUBSEP nth=1st none=""
+function head(str, re, nth,  none,   start, m, n) {
+    if (nth != -1) {
+        nth = checkpos(nth, 1, "head: third argument must be positive")
+    }
+    re = check(re, SUBSEP)
+    if (nth == 1) {
+        if (match(str, re)) {
+            RLENGTH = RSTART - 1
+            str = substr(str, 1, RLENGTH)
+        } else {
+            RLENGTH = length(str)
+        }
+        RSTART = 1
+        return str
+    } else {
+        # # to get arbitrary item, we just split
+        # nf = split(str, aux, re)
+        # if (nth == -1 && nf > 0)
+        #     m = aux[nf]
+        # else if (nth in aux)
+        #     m = aux[nth]
+        # split("", aux) # does it help to delete the aux array?
+        # return m
+
+        # I simplified and streamlined as much as I could, while still passing tests.
+        m = (nth > 0) ? none : ""
+        RLENGTH = -1
+        start = 1
+        while (nth--) {
+            if (RLENGTH > 0) {
+                str = substr(str, RSTART + RLENGTH)
+                start += RSTART + RLENGTH - n
+                m = (nth > 0) ? none : str
+            } else if (RLENGTH==0) {
+                start += RSTART + 1
+                m = n ? substr(str, 2, 1) : str
+                if ((str = substr(str, 2+n)) == "") {
+                    if (!m || nth > 1) {
+                        RSTART = 0
+                        RLENGTH = -1
+                        return none
+                    } else if (nth-- > 0)
+                        m = ""
+                    else
+                        start--
+                    break
+                }
+            }
+            n = (RLENGTH > 0)
+            if (!match(str, re)) break
+            if (RSTART > 1)
+                m = substr(str, 1, RSTART-1)
+            else
+                m = (n && RLENGTH) ? "" : substr(m, 1, 1)
+            start += n - 1
+        }
+        if (nth <= 0) {
+            RSTART = start
+            RLENGTH = length(m)
+        }
+        return m
+    }
+}
+
+
+# 3rd argument to specify occurrence (default=1st, -1=last)
+# permits one 0-length match at RSTART = length(str)+1
+function matchstr(str, re, nth,  none,   m, start, len, n) {
+    start = n = 0
+    if (nth == -1) {
+        # find last occurrence
+        len = -1
+        m = none
+        while (match(str, re)) {
+            start = (n += RSTART)
+            len = RLENGTH
+            m = substr(str, RSTART, RLENGTH)
+            # handle 0-length match
+            if (!RLENGTH) RLENGTH++
+            n += RLENGTH - 1
+            str = substr(str, RSTART + RLENGTH)
+        }
+        RSTART = start
+        RLENGTH = len
+        return m
+    }
+    nth = checkpos(nth, 1, "matchstr: third argument must be positive")
+    RLENGTH = -1
+    start = 1
+    while (nth--) {
+        if (RLENGTH > 0) {
+            str = substr(str, RSTART + RLENGTH)
+            start += RLENGTH - 1
+        } else if (RLENGTH == 0) {
+            start++
+            if ((str = substr(str, RSTART + 1)) == "") {
+                nth--
+                break
+            }
+        }
+        n = (RLENGTH > 0)
+        if (!match(str, re)) break
+        if (n && !RLENGTH) {
+            assert(RSTART == 1 && nth >= 0)
+            if ((str = substr(str, 2)) == "" || !match(str, re)) break
+            start++
+        }
+        start += RSTART + n - 1
+    }
+    if (nth >= 0) {
+        RSTART = 0
+        RLENGTH = -1
+        return none
+    } else {
+        m = substr(str, RSTART, RLENGTH)
+        RSTART = start
+        return m
+    }
+}
+
+
+# 3rd argument to specify occurrence (default=1st, -1=last)
+function nthindex(str, needle, nth,   i, n, len, start) {
+    start = 0
+    n = 0
+    len = length(needle)
+    if (nth == -1) {
+        # find last occurrence
+        while ((i = index(str, needle)) > 0) {
+            n = start + i
+            start += (i + len -1)
+            str = substr(str, i + len)
+        }
+        return n
+    }
+    nth = checkpos(nth, 1, "nthindex: third argument must be positive")
+    do {
+        if (n > 0) {
+            str = substr(str, n + len)
+            start += (len -1)
+        }
+        n = index(str, needle)
+        start += n
+    } while (n && --nth)
+    return nth ? 0 : start
+}
+
+
+# gawk's match does only a single match, and returns \0,\1..\n, starts, and lengths in a single array
+# this function does global match, and returns only \0 and starts, in two arrays
+function gmatch(str, re,  ms, starts,   i, n, start, sep1, sep2) {
+    # find separators that don't occur in str
+    i = 1
+    do
+        sep1 = sprintf("%c", i++)
+    while (sep1 ~ /[][^$(){}.*+?|\\]/ || index(str, sep1))
+    do
+        sep2 = sprintf("%c", i++)
+    while (index(str, sep2))
+    split("", starts) # delete array
+    n = gsub(re, sep1 "&" sep2, str)
+    split(str, ms, sep1)
+    start = 1
+    for (i=1; i<=n; i++) {
+        start += length(ms[i])
+        starts[i] = start--
+        ms[i] = substr(ms[i+1], 1, index(ms[i+1], sep2) - 1)
+    }
+    delete ms[i]
+    return n
+}
+
+
+# function gmatch(str, re,  ms, starts,   n, i, start, stop, eaten, sep1, sep2) {
+#     n = 0
+#     eaten = 0
+#     # find separators that don't occur in str
+#     i = 1
+#     do
+#         sep1 = sprintf("%c", i++)
+#     while (index(str, sep1))
+#     do
+#         sep2 = sprintf("%c", i++)
+#     while (index(str, sep2))
+#     split("", ms) # delete array
+#     split("", starts) # delete array
+#     i = gsub(re, sep1 "&" sep2, str)
+#     while (i--) {
+#         start = index(str, sep1)
+#         stop = index(str, sep2) - 1
+#         # testing for the arrays interpret them as scalar; just use them
+#         ms[++n] = substr(str, start + 1, stop - start)
+#         starts[n] = eaten + start
+#         eaten += stop - 1
+#         str = substr(str, stop + 2)
+#     }
+#     return n
+# }
+
+
+# based on <http://awk.freeshell.org/FindAllMatches>
+# function gmatch(str, re,  ms, starts,   n, i, eaten) {
+#     n = 0
+#     eaten = 0
+#     # we check number of matches to help avoid rematching anchored REs
+#     # but note this isn't a reliable solution: "^a|b" will wrongly match indices 1 and 2 of "aab"
+#     i = gsub(re, "&", str)
+#     while (i-- && match(str, re) > 0) {
+#         # testing for the arrays interpret them as scalar; just use them
+#         ms[++n] = substr(str, RSTART, RLENGTH)
+#         starts[n] = eaten + RSTART
+#         # handle 0-length match
+#         if (!RLENGTH) RLENGTH++
+#         eaten += (RSTART + RLENGTH -1)
+#         str = substr(str, RSTART + RLENGTH)
+#     }
+#     return n
+# }
+
+
+# behaves like gawk's split; special cases re == "" and " "
+# unlike split, will honor 0-length matches
+function gsplit(str, items, re,  seps,   n, i, start, stop, sep1, sep2, sepn) {
+    n = 0
+    # find separators that don't occur in str
+    i = 1
+    do
+        sep1 = sprintf("%c", i++)
+    while (index(str, sep1))
+    do
+        sep2 = sprintf("%c", i++)
+    while (index(str, sep2))
+    sepn = 1
+    split("", seps) # delete array
+    if (ismissing(re))
+        re = FS
+    if (re == "") {
+        split(str, items, "")
+        n = length(str)
+        for (i=1; i<n; i++)
+            seps[i]
+        return n
+    }
+    split("", items) # delete array
+    if (re == " ") {
+        re = "[ \t\n]+"
+        if (match(str, /^[ \t\n]+/)) {
+            seps[0] = substr(str, 1, RLENGTH)
+            str = substr(str, RLENGTH+1)
+        }
+        if (match(str, /[ \t\n]+$/)) {
+            sepn = substr(str, RSTART, RLENGTH)
+            str = substr(str, 1, RSTART-1)
+        }
+    }
+    i = gsub(re, sep1 "&" sep2, str)
+    while (i--) {
+        start = index(str, sep1)
+        stop = index(str, sep2) - 1
+        seps[++n] = substr(str, start + 1, stop - start)
+        items[n] = substr(str, 1, start - 1)
+        str = substr(str, stop + 2)
+    }
+    items[++n] = str
+    if (sepn != 1) seps[n] = sepn
+    return n
+}
+
+
+## debugging #########
+
+function dump(array,  prefix,   i) {
+    for (i in array) {
+        printf "%s[%s]=<%s>\n", prefix, i, array[i]
+    }
+}
+
+
+# idump(array, [[start],stop], [prefix])
+function idump(array,  stop, prefix,   i, start) {
+    if (isnum(prefix)) {
+        start = stop
+        stop = prefix
+        prefix = i
+    } else start = 1
+    for (i=start; !stop || i<=stop; i++)
+        if (i in array) {
+            printf "%s[%d]=<%s>\n", prefix, i, array[i]
+        } else if (!stop) break
+}
+
+
+## getopt-handling #########
+
+function usage(basename, version, description, summary, longsummary, addl, optstring, options, minargs) {
+    gsub(/\n/, "\n ", longsummary)
+    description = "Usage:   " basename " " summary "\n         " description "\nAuthor:  Jim Pryor <dubiousjim@gmail.com>\nVersion: " version "\n\nOptions:\n " longsummary (addl ? "\n\n" addl : "") "\n\nThis script is in the public domain, free from copyrights or restrictions."
+    getopt(optstring, options, basename, version, description)
+    if (ARGC - 1 < minargs) {
+        print description > "/dev/stderr"
+        exit 2
+    }
+}
+
+
+function getopt(optstring, options, basename, version, usage_msg,   i, j, o, m, n, a, d) {
+    # options["long"] = ""         option with no argument
+    # options["long"] = ":"        option with required argument, only remember last occurrence
+    # options["long"] = "?default" option with optional argument, only remember last occurrence
+    # options["long"] = "+"        repeatable option with required argument, results will be separated by SUBSEP
+    # options["long"] = "*default" repeatable option with optional argument, results will be separated by SUBSEP (not useful? disabled)
+
+    # optstring = "ab:c?d+e*" ~~> { a="", b=":", c="?", d="+", e="*" }
+
+    for (i=1; i<=length(optstring); ) {
+        options[m = substr(optstring, i++, 1)]
+        if (substr(optstring, i, 1) ~ /[:+?]/)  # /[:+?*]/ disabled *
+            options[m] = substr(optstring, i++, 1)
+    }
+
+    for (i=1; i<ARGC; ) {
+        if (ARGV[i] == "--") {
+            # end of option arguments
+            i++
+            break
+        } else if (ARGV[i] ~ /^--[a-z][a-z]/) {
+            m = substr(ARGV[i++], 3)
+            if (m == "version") {
+                printf "%s version %s\n", basename, version > "/dev/stderr"
+                exit 0
+            } else if (m == "help") {
+                print usage_msg > "/dev/stderr"
+                exit 0
+            }
+            if (j = index(m, "=")) {
+                a = substr(m, j+1)
+                m = substr(m, 1, j-1)
+            }
+            if (!(m in options)) {
+                printf "%s: unknown option --%s\n", basename, m > "/dev/stderr"
+                exit 2
+            }
+        } else if (ARGV[i] ~ /^--/) {
+            printf "%s: unknown option %s\n", basename, ARGV[i] > "/dev/stderr"
+            exit 2
+        } else if (ARGV[i] ~ /^-./) {
+            m = substr(ARGV[i], 2, 1)
+            if (length(ARGV[i]) == 2) {
+                j = 0 # no argument yet
+                i++
+            } else {
+                j = 1 # flag unknown argument
+                a = substr(ARGV[i], 3)
+                ARGV[i] = "-" a
+            }
+            if (!(m in options)) {
+                printf "%s: unknown option -%s\n", basename, m > "/dev/stderr"
+                exit 2
+            }
+        } else {
+            # first non-option argument
+            break
+        }
+
+        n = substr(options[m], 1, 1)
+        if (n == ":" || n == "+") {
+            if (j==1) {
+                # consume rest of current ARGV
+                i++
+            } else if (j==0)
+                if (i<ARGC && (a = ARGV[i]) !~ /^-/)
+                    i++
+                else {
+                    printf "%s: option -%s%s missing required argument\n", basename, (length(m)==1) ? "" : "-", m > "/dev/stderr"
+                    exit 2
+                }
+            # :[SUBSEP arg] gets reassigned
+            # +[SUBSEP arg...] is repeatable
+            options[m] = ((n==":") ? n : options[m]) SUBSEP a
+        } else if (n == "?") {  #   || n == "*" disabled *
+            d = index(options[m], SUBSEP)
+            d = substr(options[m], 2, d ? d-1 : length(options[m]))
+            if (j==1) {
+                # consume rest of current ARGV
+                i++
+            } else if (j==0)
+                if (i<ARGC && (a = ARGV[i]) !~ /^-/)
+                    i++
+                else {
+                    # missing optional argument
+                    a = d
+                }
+            # ?default[SUBSEP arg] gets reassigned
+            # *default[SUBSEP arg...] is repeatable
+            options[m] = ((n=="?") ? "?" d : options[m]) SUBSEP a
+        } else {
+            if (j>1) {
+                printf "%s: option --%s doesn't accept an argument\n", basename, m > "/dev/stderr"
+                exit 2
+            }
+            options[m] = ++o
+        }
+    }
+    if (i>1) {
+        for (j=1; i<ARGC; )
+            ARGV[j++] = ARGV[i++]
+        ARGC = j
+    }
+    for (m in options) {
+        if (options[m] ~ /^[:+?*]/) {
+            if (k = index(options[m], SUBSEP))
+                options[m] = substr(options[m], k+1)
+            else
+                delete options[m]
+        } else if (!(options[m]))
+            delete options[m]
+    }
+}
+
+
+
+## os/filesystem #########
+
+# assert(system(cmd) == 0, "system(\"" cmd "\") failed")
+
+
+function isreadable(path) {
+    return (system("test -r " quote(path)) == 0)
+}
+
+# function isreadable(path,   v, res) {
+#     res = 0
+#     if ((getline v < path) >= 0) {
+#         res = 1 # though file may be empty
+#         close(path)
+#     }
+#     return res
+# }
+
+
+function filesize(path,   followlink,  v, cmd) {
+    cmd = "ls -ld " (followlink ? "-L " : "") quote(path) " 2>/dev/null"
+    if (0 < (cmd | getline v)) {
+        close(cmd)
+        if (v ~ /^-/) {
+            return head(v, " ", 5) # filesize
+        } else {
+            return "" # not regular file
+        }
+    } else {
+        close(cmd)
+        return -1 # file doesn't exist
+    }
+}
+
+
+function filetype(path,   followlink,  v, cmd) {
+    cmd = "ls -ld " (followlink ? "-L " : "") quote(path) " 2>/dev/null"
+    if (0 < (cmd | getline v)) {
+        close(cmd)
+        v = substr(v, 1, 1) # -dlcbsp
+        if (v == "-")
+            return "f" # this ensures that error result < all non-error results
+        else
+            return v
+    } else {
+        close(cmd)
+        return -1 # file doesn't exist
+    }
+}
+
+
+function basename(path, suffix) {
+    sub(/\/$/, "", path)
+    if (path == "")
+        return "/"
+    sub(/^.*\//, "", path)
+    if (suffix != "" && has_suffix(path, suffix))
+        path = substr(path, 1, length(path) - length(suffix))
+    return path
+}
+
+
+function dirname(path, suffix) {
+    if (!sub(/\/[^\/]*\/?$/, "", path))
+        return "."
+    else if (path != "")
+        return path
+    else
+        return "/"
+}
+
+
+function getfile(path,   v, p, res) {
+    res = p = ""
+    while (0 < (getline v < path)) {
+        res = res p v
+        p = "\n"
+    }
+    assert(close(path) == 0, "close(\"" path "\") failed")
+    return res
+}
+
+
+function getpipe(cmd,   v, p, res) {
+    res = p = ""
+    while (0 < (cmd | getline v)) {
+        res = res p v
+        p = "\n"
+    }
+    assert(close(cmd) == 0, "close(\"" cmd "\") failed")
+    return res
+}
+
+
+# creates a file that will be deleted when awk exits; works on FreeBSD, should also work on BusyBox, whose `trap` accepts only numeric signals; also FreeBSD permits `mktemp -t awk` but BusyBox requires `mktemp -t /tmp/awk.XXXXXX`
+function mktemp(   cmd, v) {
+    # base directory is -p DIR, else ${TMPDIR-/tmp}
+    # -t tmp.XXXXXX or TEMPLATE
+    cmd = "T=`mktemp \"${TMPDIR:-/tmp}/awk.XXXXXX\"` || exit 1; trap \"rm -f '$T'\" 0 1 2 3 15; printf '%s\n' \"$T\"; cat /dev/zero"
+#     0/EXIT
+#     1/HUP: controlling terminal or process died
+#     2/INT ^C from keyboard
+#     15/TERM
+
+#     3/QUIT ^\ from keyboard
+#     6/ABRT from abort(2)
+#     13/PIPE: write to pipe with no readers
+#     14/ALRM from alarm(2), e.g. if script calls sleep
+
+# other stty keys: eof=^d start/stop=^q/^s susp=^z dsusp=^y
+#                  erase/erase2=^?/^h werase=^w kill=^u reprint=^r lnext=^v
+#                  flush/discard=^o status=^t
+
+    if (0 < (cmd | getline v)) {
+        return v
+    } else {
+        return ""
+    }
+    # we intentionally don't close the pipe
+}
+


Oops.

Oops.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/citycloud-bigdata/mondrian.git/'


Integrate change 2b890aceb9782c5d0442c475bc920abeb40cc2dc.


added open_c/version.awk

added open_c/version.awk

darcs-hash:20070430115950-1b897-969397f11883eeb2a4024a2575f72be1494d5fde.gz

error: pathspec 'open_c/version.awk' did not match any file(s) known to git

--- open_c/version.awk
+++ open_c/version.awk
@@ -0,0 +1,51 @@
+#! /bin/gawk
+#
+# This script extracts the version information from configure.ac
+# and re-generates win32/config.h and
+# libsofia-sip-ua/features/sofia_sip_features.h
+#
+# --------------------------------------------------------------------
+#
+# This file is part of the Sofia-SIP package
+#
+# Copyright (C) 2005 Nokia Corporation.
+#
+# Contact: Pekka Pessi <pekka.pessi@nokia.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# 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., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA
+#
+# --------------------------------------------------------------------
+#
+# Contributor(s): Pekka.Pessi@nokia.com.
+#
+# Created: Wed Jan 25 15:57:10 2006 ppessi
+#
+
+BEGIN { IN=1; OUT=0; }
+
+IN && /^AC_INIT/ { version=$2; gsub(/[\]\[)]/, "", version); }
+
+OUT && /@[A-Z_]+@/ {
+  gsub(/@PACKAGE_VERSION@/, version);
+  gsub(/@PACKAGE_BUGREPORT@/, "sofia-sip-devel@lists.sourceforge.net");
+  gsub(/@PACKAGE_NAME@/, "sofia-sip");
+  gsub(/@PACKAGE@/, "sofia-sip");
+  gsub(/@PACKAGE_STRING@/, "sofia-sip");
+  gsub(/@PACKAGE_TARNAME@/, "sofia-sip");
+}
+
+OUT { print; }
+


print ad_join(sb, RS)

print ad_join(sb, RS)

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/svnpenn/sage.git/'


stuipd cray awk wants \#

stuipd cray awk wants \#

git-svn-id: 193148810cf65385f3a195dbc9a8b504846da3a2@4873 ec53bebd-3082-4978-b11e-865c3cabbd6b

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/madscientist159/heimdal.git/'


inital add; gen stats on rdf statements

inital add; gen stats on rdf statements

error: pathspec 'scripts/spote_count.awk' did not match any file(s) known to git

--- scripts/spote_count.awk
+++ scripts/spote_count.awk
@@ -0,0 +1,80 @@
+#! /usr/bin/gawk -f
+# spote_count.awk
+# RDF ntriple counts for:
+# subject predicate object triples entity
+#
+# spote_count.awk -v"RELEASE=YYYYMM" path/file.nt
+
+
+function sum(a, t){
+    for(i in a)
+        t += a[i]
+    return t
+}
+
+BEGIN{
+    if(! RELEASE)
+        "date +%Y%m" | getline RELEASE;
+    FS = " "
+    archive = "https://archive.monarchinitiative.org/"
+}
+
+# iri objects
+/^.*> .$/ {
+    s[$1]++;p[$2]++;o[$3]++
+}
+
+# entities  (typed subjects)
+$2 == "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>" {
+    e[$1]++
+}
+
+# literal objects
+/^.*" .$/ {
+    s[$1]++;p[$2]++;
+    # not counting literals for now
+    # $1="";$2="";l[$0]++
+}
+
+# not counting bnodes for now
+# blank node subject
+#/^[^ ]*\.well-known\/genid/ {
+#    bs[$1]++
+#    b[$1]++
+#}
+
+# blank node object
+#/ <[^ ]*\.well-known\/genid/ {
+#    bo[$3]++
+#    b[$3]++
+#}
+
+END{
+    split(FILENAME, path, "/")
+    graphname = path[length(path)]
+    # still has extension '.nt' might need to truncate
+
+    subject_iri = "<" archive RELEASE "/rdf/" graphname ">"
+    subject_curie = "MonarchArchive:" RELEASE "/rdf/" graphname
+
+    # turtle like output for now b/c _datasets output is always turtle
+    # not sure if or how this will get intregrated.
+
+    print "@prefix MonarchArchive: <https://archive.monarchinitiative.org/> ."
+    print "@prefix void: <http://rdfs.org/ns/void#> ."
+
+    print subject_curie " a dctypes:Dataset ;"  # redundant typing
+    print "\tvoid:distinctSubjects " length(s)  " / " sum(s) " ;"
+    print "\tvoid:distinctObjects "  length(o)  " / " sum(o) " ;"
+    print "\tvoid:entities "         length(e)  " / " sum(e) " ;"
+    print "\tvoid:properties "       length(p)  " / " sum(p) " ;"
+
+    # not aware of what predicates to use. (have not researched)
+    # print "\texample:literals "      length(l)  " / " sum(l) " ;"
+    # print "\texample:blanknode "     length(b)  " / " sum(b) " ;"
+    # print "\texample:bnodesub "      length(bs) " / " sum(bs) " ;"
+    # print "\texample:bnodeobj "      length(bo) " / " sum(bo) " ;"
+
+    print "\tvoid:triples " FNR " ."
+
+}


AWK script to get PharmGKB-UMLS mappings

error: pathspec 'parse_drugs_tsv.awk' did not match any file(s) known to git

--- parse_drugs_tsv.awk
+++ parse_drugs_tsv.awk
@@ -0,0 +1,14 @@
+BEGIN { print "Début du parcours"
+FS="\t" }
+{
+pharmgkb_id = $1
+split($10,xref,",")
+for (i in xref) {
+	if(match(xref[i],/("UMLS:.*)/)) {
+		gsub(/"UMLS:/,"", xref[i])
+		gsub(/\(.*/, "", xref[i])
+		print pharmgkb_id,xref[i]
+	}
+}
+}
+END { print "-- Parcours terminé --" }


Add awk script for quad score.

Add awk script for quad score.

error: pathspec 'awk/quad.awk' did not match any file(s) known to git


update

update

error: pathspec 'sedbot.awk' did not match any file(s) known to git

--- sedbot.awk
+++ sedbot.awk
@@ -0,0 +1,53 @@
+#!/usr/bin/gawk -f
+function lineout(old,new,nouser) {
+  if(old!=new) print (nouser?"":"<" tauntuser(user) "> ") new >outfile; close(outfile);
+  if(taunt[tolower(user)]>0) taunt[tolower(user)]--;
+}
+function tauntuser(u) {
+  if(taunt[tolower(u)]>0) for(i=1;i<10;i++) u=gensub("("vowel_re")+(.)",vowel_letter[int(rand()*vowel_n+1)]"\\2",i,u);
+  return u;
+}
+BEGIN {
+  line_re="^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2} <([^>]*)> (.*)$";
+  blag_re="world wide web|internet|interweb|intersphere|intertubes|interblag|blogosphere|blagonet|blagosphere|blagoblag|webnet|webweb";
+  blag_n=split(blag_re,blag_word,/\|/);
+  vowel_re="a|e|i|o|u|y";
+  vowel_n=split(vowel_re,vowel_letter,/\|/);
+  slash_n=split("\1ACTION offers # a /\1|\1ACTION tosses a / to #\1|#, did you know there's THREE slashes in a proper s/// command?|\1ACTION hurls a / at #!\1|#, you bloody moron, get the syntax straight or get off this channel!!\n\1ACTION peppers # with /s\1",slash_msg,"|");
+  srand();
+}
+$0 ~ line_re {
+  user=repluser=gensub(line_re,"\\1",1);
+  line=gensub(/\001ACTION (.*)\001/,"\\1",1,gensub(line_re,"\\2",1));
+  update_line=1;
+}
+line ~ /^s\/(([^\/\\]|\\.)+)\/(([^\/\\]|\\.)*)[[:space:]]*$/ {
+  update_line=0;
+  taunt[tolower(user)]+=1.5;
+  lineout("",gensub("#",tauntuser(user),"g",slash_msg[int(rand()*rand()*slash_n+1)]),1);
+}
+line ~ /^([\x41-\x7D][-0-9\x41-\x7D]*)[:,] s(.*)/ {
+  repluser=gensub(/^([\x41-\x7D][-0-9\x41-\x7D]*)[:,] s(.*)/,"\\1",1,line);
+  line=gensub(/^([\x41-\x7D][-0-9\x41-\x7D]*)[:,] (s.*)/,"\\2",1,line);
+  print repluser ": " line "\n" >"/dev/stderr";
+}
+line ~ /^s/ {
+  sep=substr(line,2,1);
+  if(sep ~ /[\.\^\$\[\]\|\+\*\(\)\{\}]/) sep="\\"sep;
+  desep="\\\\("sep")";
+  s_re = "^s" sep "(([^" sep "\\\\]|\\\\.)+)" sep "(([^" sep "\\\\]|\\\\.)*)" sep "(([0-9]*[1-9][0-9]*|g)|([iI]))*[[:space:]]*$";
+  if(line ~ s_re) {
+    update_line=0;
+    search=gensub(desep,"\\1","g",gensub(s_re,"\\1", 1, line));
+    repl  =gensub(desep,"\\1","g",gensub(s_re,"\\3", 1, line));
+    count =gensub(desep,"\\1","g",gensub(s_re,"\\6", 1, line));
+    casein=gensub(desep,"\\1","g",gensub(s_re,"\\7", 1, line));
+    print repluser ": " line "\n" s_re "\n" search "\n" repl "\n" count "\n" casein >"/dev/stderr";
+    if(!count) count=1;
+    if(casein) IGNORECASE=1; else IGNORECASE=0;
+    newline=gensub(search,repl,count,last_line[tolower(repluser)]);
+    lineout((repluser!=user?"<"repluser"> ":"")last_line[tolower(repluser)],(repluser!=user?"<"repluser"> ":"")gensub(blag_re,blag_word[int(rand()*blag_n+1)],"g",newline));
+  }
+}
+line ~ /^[sS][eE][dD][bB][oO][tT]/ {lineout("","\001ACTION is a 53-line awk script, https://github.com/FoobarBazbot/sedbot\001",1);}
+update_line {last_line[tolower(user)]=line;}


use PACKAGE_VERSION instead

use PACKAGE_VERSION instead


final pass: add some backgrounds

final pass: add some backgrounds

error: pathspec 'tools/backgrounds.awk' did not match any file(s) known to git

--- tools/backgrounds.awk
+++ tools/backgrounds.awk
@@ -0,0 +1,24 @@
+BEGIN {
+  slidecount = 0
+}
+
+
+/
/ {
+  print "
"
+  print "  "
+  print "
"
+  print ""
+}
+
+/
/ {
+  slidecount++
+  if (slidecount == 2)
+  {
+    print "
"
+    print "  "
+    print "
"
+    sub(/slide/, "slide haskell")
+  }
+}
+
+{ print }


Awk script to colorize junit output
Example of usage :
./build junit | tee junit.log | awk -f ../dev/scripts/junit.awk

git-svn-id: 9146c88ff6d39b48099bf954d15d68f687b3fa69@9193 28e8926c-6b08-0410-baaa-805c5e19b8d6

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/lpellegr/scheduling.git/'


Add linkparser.

Add linkparser.

error: pathspec 'linkparser/linkparser.awk' did not match any file(s) known to git

--- linkparser/linkparser.awk
+++ linkparser/linkparser.awk
@@ -0,0 +1,153 @@
+#!@include "functions.awk"
+
+BEGIN {
+	true = 1
+	false = 0
+	g_pat_srccommon = "\\/sw\\/vobs.+"
+	g_sroot = ""
+	tar_root = ""
+
+	# Colors
+	RED="\033[0;31m"
+	GRN="\033[0;32m"
+	BLU="\033[0;34m"
+	NC="\033[0m"
+	BOL="\033[1m"
+
+	if (arg ~ /test/) {
+		do_test();
+		SKIP_END = true
+		exit 0
+	}
+	count = 0
+}
+
+/^[^-]/ {
+	link = $0
+	# Remove the ending ' \'
+	gsub(/[ \t]+\\$/, "", link)
+
+	if (g_sroot == "") {
+		g_sroot = get_sroot(link)
+		system("mkdir ." g_sroot)
+	}
+
+	cmd_file = link".cmd"
+	while ((getline line < cmd_file) > 0) {
+		# abosolute path
+		if (line ~ /[ \t]+-c[ \t]+\/.+$/)
+			source = gensub(/^.+[ \t]+-c[ \t]+(.+)$/, "\\1", "g", line)
+		# relative path
+		else
+			source = gensub(/^cd (.+);.+-c (.+)/, "\\1/\\2", "g", line)
+
+		print BLU source NC
+		if (source == "") {
+			print RED "+++++++"line NC
+		}
+
+		dir = dirname(source)
+		base = basename(source)
+		patt = "^.+\\/"g_sroot"\\/(sw.+)"
+		rel_path = gensub(patt, "\\1", "g", dir)
+
+		system("mkdir -p ." g_sroot "/" rel_path)
+		system("cp " source " ." g_sroot "/" rel_path)
+
+		count = count + 1
+	}
+}
+
+END {
+	print "Total dumped files: " count
+	"date +%Y%m%d%H%M%S" | getline date
+	tarball = g_sroot "." date ".tar.gz"
+	printf("Generating source tarball %s%s%s%s ...\n", RED, BOL, tarball, NC)
+	system("tar zcf " tarball " ." g_sroot)
+	system("rm -r ."g_sroot)
+}
+
+function get_sroot(line) {
+	if (line !~ g_pat_srccommon)
+		return ""
+
+	gsub(g_pat_srccommon, "", line);
+	gsub(/.+\//, "", line);
+	return line;
+}
+
+# dirname
+function dirname(path) {
+	if (path == "")
+		return ""
+
+	# Remove the ending '/'
+	gsub(/\/+$/, "", path)
+
+	# Remove basename
+	gsub(/[^\/]+$/, "", path)
+	if (path == "") return "."
+
+	# Remove the ending '/' again
+	gsub(/\/+$/, "", path)
+	if (path == "")
+		return "/"
+
+	return path
+}
+
+# basename
+function basename(path) {
+	if (path == "")
+		return ""
+
+	# Remove the ending '/'
+	gsub(/\/+$/, "", path)
+	if (path == "")
+		return "/"
+
+	path = gensub(/^.+\/+(.+)$/, "\\1", "g", path)
+
+	return path;
+}
+
+###### Test #########
+function do_test() {
+	printf("%s%s%s%s\n", BLU, BOL, "---- Test get_sroot ----", NC)
+	test_get_sroot("/repo/lulinw/isam/sw/vobs/esam/build");
+	test_get_sroot("/repo/lulinw/isam/sw/esam/build");
+
+	printf("%s%s%s%s\n", BLU, BOL, "---- Test dirname ----", NC)
+	test_dirname("/home/abc");
+	test_dirname("home///abc//");
+	test_dirname("home///abc/de//");
+	test_dirname("../abc//");
+	test_dirname("abc");
+	test_dirname("..");
+	test_dirname("..///");
+
+	printf("%s%s%s%s\n", BLU, BOL, "---- Test basename ----", NC)
+	test_basename("/home//abc")
+	test_basename("///")
+	test_basename("/")
+	test_basename("..")
+	test_basename("../abc//")
+	test_basename("/../abc//")
+	test_basename("/../abc/efg/")
+}
+
+function test_get_sroot(line) {
+	if ((ret = get_sroot(line)) == "") {
+		printf("Unexpected line [PAT=%s]:\n  %s%s%s\n",
+				g_pat_srccommon, RED, line, NC)
+	} else
+		printf("Root of %s is\n  %s%s%s\n", line, GRN, get_sroot(line), NC)
+}
+
+function test_dirname(path) {
+	printf("dirname(%s) is \n  %s%s%s\n", path, GRN, dirname(path), NC)
+}
+
+function test_basename(path) {
+	printf("basename(%s) is \n %s%s%s\n", path, GRN, basename(path), NC)
+}


Create zad3.awk

Create zad3.awk

error: pathspec 'AWK/zad3.awk' did not match any file(s) known to git

--- AWK/zad3.awk
+++ AWK/zad3.awk
@@ -0,0 +1,4 @@
+#Z pliku /etc/passwd wypisać dane użytkowników należących do grupy pracown (zobacz w /etc/group).
+
+BEGIN {FS=":"}
+/home/pracown/ {print $1}


Added a decode script

Added a decode script

error: pathspec 'extras/decode.awk' did not match any file(s) known to git

--- extras/decode.awk
+++ extras/decode.awk
@@ -0,0 +1,43 @@
+BEGIN {
+	RS = ""
+	FS = ""
+	convert = "\nABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+	# For character to number conversion
+	for (n=0; n<256; n++) {
+		ord[sprintf("%c", n)] = n
+	}
+
+	shift = 0
+	lastNum = 0
+}
+
+function fiveBitDecode(char) {
+	currentNum = ord[char]
+
+
+	if (shift >= 8) {
+		shift = shift - 8
+	}
+
+	while (shift <= 8) {
+		if (shift > 0 && shift < 5) {
+			lastNum = or(lastNum, and(lshift(currentNum, 5 - shift), 0x1F))
+			printf "%c", substr(convert, lastNum + 1, 1)
+		}
+
+		lastNum = and(rshift(currentNum, shift), 0x1F)
+		if (shift <= 3) {
+			printf "%c", substr(convert, lastNum + 1, 1)
+			lastNum = 0
+		}
+
+		shift = shift + 5
+	}
+}
+
+{
+	for (i = 1; i <= NF; i++) {
+		fiveBitDecode($i)
+	}
+}


Added new script, could probably use some refinements.

error: pathspec 'betterBulkGroup.awk' did not match any file(s) known to git

--- betterBulkGroup.awk
+++ betterBulkGroup.awk
@@ -0,0 +1,20 @@
+#!/usr/bin/awk -f
+
+# Bulk update email groups
+# Written by Hilary B. Bisenieks <https://github.com/HBBisenieks> (c)2013
+# Provided under the MIT License
+# No warranty is provided or implied
+
+# Takes as input a .csv file with each row containing
+# a username followed by any number of email groups to
+# which they should be added as a member.
+
+BEGIN {
+	FS=",";
+}
+{
+	for (i=2; i<=NF; i++)
+	{
+		system("python /path/to/gam.py update group " $i " add member " $1);
+	}
+}


2.13.awk

error: pathspec 'chapter2/2.13.awk' did not match any file(s) known to git

--- chapter2/2.13.awk
+++ chapter2/2.13.awk
@@ -0,0 +1,87 @@
+#!/usr/bin/awk -f
+BEGIN	{
+	printf("#include \"apue.h\"\n")
+	printf("#include <erron.h>\n")
+	printf("#include <limits.h>\n")
+	printf("\n")
+	printf("static void pr_sysconf(char *, int);\n")
+	printf("static void pr_pathconf(char *, char *, int");\n")
+	printf("\n")
+	printf("int\n")
+	printf("main(int argc, char *argv[])\n")
+	printf("{\n")
+	printf("\tif (argc != 2)\n")
+	printf("\t\terr_quit{\"usage: a.out <dirname>\";\n\n")
+	FS="\t+"
+	while (getline <"sysconf.sym" > 0) {
+		printf("#ifdef %s\n", $1)
+		printf("\tprintf(\"%s defined to be %%ld\\n", (long)%s+0);\n", $1, $1)
+		printf("#else\n")
+		printf("\tprintf(\"no symbol for %s\\n");\n", $1)
+		printf("#endif\n")
+		printf("#ifdef %s\n", $2)
+		printf("\tpr_sysconf(\"%s = \", %s);\n", $1, $2)
+		printf("#else\n")
+		printf("\tprintf(\"no symbol for %s\\n");\n", $2)
+		printf("#endif\n")
+	}
+	close("sysconf.sym")
+	while (getline <"pathconf.sym" > 0) {
+		printf("#ifdef %s\n", $1)
+        printf(" printf(\"%s defined to be %%d\\n\", %s+0);\n", $1, $1)
+        printf("#else\n")
+        printf(" printf(\"no symbol for %s\\n\");\n", $1)
+        printf("#endif\n")
+        printf("#ifdef %s\n", $2)
+        printf(" pr_pathconf(\"%s =\", argv[1], %s);\n", $1, $2)
+        printf("#else\n")
+        printf(" printf(\"no symbol for %s\\n\");\n", $2)
+        printf("#endif\n")
+    }
+    close("pathconf.sym")
+    exit
+	}
+	END {
+    printf(" exit(0);\n")
+    printf("}\n\n")
+    printf("static void\n")
+    printf("pr_sysconf(char *mesg, int name)\n")
+    printf("{\n")
+    printf(" long val;\n\n")
+    printf(" fputs(mesg, stdout);\n")
+    printf(" errno = 0;\n")
+    printf(" if ((val = sysconf(name)) < 0) {\n")
+    printf("  if (errno != 0) {\n")
+    printf("   if (errno == EINVAL)\n")
+    printf("    fputs(\" (not supported)\\n\", stdout);\n")
+    printf("   else\n")
+    printf("    err_sys(\"sysconf error\");\n")
+    printf("  } else {\n")
+    printf("   fputs(\" (no limit)\\n\", stdout);\n")
+    printf("  }\n")
+    printf(" } else {\n")
+    printf("  printf(\" %%ld\\n\", val);\n")
+    printf(" }\n")
+    printf("}\n\n")
+    printf("static void\n")
+    printf("pr_pathconf(char *mesg, char *path, int name)\n")
+    printf("{\n")
+    printf(" long val;\n")
+    printf("\n")
+    printf(" fputs(mesg, stdout);\n")
+    printf(" errno = 0;\n")
+    printf(" if ((val = pathconf(path, name)) < 0) {\n")
+    printf("  if (errno != 0) {\n")
+    printf("   if (errno == EINVAL)\n")
+    printf("    fputs(\" (not supported)\\n\", stdout);\n")
+    printf("   else\n")
+    printf("    err_sys(\"pathconf error, path = %%s\", path);\n")
+    printf("  } else {\n")
+    printf("   fputs(\" (no limit)\\n\", stdout);\n")
+    printf("  }\n")
+    printf(" } else {\n")
+    printf("  printf(\" %%ld\\n\", val);\n")
+    printf(" }\n")
+    printf("}\n")
+}
+}


Bin numbers - stackoverflow answer

Bin numbers - stackoverflow answer

error: pathspec 'number_binning.awk' did not match any file(s) known to git

--- number_binning.awk
+++ number_binning.awk
@@ -0,0 +1,22 @@
+BEGIN {
+    PROCINFO["sorted_in"]="@ind_num_asc";
+    delta = (delta == "") ? 0.1 : delta;
+};
+
+/^-?([0-9][0-9]*|[0-9]*(\.[0-9][0-9]*))/ {
+    # Special case the [-delta - 0] case so it doesn't bin in the [0-delta] bin
+    fractBin=$1/delta
+    if (fractBin < 0 && int(fractBin) == fractBin)
+        fractBin = fractBin+1
+    prefix = (fractBin <= 0 && int(fractBin) == 0) ? "-" : ""
+    bins[prefix int(fractBin)]++
+}
+
+END {
+    for (var in bins)
+    {
+        srange = sprintf("%0.2f",delta * ((var >= 0) ? var : var-1))
+        erange = sprintf("%0.2f",delta * ((var >= 0) ? var+1 : var))
+        print srange " " erange " " bins[var]
+    }
+}


Add rdf-n3.awk

Add rdf-n3.awk

error: pathspec 'misc/rdf-n3.awk' did not match any file(s) known to git

--- misc/rdf-n3.awk
+++ misc/rdf-n3.awk
@@ -0,0 +1,94 @@
+#!/usr/bin/awk -f
+BEGIN {
+    FS = "\t";
+
+    LABEL         = "<http://www.w3.org/2000/01/rdf-schema#label>";
+    TYPE          = "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>";
+
+    CONCEPT       = "<http://www.w3.org/2004/02/skos/core#Concept>";
+    LEXICALSENSE  = "<http://lemon-model.net/lemon#LexicalSense>";
+    WORD          = "<http://lemon-model.net/lemon#Word>";
+    FORM          = "<http://lemon-model.net/lemon#Form>";
+
+    WRITTENREP    = "<http://lemon-model.net/lemon#writtenRep>";
+    CANONICALFORM = "<http://lemon-model.net/lemon#canonicalForm>";
+    BROADER       = "<http://lemon-model.net/lemon#broader>";
+    NARROWER      = "<http://lemon-model.net/lemon#narrower>";
+    SENSE         = "<http://lemon-model.net/lemon#sense>";
+    ISSENSEOF     = "<http://lemon-model.net/lemon#isSenseOf>";
+    REFERENCE     = "<http://lemon-model.net/lemon#reference>";
+    ISREFERENCEOF = "<http://lemon-model.net/lemon#isReferenceOf>";
+}
+{
+    nsenses = split($3, senses, ", ");
+    nisas   = split($5, isas,   ", ");
+
+    if (nsenses == 0 || nisas == 0) next;
+
+    print ":c" $1, TYPE, CONCEPT, ".";
+
+    for (sense_id in senses) {
+        sense = senses[sense_id];
+
+        sub(":.*$", "", sense);
+
+        if (!(sense in sindex)) {
+            sindex[sense] = scount++;
+
+            word = sense;
+            gsub("_", " ",  word);
+            sub("#.*$", "", word);
+
+            if (!(word in windex)) {
+                windex[word] = wcount++;
+
+                print ":w" windex[word], TYPE,          WORD,              ".";
+                print ":w" windex[word], LABEL,         "\"" word "\"",    ".";
+                print ":f" windex[word], TYPE,          FORM,              ".";
+                print ":f" windex[word], LABEL,         "\"" word "\"",    ".";
+                print ":f" windex[word], WRITTENREP,    "\"" word "\"",    ".";
+                print ":w" windex[word], CANONICALFORM, ":f" windex[word], ".";
+            }
+
+            print ":s" sindex[sense], TYPE,          LEXICALSENSE,       ".";
+            print ":s" sindex[sense], LABEL,         "\"" sense "\"",    ".";
+            print ":s" sindex[sense], ISSENSEOF,     ":w" windex[word],  ".";
+            print ":w" windex[word],  SENSE,         ":s" sindex[sense], ".";
+            print ":s" sindex[sense], REFERENCE,     ":c" $1,            ".";
+            print ":c" $1,            ISREFERENCEOF, ":s" sindex[sense], ".";
+        }
+
+        for (isa_id in isas) {
+            isa = isas[isa_id];
+
+            sub(":.*$", "", isa);
+
+            if (!(isa in sindex)) {
+                sindex[isa] = scount++;
+
+                word = isa;
+                gsub("_", " ",  word);
+                sub("#.*$", "", word);
+
+                if (!(word in windex)) {
+                    windex[word] = wcount++;
+
+                    print ":w" windex[word], TYPE,          WORD,              ".";
+                    print ":w" windex[word], LABEL,         "\"" word "\"",    ".";
+                    print ":f" windex[word], TYPE,          FORM,              ".";
+                    print ":f" windex[word], LABEL,         "\"" word "\"",    ".";
+                    print ":f" windex[word], WRITTENREP,    "\"" word "\"",    ".";
+                    print ":w" windex[word], CANONICALFORM, ":f" windex[word], ".";
+                }
+
+                print ":s" sindex[isa],  TYPE,      LEXICALSENSE,      ".";
+                print ":s" sindex[isa],  LABEL,     "\"" isa "\"",     ".";
+                print ":s" sindex[isa],  ISSENSEOF, ":w" windex[word], ".";
+                print ":w" windex[word], SENSE,     ":s" sindex[isa],  ".";
+            }
+
+            print ":s" sindex[sense], BROADER,  ":s" sindex[isa],   ".";
+            print ":s" sindex[isa],   NARROWER, ":s" sindex[sense], ".";
+        }
+    }
+}


Create filter_it.awk

Create filter_it.awk

Italian filter

error: pathspec 'filter_it.awk' did not match any file(s) known to git

--- filter_it.awk
+++ filter_it.awk
@@ -0,0 +1,197 @@
+BEGIN {}
+/^macro:[:alpha: ]+/ {
+    macroLine = ""
+    # I check every field from the second one(the first one is "macro:")
+    for (x = 2; x <= NF; x++) {
+        do {
+            # I found a keys being kept pressed or just released, I print it as it is
+            # This works because (probably) I don't want to keep pressed keys that need to be translated such as symbols
+            if (length($x) > 1 && (substr($x, 1, 1) == "+" || substr($x, 1, 1) == "-")) {
+                macroLine = macroLine $x;
+                break;
+            }
+            # An upper-case key, I need to press shift to do it. Using the != toupper I avoid triggering things like "," == tolower(",") and "," == toupper(",")
+            if ($x != tolower($x)) {
+                macroLine = macroLine "+lshift,+" tolower($x) ",-" tolower($x) ",-lshift";
+                break;
+            }
+            if ($x == "\\") {
+                macroLine = macroLine "+grave,-grave";
+                break;
+            }
+            if ($x == "|") {
+                macroLine = macroLine "+lshift,+grave,-grave,-lshift";
+                break;
+            }
+            if ($x == "!") {
+                macroLine = macroLine "+lshift,+1,-1,-lshift";
+                break;
+            }
+            if ($x == "\"") {
+                macroLine = macroLine "+lshift,+2,-2,-lshift";
+                break;
+            }
+            if ($x == "£") {
+                macroLine = macroLine "+lshift,+3,-3,-lshift";
+                break;
+            }
+            if ($x == "$") {
+                macroLine = macroLine "+lshift,+4,-4,-lshift";
+                break;
+            }
+            if ($x == "%") {
+                macroLine = macroLine "+lshift,+5,-5,-lshift";
+                break;
+            }
+            if ($x == "&") {
+                macroLine = macroLine "+lshift,+6,-6,-lshift";
+                break;
+            }
+            if ($x == "/") {
+                macroLine = macroLine "+lshift,+7,-7,-lshift";
+                break;
+            }
+            if ($x == "(") {
+                macroLine = macroLine "+lshift,+8,-8,-lshift";
+                break;
+            }
+            if ($x == ")") {
+                macroLine = macroLine "+lshift,+9,-9,-lshift";
+                break;
+            }
+            if ($x == "=") {
+                macroLine = macroLine "+lshift,+0,-0,-lshift";
+                break;
+            }
+            if ($x == "'") {
+                macroLine = macroLine "+minus,-minus";
+                break;
+            }
+            if ($x == "?") {
+                macroLine = macroLine "+lshift,+minus,-minus,-lshift";
+                break;
+            }
+            if ($x == "ì") {
+                macroLine = macroLine "+equal,-equal";
+                break;
+            }
+            if ($x == "^") {
+                macroLine = macroLine "+lshift,+equal,-equal,-lshift";
+                break;
+            }
+            if ($x == "€") {
+                macroLine = macroLine "+ralt,+e,-e,-ralt";
+                break;
+            }
+            if ($x == "è") {
+                macroLine = macroLine "+lbrace,-lbrace";
+                break;
+            }
+            if ($x == "é") {
+                macroLine = macroLine "+lshift,+lbrace,-lbrace,-lshift";
+                break;
+            }
+            if ($x == "[") {
+                macroLine = macroLine "+ralt,+lbrace,-lbrace,-ralt";
+                break;
+            }
+            if ($x == "{") {
+                macroLine = macroLine "+ralt,+lshift,+lbrace,-lbrace,-lshift,-ralt";
+                break;
+            }
+            if ($x == "+") {
+                macroLine = macroLine "+rbrace,-rbrace";
+                break;
+            }
+            if ($x == "*") {
+                macroLine = macroLine "+lshift,+rbrace,-rbrace,-lshift";
+                break;
+            }
+            if ($x == "]") {
+                macroLine = macroLine "+ralt,+rbrace,-rbrace,-ralt";
+                break;
+            }
+            if ($x == "}") {
+                macroLine = macroLine "+ralt,+lshift,+rbrace,-rbrace,-lshift,-ralt";
+                break;
+            }
+            if ($x == "ò") {
+                macroLine = macroLine "+colon,-colon";
+                break;
+            }
+            if ($x == "ç") {
+                macroLine = macroLine "+lshift,+colon,-colon,-lshift";
+                break;
+            }
+            if ($x == "@") {
+                macroLine = macroLine "+ralt,+colon,-colon,-ralt";
+                break;
+            }
+            if ($x == "à") {
+                macroLine = macroLine "+quote,-quote";
+                break;
+            }
+            if ($x == "°") {
+                macroLine = macroLine "+lshift,+quote,-quote,-lshift";
+                break;
+            }
+            if ($x == "#") {
+                macroLine = macroLine "+ralt,+quote,-quote,-ralt";
+                break;
+            }
+            if ($x == "ù") {
+                macroLine = macroLine "+hash,-hash";
+                break;
+            }
+            if ($x == "§") {
+                macroLine = macroLine "+lshift,+hash,-hash,-lshift";
+                break;
+            }
+            if ($x == "<") {
+                macroLine = macroLine "+bslash_iso,-bslash_iso";
+                break;
+            }
+            if ($x == ">") {
+                macroLine = macroLine "+lshift,+bslash_iso,-bslash_iso,-lshift";
+                break;
+            }
+            if ($x == ",") {
+                macroLine = macroLine "+comma,-comma";
+                break;
+            }
+            if ($x == ";") {
+                macroLine = macroLine "+lshift,+comma,-comma,-lshift";
+                break;
+            }
+            if ($x == ".") {
+                macroLine = macroLine "+dot,-dot";
+                break;
+            }
+            if ($x == ":") {
+                macroLine = macroLine "+lshift,+dot,-dot,-lshift";
+                break;
+            }
+            if ($x == "-") {
+                macroLine = macroLine "+slash,-slash";
+                break;
+            }
+            if ($x == "_") {
+                macroLine = macroLine "+lshift,+slash,-slash,-lshift";
+                break;
+            }
+
+            # A normal key, press and release it, catches all the remaining cases
+            macroLine = macroLine "+" $x ",-" $x
+        }
+        while (0)
+        # 0 means it runs only once instead of endlessly looping in case of errors
+
+        # I add a comma between this key and the next unless I 'm at the last one
+        if (x < NF)
+            macroLine = macroLine ","
+        else
+            # Finished reading the macro, sending it macro to the output
+            print macroLine
+    }
+}
+END {}


builtin

builtin

error: pathspec 'src/awk/builtin.awk' did not match any file(s) known to git

--- src/awk/builtin.awk
+++ src/awk/builtin.awk
@@ -0,0 +1,13 @@
+#! /bin/awk -f
+
+#find mean and variance of a column from a file
+BEGIN {
+}
+#body
+{
+   alen=length($2)
+   if (alen >= 29)
+      print $2, alen
+}
+END {
+}


Add only unique reads for paired end filter

error: pathspec 'lib/optical/filters/paired_end_only_unique.awk' did not match any file(s) known to git

--- lib/optical/filters/paired_end_only_unique.awk
+++ lib/optical/filters/paired_end_only_unique.awk
@@ -0,0 +1,60 @@
+BEGIN {
+  OFS="\t";
+  lastid="";
+  id_counts=0;
+}
+{
+  if ( $1 ~ /^@/ )
+  {
+    # headers go straight through
+    print $0;
+    next;
+  }
+  if (lastid == "") {
+    lastid=$1;
+    r1["read"] = $0;
+    r1["chr"] = $3;
+    r1["tags"] = "";
+    for(i=12;i<NF;i++) { r1["tags"]=r1["tags"] $i " ";}
+    r1["tags"]=r1["tags"] $i;
+    next;
+  }
+
+  if ( lastid == $1 ) {
+    id_counts++;
+    if ( id_counts == 2 ) {
+      r2["read"] = $0;
+      r2["chr"] = $3;
+      r2["tags"] = "";
+      for(i=12;i<NF;i++) { r2["tags"]=r2["tags"] $i " ";}
+      r2["tags"]=r2["tags"] $i;
+    }
+  } else if ( lastid != $1 ) {
+    if ( 2 == id_counts ) {
+      # two matching ends of a pair, should we include them?
+      if ( (r1["chr"] ~ /chr([[:digit:]]+|[XY]|MT)/) && (r2["chr"] ~ /chr([[:digit:]]+|[XY]|MT)/) &&
+           (r1["tags"] ~ /XT:A:U/) && (r2["tags"] ~ /XT:A:U/) ) {
+             print r1["read"];
+             print r2["read"];
+      }
+    }
+    id_counts=1;
+    lastid=$1;
+    r1["read"] = $0;
+    r1["chr"] = $3;
+    r1["tags"]="";
+    for(i=12;i<NF;i++) { r1["tags"]=r1["tags"] $i " ";}
+    r1["tags"]=r1["tags"] $i;
+  }
+
+}
+END {
+  if ( 2 == id_counts ) {
+    # two matching ends of a pair, should we include them?
+    if ( (r1["chr"] ~ /chr([[:digit:]]+|[XY]|MT)/) && (r2["chr"] ~ /chr([[:digit:]]+|[XY]|MT)/) &&
+         (r1["tags"] ~ /XT:A:U/) && (r2["tags"] ~ /XT:A:U/) ) {
+           print r1["read"];
+           print r2["read"];
+    }
+  }
+}


extract lines from the file until max blank lines are seen

error: pathspec 'head.awk' did not match any file(s) known to git


Dedup filter for gpx recorded by endomondo

error: pathspec 'fitness/gpxfilter.awk' did not match any file(s) known to git

--- fitness/gpxfilter.awk
+++ fitness/gpxfilter.awk
@@ -0,0 +1,16 @@
+BEGIN { skipping=0; cur = ""; }
+{
+  if ($0 ~ /trkpt lat/) {
+      if (cur == $0) {
+	  skipping = 1;
+      } else {
+	  skipping = 0;
+      }
+      cur = $0;
+  }
+  if (skipping) {
+  } else {
+      print $0;
+  }
+}
+END   { }


Added AWK version.

Added AWK version.

error: pathspec 'prime.awk' did not match any file(s) known to git

--- prime.awk
+++ prime.awk
@@ -0,0 +1,21 @@
+#!/usr/bin/awk -f
+
+function isPrime (x) {
+    if (sqrt(x) % 1 == 0)
+        return 0
+    for (j = 2; j < sqrt(x); j++)
+        if (x % j == 0)
+            return 0
+    return 1
+}
+
+BEGIN {
+    n = 0
+    for (i = 0;  n < ARGV[1]; i++)
+        if (isPrime(i)) {
+            arr[n] = i
+            n++
+        }
+    for (i in arr)
+        print arr[i]
+}


Add toloka-gold-isas.awk

Add toloka-gold-isas.awk

error: pathspec 'misc/toloka-gold-isas.awk' did not match any file(s) known to git

--- misc/toloka-gold-isas.awk
+++ misc/toloka-gold-isas.awk
@@ -0,0 +1,13 @@
+#!/usr/bin/awk -f
+BEGIN {
+    FS = OFS = "\t";
+}
+FNR == 1 {
+    for (i=1; i<=NF; i++) ix[$i] = i;
+    next;
+}
+tolower($ix["OUTPUT:judgement"]) == "true" {
+    for (i = 1; i <= split($ix["INPUT:hypernym"], hypernyms, ", "); i++) {
+        print $ix["INPUT:hyponym"], hypernyms[i];
+    }
+}


Extract barcodes done

Extract barcodes done

error: pathspec 'extract_barcodes/extract_barcodes.awk' did not match any file(s) known to git

--- extract_barcodes/extract_barcodes.awk
+++ extract_barcodes/extract_barcodes.awk
@@ -0,0 +1,14 @@
+{
+    if (NR % 8 == 1 && NR > 1) {
+        barcode = substr(read_pair[2], 1, 16)
+        printf read_pair[1]" BX:Z:"barcode"\n"
+        printf substr(read_pair[2], 17)"\n"
+        printf read_pair[3]"\n"
+        printf substr(read_pair[4], 17)"\n"
+        printf read_pair[5]" BX:Z:"barcode"\n"
+        printf read_pair[6]"\n"
+        printf read_pair[7]"\n"
+        printf read_pair[0]"\n"
+    }
+    read_pair[NR % 8] = $0
+}


Add ncsa_response_times.awk

Add ncsa_response_times.awk

Signed-off-by: Kevin Grigorenko <998fc961d8f3868bf77492ff63381353a0fb578e@us.ibm.com>

error: pathspec 'scripts/general/ncsa_response_times.awk' did not match any file(s) known to git

--- scripts/general/ncsa_response_times.awk
+++ scripts/general/ncsa_response_times.awk
@@ -0,0 +1,371 @@
+#!/usr/bin/awk -f
+# usage: ncsa_response_times.awk [-v "option=value"] access_log... | sort -n
+#   (First chmod a+x ncsa_response_times.awk)
+#   The sort is needed because statistics are stored in an associative array dumped at the end and it's unordered.
+#   Default LogFormat is assumed to be LogFormat "%h %l %u %t \"%r\" %>s %b %D \"%{WAS}e\" %X" common
+#   Field descriptions: https://httpd.apache.org/docs/current/mod/mod_log_config.html#formats
+#
+# Output (CSV):
+# 010SortableDateTime,Date,Day,Time,ArrivalsPer%s,ThroughputAllPer%s,Throughput4xxPer%s,Throughput5xxPer%s,ResponseTimesSumPer%s(%s),MeanResponseTimePer%s(%s),MaxResponseTimePer%s(%s),ResponseBytesSumPer%s,MeanResponseSizeBytesPer%s,MaxResponseSizeBytesPer%s
+#
+# Options:
+#   Column offset of %D starting from the left (1 is the first column, 2 is second, etc.):
+#     -v response_time_offset_left=X
+#   Column offset of %D starting from the right (0 is the last column, 1 is second-to-last, etc.):
+#     -v response_time_offset_right=X
+#   Column offset of %t starting from the left (1 is the first column, 2 is second, etc.):
+#     -v date_offset_left=X
+#   Column offset of %t starting from the right (0 is the last column, 1 is second-to-last, etc.):
+#     -v date_offset_right=X
+#   Column offset of %s starting from the left (1 is the first column, 2 is second, etc.):
+#     -v status_offset_left=X
+#   Column offset of %s starting from the right (0 is the last column, 1 is second-to-last, etc.):
+#     -v status_offset_right=X
+#   Column offset of %b starting from the left (1 is the first column, 2 is second, etc.):
+#     -v response_size_offset_left=X
+#   Column offset of %b starting from the right (0 is the last column, 1 is second-to-last, etc.):
+#     -v response_size_offset_right=X
+#   Column offset of %{WAS}e starting from the left (1 is the first column, 2 is second, etc.):
+#     -v jvm_offset_left=X
+#   Column offset of %{WAS}e starting from the right (0 is the last column, 1 is second-to-last, etc.):
+#     -v jvm_offset_right=X
+#   Per-minute instead of per-second:
+#     -v per_minute=true
+#   Suppress printing the CSV header:
+#     -v noheader=true
+#   Response times in milliseconds instead of microseconds:
+#     -v responsems=true
+#   Debug:
+#     -v debug=true
+#   Divide transaction rates:
+#     -v divtranrates=X
+#   Don't skip rows with 0 responses:
+#     -v noskip0=true
+#   ODR %t time format:
+#     -v odrtimeformat=true
+
+BEGIN {
+  per_second = 1;
+  per_title = "S";
+  if (per_minute) {
+    per_second = 0;
+    per_title = "M";
+  }
+  if (length(date_offset_left) == 0 && length(date_offset_right) == 0) {
+    date_offset_left = 4;
+  }
+  if (length(status_offset_left) == 0 && length(status_offset_right) == 0) {
+    status_offset_left = 9;
+  }
+  if (length(response_time_offset_left) == 0 && length(response_time_offset_right) == 0) {
+    response_time_offset_right = 2;
+  }
+  if (length(response_size_offset_left) == 0 && length(response_size_offset_right) == 0) {
+    response_size_offset_left = 10;
+  }
+
+  if (odrtimeformat) {
+    responsems = 1;
+  }
+
+  responseunit = "us";
+  if (responsems) {
+    responseunit = "ms";
+  }
+  if (!divtranrates) {
+    divtranrates = 1;
+  }
+  hasJVMs = 0;
+}
+
+function printHeader() {
+  if (!noheader) {
+    printf( \
+      "010SortableDateTime,Date,Day,Time,ArrivalsPer%s,ThroughputAllPer%s,Throughput4xxPer%s,Throughput5xxPer%s,ResponseTimesSumPer%s(%s),MeanResponseTimePer%s(%s),MaxResponseTimePer%s(%s),ResponseBytesSumPer%s,MeanResponseSizeBytesPer%s,MaxResponseSizeBytesPer%s", \
+      per_title, \
+      per_title, \
+      per_title, \
+      per_title, \
+      per_title, \
+      responseunit, \
+      per_title, \
+      responseunit, \
+      per_title, \
+      responseunit, \
+      per_title, \
+      per_title, \
+      per_title \
+    );
+    if (hasJVMs) {
+      printf(",JVM");
+    }
+    printf("\n");
+  }
+}
+
+# Match every line
+{
+  if (date_offset_left) {
+    date = $(date_offset_left);
+  } else {
+    date = $(NF - date_offset_right);
+  }
+  if (status_offset_left) {
+    status = $(status_offset_left);
+  } else {
+    status = $(NF - status_offset_right);
+  }
+
+  if (!odrtimeformat) {
+    gsub(/\[/, "", date);
+    gsub(/\//, ":", date);
+    split(date, date_pieces, ":");
+    isoihsdate = sprintf("%d%02d%02d%02d%02d%02d", date_pieces[3], getMonthInteger(date_pieces[2]), date_pieces[1], date_pieces[4], date_pieces[5], date_pieces[6]);
+    day = sprintf("%d-%02d-%02d", date_pieces[3], getMonthInteger(date_pieces[2]), date_pieces[1]);
+    time = sprintf("%02d:%02d:%02d", date_pieces[4], date_pieces[5], date_pieces[6]);
+  } else {
+    # 09/sept./2021:10:36:54
+    split(date, pieces, "/");
+    split(pieces[3], date_pieces, ":");
+    isoihsdate = sprintf("%d%02d%02d%02d%02d%02d", date_pieces[1], getMonthIntegerODR(pieces[2]), pieces[1], date_pieces[2], date_pieces[3], date_pieces[4]);
+    day = sprintf("%d-%02d-%02d", date_pieces[1], getMonthIntegerODR(pieces[2]), pieces[1]);
+    time = sprintf("%02d:%02d:%02d", date_pieces[2], date_pieces[3], date_pieces[4]);
+  }
+
+  if (!per_second) {
+    gsub(/..$/, "", isoihsdate);
+    gsub(/:..$/, "", time);
+  }
+
+  if (response_time_offset_left) {
+    response_time = $(response_time_offset_left);
+  } else {
+    response_time = $(NF - response_time_offset_right);
+  }
+
+  if (response_size_offset_left) {
+    response_size = $(response_size_offset_left);
+  } else {
+    response_size = $(NF - response_size_offset_right);
+  }
+
+  arrivalisoihsdate = isoihsdate + 0;
+  if (!per_second) {
+    arrivalisoihsdate *= 100;
+  }
+  originalarrivalisoihsdate = arrivalisoihsdate;
+  if (!odrtimeformat) {
+    if (responsems) {
+      response_time = (response_time + 0) / 1000;
+      if (response_time >= 1000) {
+        arrivalisoihsdate -= response_time / 1000;
+        arrivalisoihsdate = int(arrivalisoihsdate);
+      }
+    } else {
+      # microseconds
+      if (response_time >= 1000000) {
+        arrivalisoihsdate -= response_time / 1000000;
+        arrivalisoihsdate = int(arrivalisoihsdate);
+      }
+    }
+  } else {
+    response_time = response_time + 0;
+    arrivalisoihsdate -= response_time / 1000;
+    arrivalisoihsdate = int(arrivalisoihsdate);
+  }
+
+  if (int(arrivalisoihsdate % 100) >= 60) {
+    arrivalisoihsdate -= 40;
+  }
+  if (!per_second) {
+    arrivalisoihsdate = int(arrivalisoihsdate / 100);
+  }
+
+  if (arrivalisoihsdate == 0) {
+    printf("001WARNING (%s): Could not parse date for %s %s\n", FILENAME, $0, isoihsdate) > "/dev/stderr";
+  }
+
+  key = "all";
+
+  if (jvm_offset_left) {
+    key = $(jvm_offset_left);
+    gsub(/"/, "", key);
+    hasJVMs = 1;
+  } else if (length(jvm_offset_right) > 0) {
+    key = $(NF - jvm_offset_right);
+    gsub(/"/, "", key);
+    hasJVMs = 1;
+  }
+
+  arrival_count = arrival_counts[key, arrivalisoihsdate] + 0;
+  arrival_counts[key, arrivalisoihsdate] = arrival_count + 1;
+
+  arrival_counts[key, originalarrivalisoihsdate] = arrival_counts[key, originalarrivalisoihsdate] + 0;
+
+  if (debug) {
+    printDebug($0 "; date: " date ", status: " status ", isoihsdate: " isoihsdate ", day: " day ", time: " time ", responsetime: " response_time);
+  }
+
+  sum = response_time_sums[key, isoihsdate] + 0;
+  response_time_sums[key, isoihsdate] = sum + response_time;
+
+  sum = response_size_sums[key, isoihsdate] + 0;
+  response_size_sums[key, isoihsdate] = sum + response_size;
+
+  count = response_time_counts[key, isoihsdate] + 0;
+  response_time_counts[key, isoihsdate] = count + 1;
+
+  max = response_time_maximums[key, isoihsdate] + 0;
+  if (response_time > max) {
+    response_time_maximums[key, isoihsdate] = response_time;
+  }
+
+  max = response_size_maximums[key, isoihsdate] + 0;
+  if (response_size > max) {
+    response_size_maximums[key, isoihsdate] = response_size;
+  }
+
+  count = errors4xx_counts[key, isoihsdate] + 0;
+  if (status >= 400 && status < 500) {
+    count = count + 1;
+  }
+  errors4xx_counts[key, isoihsdate] = count;
+
+  count = errors5xx_counts[key, isoihsdate] + 0;
+  if (status >= 500) {
+    count = count + 1;
+  }
+  errors5xx_counts[key, isoihsdate] = count;
+
+  days[key, isoihsdate] = day;
+  times[key, isoihsdate] = time;
+}
+
+function getMonthInteger(month) {
+  if (month == "Jan") {
+    return 1;
+  } else if (month == "Feb") {
+    return 2;
+  } else if (month == "Mar") {
+    return 3;
+  } else if (month == "Apr") {
+    return 4;
+  } else if (month == "May") {
+    return 5;
+  } else if (month == "Jun") {
+    return 6;
+  } else if (month == "Jul") {
+    return 7;
+  } else if (month == "Aug") {
+    return 8;
+  } else if (month == "Sep") {
+    return 9;
+  } else if (month == "Oct") {
+    return 10;
+  } else if (month == "Nov") {
+    return 11;
+  } else if (month == "Dec") {
+    return 12;
+  }
+  return 0;
+}
+
+function getMonthIntegerODR(month) {
+  if (month ~ /jan/) {
+    return 1;
+  } else if (month ~ /feb/) {
+    return 2;
+  } else if (month ~ /mar/) {
+    return 3;
+  } else if (month ~ /apr/) {
+    return 4;
+  } else if (month ~ /may/) {
+    return 5;
+  } else if (month ~ /jun/) {
+    return 6;
+  } else if (month ~ /jul/) {
+    return 7;
+  } else if (month ~ /aug/) {
+    return 8;
+  } else if (month ~ /sep/) {
+    return 9;
+  } else if (month ~ /oct/) {
+    return 10;
+  } else if (month ~ /nov/) {
+    return 11;
+  } else if (month ~ /dec/) {
+    return 12;
+  }
+  return 0;
+}
+
+function printDebug(message) {
+  printf("DEBUG: %s\n", message);
+}
+
+function array2d_tokeys(array) {
+  delete a2d2k;
+  for (key in array) {
+    split(key, pieces, SUBSEP);
+    if (length(a2d2k[pieces[1]]) == 0) {
+      a2d2k[pieces[1]] = pieces[2];
+    } else {
+      a2d2k[pieces[1]] = a2d2k[pieces[1]] SUBSEP pieces[2];
+    }
+  }
+}
+
+END {
+  array2d_tokeys(arrival_counts);
+  printHeader();
+  for (key in a2d2k) {
+    split(a2d2k[key], pieces, SUBSEP);
+    for (piecesKey in pieces) {
+      date = pieces[piecesKey];
+      dt = days[key, date];
+      tm = times[key, date];
+      if (!dt) {
+        if (per_second) {
+          dt = sprintf("%d-%02d-%02d", date / 10000000000, (date / 100000000) % 1000, (date / 1000000) % 100);
+          tm = sprintf("%d:%02d:%02d", (date / 10000) % 100, (date / 100) % 100, date % 100);
+        } else {
+          dt = sprintf("%d-%02d-%02d", date / 100000000, (date / 1000000) % 1000, (date / 10000) % 100);
+          tm = sprintf("%d:%02d", (date / 100) % 100, date % 100);
+        }
+      }
+      arrivals = (arrival_counts[key, date] + 0) / divtranrates;
+      responses = (response_time_counts[key, date] + 0) / divtranrates;
+
+      # ct is to compute averages. We don't divide by divtranrates here as that would skew the average
+      ct = response_time_counts[key, date] + 0
+      if (ct == 0) {
+        ct = 1;
+      }
+
+      if (responses > 0 || (responses == 0 && noskip0)) {
+        printf( \
+          "%s,%s %s,%s,%s,%d,%d,%d,%d,%d,%.2f,%d,%d,%.2f,%d", \
+          date, \
+          dt, \
+          tm, \
+          dt, \
+          tm, \
+          arrivals, \
+          responses, \
+          errors4xx_counts[key, date] + 0, \
+          errors5xx_counts[key, date] + 0, \
+          response_time_sums[key, date] + 0, \
+          (response_time_sums[key, date] + 0) / ct, \
+          response_time_maximums[key, date] + 0, \
+          response_size_sums[key, date], \
+          (response_size_sums[key, date] + 0) / ct, \
+          response_size_maximums[key, date] \
+        );
+        if (key != "all") {
+          printf(",%s", key);
+        }
+        printf("\n");
+      }
+    }
+  }
+}


INTEGRATION: CWS internatiodel (1.1.2); FILE ADDED 2006/02/10 19:13:27 er 1.1.2.1: #i52115# move tools/source/intntl/ to i18npool/source/isolang/

error: pathspec 'i18npool/source/isolang/lcid.awk' did not match any file(s) known to git

--- i18npool/source/isolang/lcid.awk
+++ i18npool/source/isolang/lcid.awk
@@ -0,0 +1,119 @@
+#!/usr/bin/awk -f
+#
+# Utility to compare MS-LANGID definitions with those defined in ../../inc/i18npool/lang.hxx
+# Run in i18npool/source/isolang
+#
+# outputs new #define LANGUAGE_... 0x... and also some commented out substrings
+# that were matched in already existing defines.
+#
+# Expects input from the saved page of
+#
+# (1)
+# http://www.microsoft.com/globaldev/reference/lcid-all.mspx
+# filtered through ``html2text -nobs ...'', generated table:
+# blank,name,hex,dec fields:
+#    |Afrikaans_-_South_Africa____________|0436|1078_|
+# Best if file cleaned up to _only_ contain the table entries, but not
+# necessary, entries are filtered. Check output.
+#
+# complete command line:
+# lynx -dump -source http://www.microsoft.com/globaldev/reference/lcid-all.mspx | html2text -nobs | awk -f lcid.awk >outfile
+#
+#
+# (2)
+# http://www.microsoft.com/globaldev/reference/winxp/xp-lcid.mspx
+# filtered through ``html2text -nobs ...'', generated table:
+# blank,name,hex,dec,inputlocales,collection fields:
+#    |Afrikaans                           |0436|1078 |0436:       |Basic     |
+# Best if file cleaned up to _only_ contain the table entries, but not
+# necessary, entries are filtered. Check output.
+#
+# complete command line:
+# lynx -dump -source http://www.microsoft.com/globaldev/reference/winxp/xp-lcid.mspx | html2text -nobs | awk -f lcid.awk >outfile
+#
+# Author: Eike Rathke <erack@sun.com>, <er@openoffice.org>
+#
+
+BEGIN {
+    while ((getline < "../../inc/i18npool/lang.hxx") > 0)
+    {
+        if ($0 ~ /^#define[ ]*LANGUAGE_[_A-Za-z0-9]*[ ]*0x[0-9a-fA-F]/)
+        {
+            # lang[HEX]=NAME
+            lang[toupper(substr($3,3))] = toupper($2)
+            #print substr($3,3) "=" $2
+        }
+    }
+    # html2text table follows
+    FS = "\|"
+    filetype = 0
+    lcid_all = 1
+    xp_lcid  = 2
+}
+
+(NF < 5) { next }
+
+!filetype {
+    if (NF == 5)
+        filetype = lcid_all
+    else if (NF == 7)
+        filetype = xp_lcid
+    else
+        next
+}
+
+($3 !~ /^[0-9a-fA-F][0-9a-fA-F]*$/) { filtered[$3] = $0; next }
+
+# all[HEX]=string
+{ all[toupper($3)] = $2 }
+
+# new hex: newlang[HEX]=string
+!(toupper($3) in lang) { newlang[toupper($3)] = $2 }
+
+END {
+    if (!filetype)
+    {
+        print "No file type (lcid-all|xp-lcid) recognized." >>"/dev/stderr"
+        exit(1)
+    }
+    else if (filetype == lcid_all)
+        print "// assuming lcid-all file"
+    else if (filetype == xp_lcid)
+        print "// assuming xp-lcid file"
+    else
+        print "// unknown file type"
+    # every new language
+    for (x in newlang)
+    {
+        printf( "xxxxxxx LANGUAGE_%-26s 0x%s\n", newlang[x], x)
+        n = split(newlang[x],arr,/[^A-Za-z0-9]/)
+        def = ""
+        for (i=1; i<=n; ++i)
+        {
+            if (length(arr[i]))
+            {
+                # each identifier word of the language name
+                if (def)
+                    def = def "_"
+                aup = toupper(arr[i])
+                def = def aup
+                for (l in lang)
+                {
+                    #  contained in already existing definitions?
+                    if (lang[l] ~ aup)
+                        printf( "// %-50s %s\n", arr[i] ": " lang[l], l)
+                }
+            }
+        }
+        printf( "#define LANGUAGE_%-26s 0x%s\n", def, x)
+    }
+    print "\n// --- reverse check follows ----------------------------------\n"
+    for (x in lang)
+    {
+        if (!(x in all))
+            print "// not in input file:   " x "  " lang[x]
+    }
+    print "\n// --- filtered table entries follow (if any) -----------------\n"
+    for (x in filtered)
+        print "// filtered:   " x "  " filtered[x]
+}


Added push_pop_indent script

Added push_pop_indent script

error: pathspec 'tools/push_pop_indent.awk' did not match any file(s) known to git

--- tools/push_pop_indent.awk
+++ tools/push_pop_indent.awk
@@ -0,0 +1,18 @@
+#!/bin/awk -f
+
+/pop/ {
+	if(--indent < 0)
+		print "AWK: indent less than zero (" indent ")" #| "cat >&2"
+}
+
+{
+	i = indent
+	while(i --> 0)
+		printf "\t"
+
+	print $0
+}
+
+/push/ {
+	indent++
+}


sage-spy: last-modified

sage-spy: last-modified

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/svnpenn/sage.git/'


print "try 1.7 for FTP"

print "try 1.7 for FTP"


checkFile: olap4j header format has changed.

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/citycloud-bigdata/mondrian.git/'


error: pathspec 'dev/scripts/junit.awk' did not match any file(s) known to git

--- dev/scripts/junit.awk
+++ dev/scripts/junit.awk
@@ -0,0 +1,39 @@
+# Example of usage :
+#
+#   ./build junit | awk -f ../dev/scripts/junit.awk
+#
+# or
+#
+#   ./build junit | tee junit.log | awk -f ../dev/scripts/junit.awk
+#
+
+BEGIN {
+    nberr = 0;
+    prev = "";
+    current = "";
+    errors = "";
+}
+
+{
+  if ( $0 ~ /\[junit\]/ ) {
+    prev = current;
+    current = $3;
+
+    if ( $0 ~ /(Failures|Errors): [1-9]+/ ) {
+        nberr++;
+	errors = errors "\n  " prev
+    }
+
+    sub(/run: [0-9]+/, "\033[32;1m&\033[0m");
+    sub(/(Failures|Errors): [1-9]+/, "\033[31;1m&\033[0m");
+    sub(/[0-9.]+ sec/, "\033[29;1m&\033[0m");
+
+    print
+  }
+}
+
+END {
+    if ( nberr > 0 ) {
+	print "\033[31;1mThere was " nberr " failure" ( nberr>1 ? "s" : "" ) " : " errors "\033[0m"
+    }
+}


add subnetRRD.awk

add subnetRRD.awk

error: pathspec 'subnetRRD.awk' did not match any file(s) known to git

--- subnetRRD.awk
+++ subnetRRD.awk
@@ -0,0 +1,31 @@
+#!/bin/awk -f
+
+BEGIN{ lastInt = 0; }
+/unixSecondsUTC/{
+  currentInt = $2 - ($2 % 300);
+  if(currentInt != lastInt) {
+    cmd="rrdtool update subnet.rrd";
+    templates = "--template ";
+    values=lastInt;
+    i=0;
+    for(key in count) {
+      templates=templates"n"key":";
+      values=values":"count[key];
+      i++;
+    }
+    sub( /.$/, "", templates );
+    if(i>0){
+	print cmd" "templates" "values;
+    }
+    lastInt = currentInt;
+    delete count;
+  }
+}
+/dstIP/{
+    vlan = $2;
+    split(vlan,tmp,".");
+    key = tmp[3];
+    count[key] = count[key] + 1;
+}
+END{}
+


2007-12-31  Martin Sebor  <sebor@roguewave.com>

	* xcomp.awk: Escaped the question mark in invocation of gsub() to
	silence the FreeBSD error: illegal primary in regular expression.

git-svn-id: 1e8a4076bc3774682289f662a06025447996ff23@607789 13f79535-47bb-0310-9956-ffa450edef68

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/pathscale/stdcxx.git/'


Added draft version of 'gen_jnienv_go.awk'

error: pathspec 'jni/scripts/gen_jnienv_go.awk' did not match any file(s) known to git

--- jni/scripts/gen_jnienv_go.awk
+++ jni/scripts/gen_jnienv_go.awk
@@ -0,0 +1,144 @@
+BEGIN {
+	# Beginning Stub
+	print "#include \"jnienv.h\""
+}
+
+func join(array, separator) {
+	buffer = array[1]
+	for (i = 2; i <= length(array); i++) {
+		buffer = buffer separator array[i]
+	}
+	return buffer
+}
+
+func get_return_type(declaration) {
+	match(declaration, /^[^ ]+/)
+	return substr(declaration, 1, RLENGTH)
+}
+
+func get_method(declaration) {
+	match(declaration, /_GoJni[^(]+/)
+	return substr(declaration, RSTART + 6, RLENGTH - 6)
+}
+
+func get_parameter_list(declaration) {
+	match(declaration, /\([^)]+\)/)
+	return substr(declaration, RSTART + 1, RLENGTH - 2)
+}
+
+func get_first_parameter_type(parameter_list) {
+	if (parameter_list == "") {
+		return ""
+	}
+	match(parameter_list, / [^ ,]+(, |$)/)
+	return substr(parameter_list, 1, RSTART - 1)
+}
+
+func get_first_parameter_name(parameter_list) {
+	if (parameter_list == "") {
+		return ""
+	}
+	match(parameter_list, / [^ ,]+(, |$)/)
+	first_parameter_name = substr(parameter_list, RSTART + 1, RLENGTH - 1)
+	len = length(first_parameter_name)
+	if (substr(first_parameter_name, len - 1) == ", ") {
+		return substr(first_parameter_name, 1, len - 2)
+	}
+	return first_parameter_name
+}
+
+func remove_first_parameter(parameter_list) {
+	if (parameter_list == "") {
+		return ""
+	}
+	match(parameter_list, /^[^,]+(, |$)/)
+	return substr(parameter_list, RLENGTH + 1)
+}
+
+func transform_type(type) {
+	if (type == "void") {
+		return ""
+	}
+	if (substr(type, 1, 6) == "const ") {
+		type = substr(type, 7)
+	}
+	len = length(type)
+	if (substr(type, len) == "*") {
+		type = "*C." substr(type, 1, len - 1)
+	} else {
+		type = "C." type
+	}
+	return type
+}
+
+func transform_parameter_name(parameter_name) {
+	if (parameter_name == "len") {
+		return "_len"
+	}
+	return parameter_name
+}
+
+/^\/\/ jni.h:$/ {
+	print ""
+	print
+}
+
+/^\/\/  / {
+	print
+}
+
+/^[^#\/]/ {
+	# Method
+	m = get_method($0)
+	printf "func " m "("
+
+	# Parameter List
+	pl = get_parameter_list($0)
+	for (i in ps) {
+		delete ps[i]
+	}
+	i = 1
+	while (1) {
+		pt1 = get_first_parameter_type(pl)
+		if (pt1 == "") {
+			break
+		}
+		pn1 = get_first_parameter_name(pl)
+		ps[i] = transform_parameter_name(pn1) " " transform_type(pt1)
+		pl = remove_first_parameter(pl)
+		++i
+	}
+	printf join(ps, ", ")
+
+	# Return Type
+	rt = get_return_type($0)
+	if (rt == "void") {
+		print ") {"
+	} else {
+		print ") " transform_type(rt) " {"
+	}
+
+	# Invocation
+	pl = get_parameter_list($0)
+	for (i in pns) {
+		delete pns[i]
+	}
+	i = 1
+	while (1) {
+		pn1 = get_first_parameter_name(pl)
+		if (pn1 == "") {
+			break
+		}
+		pns[i] = transform_parameter_name(pn1)
+		pl = remove_first_parameter(pl)
+		++i
+	}
+	if (rt == "void") {
+		print "\t" "C._GoJni" m "(" join(pns, ", ") ")"
+	} else {
+		print "\t" "return C._GoJni" m "(" join(pns, ", ") ")"
+	}
+
+	# End
+	print "}"
+}


2008-03-14  Martin Sebor  <sebor@roguewave.com>

	* bin/xcomp.awk: Escaped a forward slash to make FreeBSD awk happy.

git-svn-id: 8ce9432b95a2a271c6c279131eb1bb968a8ee7fb@637274 13f79535-47bb-0310-9956-ffa450edef68


x

x

git-svn-id: 193148810cf65385f3a195dbc9a8b504846da3a2@4133 ec53bebd-3082-4978-b11e-865c3cabbd6b

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/madscientist159/heimdal.git/'


filter some triples for the diagrams

filter some triples for the diagrams

error: pathspec 'doc/examples/source/data-gov/1554-frbr-demo-explore/version/2011-Sep-19-frbr/doc/filter.awk' did not match any file(s) known to git

--- doc/examples/source/data-gov/1554-frbr-demo-explore/version/2011-Sep-19-frbr/doc/filter.awk
+++ doc/examples/source/data-gov/1554-frbr-demo-explore/version/2011-Sep-19-frbr/doc/filter.awk
@@ -0,0 +1,9 @@
+{
+        if ( $0~/#hasHash/ ) {}
+   else if ( $0~/#TabularDigest/ ) {}
+   else if ( $0~/#hashAlgorithm/ ) {}
+   else if ( $0~/#hashValue/ ) {}
+   else if ( $0~/hash:Item/ ) {}
+   else if ( $0~/p.surfrdf/ ) {}
+   else { print }
+}


make output more colorful

make output more colorful

error: pathspec 'print_color.awk' did not match any file(s) known to git

--- print_color.awk
+++ print_color.awk
@@ -0,0 +1,40 @@
+#!/bin/awk -f
+
+BEGIN {
+    #define verables
+    flag=1
+    begin_p=bp
+    end_p=ep
+    output=o
+    color=c
+    help=h
+
+    #print help part
+    if(h!="no"){
+        print "\x1b[7mUsage:\tprint_color.awk [-v 'bp=regex'][-v 'ep=regex'][-v c=color][-v o=only]\x1b[m\x1b[m"
+        print "\x1b[7m\tbp|ep is a regex match to special output row.\x1b[m\x1b[m"
+        print "\x1b[7m\tcolor=black|red|green|yellow|blue|purple|cyan|white default is white\x1b[m\x1b[m"
+        print "\x1b[7m\tif option 'o' equels 'only',means only output between [bp,ep]\x1b[m\x1b[m"
+        print "\x1b[7m\tif option 'h' equels 'no',means don't show help infomation\x1b[m\x1b[m"
+    }
+}
+$0 ~ begin_p {
+    flag=0
+}
+flag==0 {
+    if(color=="black"){print "\x1b[30m",$0,"\x1b[m\x1b[m"}
+    else if(color=="red"){print "\x1b[31m",$0,"\x1b[m\x1b[m"}
+    else if(color=="green"){print "\x1b[32m",$0,"\x1b[m\x1b[m"}
+    else if(color=="yellow"){print "\x1b[33m",$0,"\x1b[m\x1b[m"}
+    else if(color=="blue"){print "\x1b[34m",$0,"\x1b[m\x1b[m"}
+    else if(color=="purple"){print "\x1b[35m",$0,"\x1b[m\x1b[m"}
+    else if(color=="cyan"){print "\x1b[36m",$0,"\x1b[m\x1b[m"}
+    else if(color=="white"){print "\x1b[37m",$0,"\x1b[m\x1b[m"}
+    else{print "\x1b[37m",$0,"\x1b[m\x1b[m"}
+}
+flag==1 {
+    if(output!="only"){print $0}
+}
+$0 ~ end_p {
+    flag=1
+}