/usr/bin/noroff is in noweb 2.11b-11+b1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #!/bin/sh
#
# noroff -- run troff using tags file trick
ROFF="groff"
AWK=awk
macrodir=/usr/share/groff/tmac
opts=
if [ $# -eq 0 ]; then
echo "Usage: noroff [groff-arguments] files" 1>&2
exit 1
fi
while [ $# -gt 0 ]
do
case $1 in
-*) opts="$opts $1"
shift
;;
*) # end of options
break;
;;
esac
done
if [ "$opts" = "" ]
then
# no options, default to -mm
# groff already defaults to -Tps
opts="-mm"
fi
# otherwise assume user passed in all the arguments they want
base="`basename $1 | sed '/\./s/\.[^.]*$//'`"
tagsfile="$base.nwt"
(echo ".so $macrodir/noweb.tmac"
if [ -r "$tagsfile" ]; then
tagstemp=$(tempfile -p tags) || { echo "$0: Cannot create temporary file" >&2; exit 1; }
cp $tagsfile $tagstemp
$AWK '{
if (sub(/^###TAG### / , "")) tags[$1] = $2
else if (sub(/^###BEGINCHUNKS###/, "")) printf ".de CLIST\n.CLISTBEGIN\n"
else if (sub(/^###CHUNKBEGIN### /, "")) { name = convquote($0)
chunkuse = chunkdefn = "" }
else if (sub(/^###CHUNKUSE### / , "")) chunkuse = chunkuse " " tag($0)
else if (sub(/^###CHUNKDEFN### / , "")) chunkdefn = chunkdefn " " tag($0)
else if (sub(/^###CHUNKEND###/ , ""))
printf ".CITEM \"%s\" \"%s\" \"%s\"\n", name, chunkdefn, chunkuse
else if (sub(/^###ENDCHUNKS###/ , "")) printf ".CLISTEND\n..\n"
else if (sub(/^###BEGININDEX###/ , "")) printf ".de ILIST\n.ILISTBEGIN\n"
else if (sub(/^###ENTRYBEGIN### /, "")) { name = convquote($0)
entryuse = entrydefn = "" }
else if (sub(/^###ENTRYUSE### / , "")) entryuse = entryuse " " tag($0)
else if (sub(/^###ENTRYDEFN### / , "")) entrydefn = entrydefn " " tag($0)
else if (sub(/^###ENTRYEND###/ , "")) {
for (i = 1; i <= split(entrydefn, entryarray); i++)
sub(entryarray[i], "\\*[BEGINDEFN]&\\*[ENDDEFN]", entryuse)
printf ".IITEM \"%s\" \"%s\"\n", name, entryuse }
else if (sub(/^###ENDINDEX###/ , "")) printf ".ILISTEND\n..\n"
}
function convquote(s, out, front, mid, tail) {
gsub(/\[\[/, "\\*[BEGINCONVQUOTE]", s)
# gsub(/\]\]/, "\\*[ENDCONVQUOTE]", s)
out = ""
mid = "\\*[ENDCONVQUOTE]"
while (match(s, /\]\]+/) != 0) {
# RLENGTH is length of match, want to remove last two chars
# RSTART is where sequence of ]s begins
tail = substr(s, RSTART + RLENGTH)
if (RLENGTH == 2) # easy
front = substr(s, 1, RSTART - 1)
else
front = substr(s, 1, RSTART - 1 + RLENGTH - 2)
out = out front mid
s = tail
}
out = out s
return out }
# my test program for the revised function - ADR
# BEGIN { str = "abc[[foo[i]]]]]]]]junk"
# print str
# print convquote(str)
# str2 = "nothing here"
# print str2
# print convquote(str2)
# str3 = "abc[[foo[i]]]]]]]]junk[[bar[i]]more stuff[[baz]]"
# print str3
# print convquote(str3)
# }
function tag(s) { if (s in tags) return tags[s]; else return "???" }' $tagstemp
rm -f $tagstemp
fi
cat "$@") |
($ROFF $opts 2>$tagsfile)
sed '/^###[A-Z][A-Z]*###/d' $tagsfile >&2
|