Check-in by ben on 2025-04-30 00:57:35

Use consistent spacing in numerical expressions

 INSERTED    DELETED
        4          4 src/cgi.awk
        1          1 src/details/index.dcgi.m4
        2          2 src/search/index.dcgi.m4
        1          1 src/util.awk
        3          3 src/web.awk
       11         11 TOTAL over 5 changed files

Index: src/cgi.awk
==================================================================
--- src/cgi.awk
+++ src/cgi.awk
@@ -24,11 +24,11 @@
            selector = substr(path, RSTART)
        }

        # remove trailing text from beginning of script name
        if (match(selector, ENVIRON["SCRIPT_NAME"])) {
-            selector = substr(selector, 1, RSTART-1)
+            selector = substr(selector, 1, RSTART - 1)
        }
        selector = selector input
    } else {
        input = traversal
    }
@@ -35,12 +35,12 @@

    if (length(search) == 0 && match(input, /%09.*/)) {
        # This is a hack to include a search in the URL.
        # everything before %09 is considered arguments
        # everything after %09 is considered the search
-        search = substr(input, RSTART+3, RLENGTH-3)
-        args = substr(input, 0, RSTART-1)
+        search = substr(input, RSTART + 3, RLENGTH - 3)
+        args = substr(input, 0, RSTART - 1)
    } else {
        args = input
    }

    # query is everything after ? in the gopher selector
@@ -51,11 +51,11 @@
    path = selector
    if (substr(path, 1, length(cgipath)) == cgipath) {
        path = substr(path, length(cgipath) + 1)
    }
    if (match(path, /%09/)) {
-        path = substr(path, 1, RSTART-1)
+        path = substr(path, 1, RSTART - 1)
    }

    split(path, parts, "/")
    topdir = parts[2]


Index: src/details/index.dcgi.m4
==================================================================
--- src/details/index.dcgi.m4
+++ src/details/index.dcgi.m4
@@ -177,11 +177,11 @@
    api_request(url, "GET", iaout)
    while ((getline <iaout) > 0) {
        if (/item-upload-info__uploader-name/ &&
            match($0, /\/details\/[^"]*"/))
        {
-            uploader_account = substr($0, RSTART+9, RLENGTH-10)
+            uploader_account = substr($0, RSTART + 9, RLENGTH - 10)
        }
    }
    close(iaout)

    if (cols > 0) {

Index: src/search/index.dcgi.m4
==================================================================
--- src/search/index.dcgi.m4
+++ src/search/index.dcgi.m4
@@ -43,11 +43,11 @@
        }
    }

    # special case for when the search term is an archive.org details URL
    if (match(search, /^https:\/\/(www\.)?archive\.org\/details\//)) {
-        id = substr(search, RLENGTH+1)
+        id = substr(search, RLENGTH + 1)
        search = "identifier:" id
    }

    # remove quotes from search string, since it gets quoted later
    gsub(/"/, "", search)
@@ -87,11 +87,11 @@
        split(order, parts, " ")
        url = url sprintf("&sort%%5B0%%5D=%s %s", order_names[parts[1]],
            parts[2])
    }
    for (i = 1; i <= fields; i++) {
-        url = url sprintf("&fl%%5B%d%%5D=%s", i-1, field[i])
+        url = url sprintf("&fl%%5B%d%%5D=%s", i - 1, field[i])
    }
    api_request(url, "GET", iaout)

    cmd = sprintf("%s <%s >%s 2>&1", cmd_json2tsv, iaout, jsout)
    system(cmd)

Index: src/util.awk
==================================================================
--- src/util.awk
+++ src/util.awk
@@ -87,11 +87,11 @@
                A[1] = t
                return
            }
        }
        for (p = i; (c = 2*p) <= n; p = c) {
-            if ((c < n) && (A[c] < A[c+1]))
+            if ((c < n) && (A[c] < A[c + 1]))
                c++
            if (t < A[c])
                A[p] = A[c]
            else break
        }

Index: src/web.awk
==================================================================
--- src/web.awk
+++ src/web.awk
@@ -148,11 +148,11 @@
# to full URLs

function print_ref_full(str, base, proto, root,     link, prefix, relative) {
    if (match(str, /^ [0-9]+\. /)) {
        prefix = substr(str, 0, RLENGTH)
-        link = substr(str, RLENGTH+1)
+        link = substr(str, RLENGTH + 1)
        # convert relative links to full URLs
        if (link !~ /^[a-z]+:/) {
            # convert relative link to full URL
            relative = link
            if (relative ~ /^\/\//) {
@@ -177,18 +177,18 @@
function print_ref_pharos(output, str,     id, label, link, prefix,
    relative, token)
{
    if (match(str, /^ [0-9]+\. /)) {
        prefix = substr(str, 0, RLENGTH)
-        link = substr(str, RLENGTH+1)
+        link = substr(str, RLENGTH + 1)

        id = ""
        if (match(link, /https?:\/\/(www\.)?archive\.org\/details\//)) {
            token = substr(link, RSTART+RLENGTH)
            id = substr(token, 1, length(token) - 7)
            if (match(id, /[?\/ ]/)) {
-                id = substr(id, 1, RSTART-1)
+                id = substr(id, 1, RSTART - 1)
            }
        }
        if (length(id) > 0) {
            label = prefix id
            printf "[1|%s|%s/details/%s|%s|%s]\n", label, cgipath,