Remove automatic patch generators

These tools have served their purposes and need not be kept outside of
the repository history any longer.  This patch as a diff also collects
the contents of the various tools in one convenient place.

* patch-1.gawk: Remove.
* patch-3.gawk: Likewise.
* patch-6.gawk: Likewise.
This commit is contained in:
Jacob Bachmeyer 2021-05-26 20:13:22 -05:00 committed by Dmitry V. Levin
parent 598afeec95
commit d921e50274
3 changed files with 0 additions and 221 deletions

View File

@ -1,101 +0,0 @@
#!/usr/bin/gawk -f
# -*- Awk -*-
# Automate (most of) the refactoring of config.guess to use an intermediate variable
# for uname-based results.
# GPLv3+
BEGIN {
if (ARGC < 2) ARGV[ARGC++] = "config.guess"
Indent = ""
In_main_case = 0
In_here_doc = 0
Here_doc_end = ""
If_depth = 0
If_rewritten = 0
}
# Skip here documents
In_here_doc && $0 ~ /^[[:space:]]*EOF/ { In_here_doc = 0 }
In_here_doc { print; next }
/<</ { In_here_doc = 1 }
# Conveniently, all here documents in config.guess end with "EOF".
# Track indentation
/^[[:space:]]*/ {
Indent_prev = Indent
match($0, /^[[:space:]]*/)
Indent = substr($0, RSTART, RLENGTH)
}
/^case \$UNAME_MACHINE:\$UNAME_SYSTEM/ { In_main_case = 1 }
function rewrite_echo_line( i) {
$2 = "GUESS="$2
for (i=2; i<=NF; i++) {
$(i-1)=$i
if ($i == "#") {
$(i-2) = $(i-2)" "
}
}
NF--
$0 = Indent $0
}
# Track "if" depth within main case block
In_main_case && /^[[:space:]]+if / { If_depth++ }
In_main_case && /^[[:space:]]+fi/ { If_depth-- }
In_main_case && If_depth > 0 && /^[[:space:]]+echo/ {
If_rewritten = 1
rewrite_echo_line()
}
In_main_case && /^[[:space:]]+exit ;;$/ && If_rewritten {
If_rewritten = 0
print Indent";;"
next
}
In_main_case && /^[[:space:]]+echo/ {
getline next_line
if (next_line !~ /^[[:space:]]+exit ;;/) {
# not the output-and-exit we seek here...
print
print next_line
next
}
if (/-cray-/ && $3 == "|") {
# several Cray Unicos entries apply sed to the entire output in
# order to edit the UNAME_RELEASE field; fix these up
sub(/"\$UNAME_RELEASE"/, "\"$(echo &", $2)
$NF = $NF")\""
}
rewrite_echo_line()
if (next_line ~ /^[[:space:]]+exit ;;.+/)
sub(/^[[:space:]]+exit ;;/, ";; ", next_line)
else
sub(/^[[:space:]]+exit ;;/, ";;", next_line)
print $0
print Indent next_line
next
}
In_main_case && /^esac/ {
In_main_case = 0
print # "esac"
# Copy the rest of the input file
while (getline) print
nextfile
}
{ print }

View File

