diff options
author | sheldonh <sheldonh@FreeBSD.org> | 2000-08-15 10:02:07 +0000 |
---|---|---|
committer | sheldonh <sheldonh@FreeBSD.org> | 2000-08-15 10:02:07 +0000 |
commit | 4e5281d00b8fa7447d70020d36660157e7e43626 (patch) | |
tree | 88d7fea3d791af620456e3cd42ff2bf1c4229af2 /contrib/awk/awklib/eg/prog/extract.awk | |
parent | 946d89ae2629e07c7d4735eac8d1f5ac2263ce58 (diff) | |
download | FreeBSD-src-4e5281d00b8fa7447d70020d36660157e7e43626.zip FreeBSD-src-4e5281d00b8fa7447d70020d36660157e7e43626.tar.gz |
Update vendor branch to gawk-3.0.6.
Diffstat (limited to 'contrib/awk/awklib/eg/prog/extract.awk')
-rw-r--r-- | contrib/awk/awklib/eg/prog/extract.awk | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/contrib/awk/awklib/eg/prog/extract.awk b/contrib/awk/awklib/eg/prog/extract.awk new file mode 100644 index 0000000..65f3f2d --- /dev/null +++ b/contrib/awk/awklib/eg/prog/extract.awk @@ -0,0 +1,71 @@ +# extract.awk --- extract files and run programs +# from texinfo files +# Arnold Robbins, arnold@gnu.org, Public Domain, May 1993 + +BEGIN { IGNORECASE = 1 } + +/^@c(omment)?[ \t]+system/ \ +{ + if (NF < 3) { + e = (FILENAME ":" FNR) + e = (e ": badly formed `system' line") + print e > "/dev/stderr" + next + } + $1 = "" + $2 = "" + stat = system($0) + if (stat != 0) { + e = (FILENAME ":" FNR) + e = (e ": warning: system returned " stat) + print e > "/dev/stderr" + } +} +/^@c(omment)?[ \t]+file/ \ +{ + if (NF != 3) { + e = (FILENAME ":" FNR ": badly formed `file' line") + print e > "/dev/stderr" + next + } + if ($3 != curfile) { + if (curfile != "") + close(curfile) + curfile = $3 + } + + for (;;) { + if ((getline line) <= 0) + unexpected_eof() + if (line ~ /^@c(omment)?[ \t]+endfile/) + break + else if (line ~ /^@(end[ \t]+)?group/) + continue + if (index(line, "@") == 0) { + print line > curfile + continue + } + n = split(line, a, "@") + # if a[1] == "", means leading @, + # don't add one back in. + for (i = 2; i <= n; i++) { + if (a[i] == "") { # was an @@ + a[i] = "@" + if (a[i+1] == "") + i++ + } + } + print join(a, 1, n, SUBSEP) > curfile + } +} +function unexpected_eof() +{ + printf("%s:%d: unexpected EOF or error\n", \ + FILENAME, FNR) > "/dev/stderr" + exit 1 +} + +END { + if (curfile) + close(curfile) +} |