diff options
author | rsc <devnull@localhost> | 2006-02-21 18:37:05 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-02-21 18:37:05 +0000 |
commit | c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4 (patch) | |
tree | 400f263e56681842ba1e6e1fdd8be453856474ef /src/cmd/htmlroff/t18.c | |
parent | 49a1496cbbb871bc623cfd0925566628e246c9ba (diff) | |
download | plan9port-c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4.tar.gz plan9port-c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4.tar.bz2 plan9port-c42a1d3d6168df56f966ea1f3ba3ef39ebbff4e4.zip |
add
Diffstat (limited to 'src/cmd/htmlroff/t18.c')
-rw-r--r-- | src/cmd/htmlroff/t18.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/cmd/htmlroff/t18.c b/src/cmd/htmlroff/t18.c new file mode 100644 index 00000000..f5c74a1f --- /dev/null +++ b/src/cmd/htmlroff/t18.c @@ -0,0 +1,67 @@ +#include "a.h" + +/* + * 18. Insertions from the standard input + */ +void +r_rd(int argc, Rune **argv) +{ + char *s; + Rune *p; + Fmt fmt; + static int didstdin; + static Biobuf bstdin; + + /* + * print prompt, then read until double newline, + * then run the text just read as though it were + * a macro body, using the remaining arguments. + */ + if(isatty(0)){ + if(argc > 1) + fprint(2, "%S", argv[1]); + else + fprint(2, "%c", 7/*BEL*/); + } + + if(!didstdin){ + Binit(&bstdin, 0, OREAD); + didstdin = 1; + } + runefmtstrinit(&fmt); + while((s = Brdstr(&bstdin, '\n', 0)) != nil){ + if(s[0] == '\n'){ + free(s); + break; + } + fmtprint(&fmt, "%s", s); + free(s); + } + p = runefmtstrflush(&fmt); + if(p == nil) + warn("out of memory in %Crd", dot); + ds(L(".rd"), p); + argc--; + argv++; + argv[0] = L(".rd"); + runmacro('.', argc, argv); + ds(L(".rd"), nil); +} + +/* terminate exactly as if input had ended */ +void +r_ex(int argc, Rune **argv) +{ + USED(argc); + USED(argv); + + while(popinput()) + ; +} + +void +t18init(void) +{ + addreq(L("rd"), r_rd, -1); + addreq(L("ex"), r_ex, 0); +} |