@ -1,99 +0,0 @@
#!/usr/bin/gawk -f
# -*- Awk -*-
# Automate removing unneeded quotes in variable assignments and factoring
# out some command substitutions in config.guess.
# GPLv3+
BEGIN {
if (ARGC < 2) ARGV[ARGC++] = "config.guess"
Indent = ""
In_here_doc = 0
Factor = "BOGUS!REL"
}
# Skip here documents
In_here_doc && $0 ~ /^[[:space:]]*EOF/ { In_here_doc = 0 }
In_here_doc { print; next }
/<</ { In_here_doc = 1 }
# Conveniently, all here documents in config.guess end with "EOF".
# Track indentation
/^[[:space:]]*/ {
Indent_prev = Indent
match($0, /^[[:space:]]*/)
Indent = substr($0, RSTART, RLENGTH)
}
/^[[:space:]]+GUESS=/ {
$0 = gensub(/GUESS="([^"[[:space:]]+)"$/, "GUESS=\\1", 1)
$0 = gensub(/"(\$[[:alnum:]{}_]+)"([^[:alnum:]_]|$)/, "\\1\\2", "g")
$0 = gensub(/"\$([[:alnum:]_]+)"([[:alnum:]_]|$)/, "${\\1}\\2", "g")
if (/[[:space:]]#/) {
$0 = gensub(/[[:space:]]#/, repeat(" ", gsub(/\$/, "&"))"&", 1)
}
}
/\$\(echo \$[[:alnum:]_]+/ {
# requote variables inside command substitutions
$0 = gensub(/(\$\(echo )\$([[:alnum:]_]+)/, "\\1\"$\\2\"", "g")
}
# Factor out $(echo "$UNAME_RELEASE" | sed ...) into variables...
# ... first, track what name to use:
/alpha:OSF1:/ { Factor = "OSF" }
/:SunOS:/ { Factor = "SUN" }
/:IRIX\*:/ { Factor = "IRIX" }
/CRAY[[:alnum:]*:-]+\)/ { Factor = "CRAY" }
/86:skyos:/ { Factor = "SKYOS" }
/:FreeBSD:/ { Factor = "FREEBSD" }
/:DragonFly:/ { Factor = "DRAGONFLY" }
# The GNU system is a very special case and is handled manually.
/:GNU(\/\*)?:/ { Factor = "GNU" }
# ... second, split the GUESS= lines
/GUESS=/ && /\$\(echo[^|]+|.*sed/ && Factor != "GNU" {
base = index($0, "\"$(")
item = substr($0, base)
tail = ""
# special handling to clean up some FreeBSD cases
if (Factor == "FREEBSD" && match($0, /-gnueabi/)) {
# transfer the "-gnueabi" marker
tail = substr($0, RSTART)
$0 = substr($0, 1, RSTART-1); item = substr($0, base)
# quote variable in inner substitution
sub(/echo \${UNAME_RELEASE}/, "echo \"$UNAME_RELEASE\"", item)
# remove unneeded braces
if (sub(/\${UNAME_PROCESSOR}/, "$UNAME_PROCESSOR"))
base -= 2
}
# standardize spacing around pipe
sub(/"\|sed/, "\" | sed", item)
# remove quotes from command substitution
sub(/^"/, "", item); sub(/"$/, "", item)
print Indent Factor"_REL="item
$0 = substr($0, 1, base-1)"$"Factor"_REL"tail
}
# Copy the rest of the file after the edits are done
/^[[:space:]]+echo "\$GUESS"/ {
print
while (getline) print
nextfile
}
{ print }
function repeat(text, count, ret) {
for (ret = ""; count > 0; count--) ret = ret text
return ret
}

View File

@ -1,21 +0,0 @@
#!/usr/bin/gawk -f
# -*- Awk -*-
# Automate reversion of $( ) substitutions to classic `` form.
# GPLv3+
BEGIN {
if (ARGC < 2) ARGV[ARGC++] = "config.guess"
}
# fix a special case of forgotten quotes
/\$\(\$dummy\)/ { sub(/\$\(\$dummy\)/, "$(\"$dummy\")") }
/\$\( \(/ { $0 = gensub(/\$\( (\([^()]+\)[^()]*)\)/, "`\\1`", "g") }
/\$\(/ { $0 = gensub(/\$\(([^()]+)\)/, "`\\1`", "g") }
/\$\( \(.*'/ { $0 = gensub(/\$\( (\([^()]+'[^']+'[^()]*\)[^()]*)\)/, "`\\1`", "g") }
/\$\(.*'/ { $0 = gensub(/\$\(([^()]+'[^']+'[^()]*)\)/, "`\\1`", "g") }
{ print }