summaryrefslogtreecommitdiffstats
path: root/release
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2002-05-25 10:37:00 +0000
committerru <ru@FreeBSD.org>2002-05-25 10:37:00 +0000
commit0adccddf2f8f210a182c3e4bdd83e7a415b9fc6a (patch)
tree3341f99c8bc235b7c23af6c516ba2b52c96393b8 /release
parentcb22bdeaa9589d733e99639a0db639ab99e0cad6 (diff)
downloadFreeBSD-src-0adccddf2f8f210a182c3e4bdd83e7a415b9fc6a.zip
FreeBSD-src-0adccddf2f8f210a182c3e4bdd83e7a415b9fc6a.tar.gz
Make these work with one-true-awk.
Spotted by: nyan
Diffstat (limited to 'release')
-rwxr-xr-xrelease/scripts/driver-copy2.awk32
-rwxr-xr-xrelease/scripts/driver-remove.awk47
2 files changed, 46 insertions, 33 deletions
diff --git a/release/scripts/driver-copy2.awk b/release/scripts/driver-copy2.awk
index f5789f4..0935878 100755
--- a/release/scripts/driver-copy2.awk
+++ b/release/scripts/driver-copy2.awk
@@ -36,28 +36,28 @@ function usage()
function err(eval, fmt, what)
{
- printf "driver-copy2.awk: " fmt ": %s\n", what, ERRNO > "/dev/stderr";
- exit eval;
-}
-
-function errx(eval, fmt, what)
-{
printf "driver-copy2.awk: " fmt "\n", what > "/dev/stderr";
exit eval;
}
-function readconfig(config)
+function readconfig()
{
- while ((getline < config) > 0) {
+ while ((r = (getline < config)) > 0) {
sub("#.*$", "");
- if (split(gensub(/^(\w+)[ \t]+(\w+)[ \t]+([0-9]+)[ \t]+(\w+)[ \t]+\"(.*)\"[ \t]*$/,
- "\\1#\\2#\\3#\\4#\\5", "g"), arg, "#") == 5) {
+ if (sub(/^[[:alnum:]_]+[ \t]+[[:alnum:]_]+[ \t]+[0-9]+[ \t]+[[:alnum:]_]+[ \t]+\".*\"[ \t]*$/, "&")) {
+ sub(/[ \t]+/, "#");
+ sub(/[ \t]+/, "#");
+ sub(/[ \t]+/, "#");
+ sub(/[ \t]+/, "#");
+ sub(/\"/, "");
+ sub(/\"/, "");
+ split($0, arg, "#");
flp[arg[2]] = arg[3];
dsc[arg[2]] = arg[5];
}
}
- if (ERRNO)
- err(1, "reading %s", config);
+ if (r == -1)
+ err(1, "error reading %s", config);
close(config);
}
@@ -69,12 +69,12 @@ BEGIN {
srcdir = ARGV[2];
dstdir = ARGV[3];
- readconfig(config);
+ readconfig();
if (system("test -d " srcdir) != 0)
- errx(1, "cannot find %s directory", srcdir);
+ err(1, "cannot find %s directory", srcdir);
if (system("test -d " dstdir) != 0)
- errx(1, "cannot find %s directory", dstdir);
+ err(1, "cannot find %s directory", dstdir);
for (f in flp) {
if (flp[f] == 1) {
@@ -90,7 +90,7 @@ BEGIN {
close(dscfile);
} else if (flp[f] == 3) {
# third driver floppy (not yet implemented)
- errx(1, "%s: 3rd driver floppy support is not implemented", f);
+ err(1, "%s: 3rd driver floppy support is not implemented", f);
}
}
}
diff --git a/release/scripts/driver-remove.awk b/release/scripts/driver-remove.awk
index 0c15bde..fd44a1a 100755
--- a/release/scripts/driver-remove.awk
+++ b/release/scripts/driver-remove.awk
@@ -36,24 +36,30 @@ function usage()
function err(eval, fmt, what)
{
- printf "driver-remove.awk: " fmt ": %s\n", what, ERRNO > "/dev/stderr";
+ printf "driver-remove.awk: " fmt "\n", what > "/dev/stderr";
exit eval;
}
-function readconfig(config)
+function readconfig()
{
- while ((getline < config) > 0) {
+ while ((r = (getline < config)) > 0) {
sub("#.*$", "");
- if (split(gensub(/^(\w+)[ \t]+(\w+)[ \t]+([0-9]+)[ \t]+(\w+)[ \t]+\"(.*)\"[ \t]*$/,
- "\\1#\\2#\\3#\\4#\\5", "g"), arg, "#") == 5) {
+ if (sub(/^[[:alnum:]_]+[ \t]+[[:alnum:]_]+[ \t]+[0-9]+[ \t]+[[:alnum:]_]+[ \t]+\".*\"[ \t]*$/, "&")) {
+ sub(/[ \t]+/, "#");
+ sub(/[ \t]+/, "#");
+ sub(/[ \t]+/, "#");
+ sub(/[ \t]+/, "#");
+ sub(/\"/, "");
+ sub(/\"/, "");
+ split($0, arg, "#");
if (arg[4] == "options")
options[arg[1]] = 1;
else
drivers[arg[1]] = 1;
}
}
- if (ERRNO)
- err(1, "reading %s", config);
+ if (r == -1)
+ err(1, "error reading %s", config);
close(config);
}
@@ -64,20 +70,27 @@ BEGIN {
config = ARGV[1];
bootmfs = ARGV[2];
- readconfig(config);
+ readconfig();
lines = 0;
- while ((getline < bootmfs) > 0) {
- if (/^device[ \t]+\w+/ &&
- gensub(/^device[ \t]+(\w+).*$/, "\\1", "g") in drivers)
- continue;
- if (/^options[ \t]+\w+/ &&
- gensub(/^options[ \t]+(\w+).*$/, "\\1", "g") in options)
- continue;
+ while ((r = (getline < bootmfs)) > 0) {
+ if (/^device[ \t]+[[:alnum:]_]+/) {
+ dev = $0;
+ sub(/^device[ \t]+/, "", dev);
+ sub(/[ \t]+.*$/, "", dev);
+ if (dev in drivers)
+ continue;
+ } else if (/^options[ \t]+[[:alnum:]_]+/) {
+ opt = $0;
+ sub(/^options[ \t]+/, "", opt);
+ sub(/[ \t]+.*$/, "", opt);
+ if (opt in options)
+ continue;
+ }
line[lines++] = $0;
}
- if (ERRNO)
- err(1, "reading %s", bootmfs);
+ if (r == -1)
+ err(1, "error reading %s", bootmfs);
close(bootmfs);
printf "" > bootmfs;
for (i = 0; i < lines; i++)
OpenPOWER on IntegriCloud