Make these work with one-true-awk.
Spotted by: nyan
This commit is contained in:
parent
d6c762af40
commit
01e9310be5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97269
@ -35,29 +35,29 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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++)
|
||||
|
Loading…
Reference in New Issue
Block a user