diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp index 60d46e8..9bac7da 100644 --- a/src/devices/grotty/tty.cpp +++ b/src/devices/grotty/tty.cpp @@ -30,6 +30,10 @@ extern "C" const char *Version_string; #define putstring(s) fputs(s, stdout) +#ifndef PTR2SIZE +# define PTR2SIZE(X) ((size_t)(X)) +#endif + #ifndef SHRT_MIN #define SHRT_MIN (-32768) #endif @@ -216,6 +220,7 @@ class tty_printer : public printer { void line(int, int, int, int, color *, color *); void draw_line(int *, int, const environment *); void draw_polygon(int *, int, const environment *); + void _special_mdocmx(char const *, environment const *); public: tty_printer(); ~tty_printer(); @@ -434,42 +439,119 @@ void tty_printer::add_char(output_character c, int w, void tty_printer::special(char *arg, const environment *env, char type) { if (type == 'u') { - add_char(*arg - '0', 0, env->hpos, env->vpos, env->col, env->fill, - CU_MODE); - return; + add_char(*arg - '0', 0, env->hpos, env->vpos, env->col, env->fill, CU_MODE); + goto jleave; } if (type != 'p') - return; - char *p; - for (p = arg; *p == ' ' || *p == '\n'; p++) + goto jleave; + + char *p, *tag_cmd; + + for (p = arg; *p == ' ' || *p == '\n'; ++p) ; - char *tag = p; - for (; *p != '\0' && *p != ':' && *p != ' ' && *p != '\n'; p++) + tag_cmd = p; + for (; *p != '\0' && *p != ':' && *p != ' ' && *p != '\n'; ++p) ; - if (*p == '\0' || strncmp(tag, "tty", p - tag) != 0) { + if (*p == '\0' || strncmp(tag_cmd, "tty", PTR2SIZE(p - tag_cmd)) != 0) { error("X command without `tty:' tag ignored"); - return; + goto jleave; } - p++; - for (; *p == ' ' || *p == '\n'; p++) + + for (++p; *p == ' ' || *p == '\n'; ++p) ; - char *command = p; - for (; *p != '\0' && *p != ' ' && *p != '\n'; p++) + tag_cmd = p; + for (; *p != '\0' && *p != ' ' && *p != '\n'; ++p) ; - if (*command == '\0') { + if (*tag_cmd == '\0') { error("empty X command ignored"); - return; + goto jleave; } - if (strncmp(command, "sgr", p - command) == 0) { - for (; *p == ' ' || *p == '\n'; p++) + + if (!strncmp(tag_cmd, "sgr", PTR2SIZE(p - tag_cmd))) { + for (; *p == ' ' || *p == '\n'; ++p) ; int n; - if (*p != '\0' && sscanf(p, "%d", &n) == 1 && n == 0) - old_drawing_scheme = 1; - else - old_drawing_scheme = 0; + old_drawing_scheme = (*p != '\0' && sscanf(p, "%d", &n) == 1 && n == 0); update_options(); + } else if (!strncmp(tag_cmd, "mdocmx", PTR2SIZE(p - tag_cmd))) + _special_mdocmx(p, env); + +jleave: + ; +} + +void +tty_printer::_special_mdocmx(char const *ap, environment const *env) +{ + // Handle the special \X'' injections of the mdocmx(7) reference extension + // for the mdoc semantic markup language. + // See mdocmx(7) for the used protocol +#undef __C +#define __C(C) add_char(C, 0, env->hpos, env->vpos, env->col, env->fill, 0) + + char const *cmd, *cmd_top, *cp; + + for (; *ap == ' ' || *ap == '\n'; ++ap) + ; + cmd = ap; + for (; *ap != '\0' && *ap != ' ' && *ap != '\n'; ++ap) + ; + cmd_top = ap; + if (cmd == cmd_top) { + error("empty mdocmx X command ignored"); + goto jleave; } + + // Any mdocmx(7) command places an anchor + for (; *ap == ' ' || *ap == '\n'; ++ap) + ; + cp = ap; + for (; *ap != '\0' && *ap != ' ' && *ap != '\n'; ++ap) + ; + if (cp == ap) { + error("empty mdocmx X anchor ignored"); + goto jleave; + } + + __C('{'); __C('\b'); __C('{'); __C('\b'); + for (; cp < ap; ++cp) { + __C(*cp); __C('\b'); __C(*cp); __C('\b'); + } + __C('}'); __C('\b'); __C('}'); __C('\b'); + + // The external reference .Xr injects some more + if (!strncmp(cmd, "xr", PTR2SIZE(cmd_top - cmd))) { + __C('{'); __C('\b'); __C('{'); __C('\b'); + __C('!'); __C('\b'); __C('!'); __C('\b'); + + // Manual section + for (; *ap == ' ' || *ap == '\n'; ++ap) + ; + cp = ap; + for (; *ap != '\0' && *ap != ' ' && *ap != '\n'; ++ap) + ; + for (; cp < ap; ++cp) { + __C(*cp); __C('\b'); __C(*cp); __C('\b'); + } + + __C(';'); __C('\b'); __C(';'); __C('\b'); + + // Manual page + for (; *ap == ' ' || *ap == '\n'; ++ap) + ; + cp = ap; + for (; *ap != '\0' && *ap != ' ' && *ap != '\n'; ++ap) + ; + for (; cp < ap; ++cp) { + __C(*cp); __C('\b'); __C(*cp); __C('\b'); + } + + __C('}'); __C('\b'); __C('}'); __C('\b'); + } + +jleave: + ; +#undef __C } void tty_printer::change_color(const environment * const env) diff --git a/tmac/doc-common b/tmac/doc-common index e63fdb4..934ef3c 100644 --- a/tmac/doc-common +++ b/tmac/doc-common @@ -814,6 +814,397 @@ .. . . +.\" NS Mx user macro +.\" NS mdocmx(7) reference extension +.\" NS +.\" NS modifies: +.\" NS doc-mx-enabled - have seen .Mx -enable +.\" NS doc-mx-preprocessed - mdocmx(1) preprocessed the document +.\" NS doc-mx-error - error mode - do not act for real any more +.\" NS doc-mx-gogogo - we support the output device: act! +.\" NS doc-mx-tty - is a TTY output devie +.\" NS +.\" NS doc-mx-refno - the running count of generated references +.\" NS +.\" NS doc-mx-CMD-no - count of anchors for CMD +.\" NS +.\" NS local variables: +.\" NS doc-mx-XXX-XXX +. +.\"ds doc-mx-enabled +.\"ds doc-mx-preprocessed +.\"ds doc-mx-error +.\"ds doc-mx-gogogo +.\"ds doc-mx-tty +. +.nr doc-mx-refno 1 +. +.nr doc-mx-stack-no 0 +. +.de Mx +. if d doc-mx-error .return +. +. \" Mx is an extension and may not be used by noone else +. if \n[doc-arg-limit] \{\ +. if !'Mx'\*[doc-macro-name]' \{\ +. tm1 mdocmx(7): .Mx not callable by other macros (#\n[.c]) +. doc-reset-args +. ds doc-mx-error +. return +. \}\} +. +. if '-enable'\$1' \{\ +. ds doc-mx-error +. ie d doc-mx-enabled \ +. tm1 mdocmx(7): .Mx -enable may be used once only! (#\n[.c]) +. el .ie (\n[.$] == 1) \{\ +. \" For single-pass troff mdocmx(7) requires a preprocessor. +. \" For multi-pass troff we could now switch some mode.. ? +. tm1 mdocmx(7): document not preprocessed by mdocmx(1) (#\n[.c])! +. \"ie (1) .tm1 mdocmx(7): missing preprocessing by mdocmx(1) (#\n[.c])! +. \"el .rm doc-mx-error +. \} +. el .ie (\n[.$] > 2) .tm1 mdocmx(7): synposis: .Mx -enable (#\n[.c]) +. el .ie '-preprocessed'\$2' \{\ +. ds doc-mx-preprocessed +. rm doc-mx-error +. \} +. el .tm1 mdocmx(7): synposis: .Mx -enable (#\n[.c]) +. if d doc-mx-error .return +. +. ds doc-mx-enabled +. ds doc-mx-gogogo +. ie 'utf8'\*[.T]' .ds doc-mx-tty +. el .ie 'latin1'\*[.T]' .ds doc-mx-tty +. el .ie 'ascii'\*[.T]' .ds doc-mx-tty +. el .rm doc-mx-gogogo +. \" TODO For HTML and PDF devices include their respective support +. \" TODO packages and inject anchors and references as appropriate +. return +. \} +. +. if !d doc-mx-enabled \{\ +. tm1 mdocmx(7) not enabled via -enable in the document prologue! (#\n[.c]) +. ds doc-mx-error +. return +. \} +. if !d doc-mx-gogogo .return +. +. \" TODO -toc is expanded by preprocessor (but we *can* with preproc info!!) +. if '-toc'\$1' .return +. +. \" II. Single pass troff info generated by mdocmx(1) +. if '-anchor-spass'\$1' \{\ +. ie 'Ar'\$2' .ds doc-mx#s1 Ar +. el .ie 'Cm'\$2' .ds doc-mx#s1 Cm +. el .ie 'Dv'\$2' .ds doc-mx#s1 Dv +. el .ie 'Er'\$2' .ds doc-mx#s1 Er +. el .ie 'Ev'\$2' .ds doc-mx#s1 Ev +. el .ie 'Fl'\$2' .ds doc-mx#s1 Fl +. el .ie 'Fn'\$2' .ds doc-mx#s1 Fn +. el .ie 'Ic'\$2' .ds doc-mx#s1 Ic +. el .ie 'Pa'\$2' .ds doc-mx#s1 Pa +. el .ie 'Va'\$2' .ds doc-mx#s1 Va +. +. el .ie 'Sh'\$2' .ds doc-mx#s1 Sh +. el .ie 'Ss'\$2' .ds doc-mx#s1 Ss +. el \{\ +. tm1 mdocmx(7): .Mx -anchor-spass: invalid argument: \$2 (#\n[.c]) +. ds doc-mx-error +. return +. \} +. +. nr doc-mx-\*[doc-mx#s1]-no +1 +. ds doc-mx-\*[doc-mx#s1]-\n[doc-mx-\*[doc-mx#s1]-no]-arg \$3 +. ds doc-mx-\*[doc-mx#s1]-\n[doc-mx-\*[doc-mx#s1]-no]-ref \n[doc-mx-refno] +. nr doc-mx-refno +1 +. \" Fake that we have the anchor +. nr doc-mx-\*[doc-mx#s1]-anchor 0 +. rm doc-mx#s1 +. return +. \} +. +. \" III. .Mx stack handling +. +. \" III.1. No argument: any supported macro, any content +. if (\n[.$] == 0) \{\ +. nr doc-mx-stack-no +1 +. return +. \} +. +. \" III.2. MACRO: exactly MACRO, any content +. nr doc-mx-stack-no +1 +. ie 'Ar'\$1' .ds doc-mx#s1 Ar +. el .ie 'Cm'\$1' .ds doc-mx#s1 Cm +. el .ie 'Dv'\$1' .ds doc-mx#s1 Dv +. el .ie 'Er'\$1' .ds doc-mx#s1 Er +. el .ie 'Ev'\$1' .ds doc-mx#s1 Ev +. el .ie 'Fl'\$1' .ds doc-mx#s1 Fl +. el .ie 'Fn'\$1' .ds doc-mx#s1 Fn +. el .ie 'Fo'\$1' .ds doc-mx#s1 Fn +. el .ie 'Ic'\$1' .ds doc-mx#s1 Ic +. el .ie 'Pa'\$1' .ds doc-mx#s1 Pa +. el .ie 'Va'\$1' .ds doc-mx#s1 Va +. el \{\ +. tm1 mdocmx(7): .Mx: cannot enqueue an anchor for macro "\$1" (#\n[.c]) +. ds doc-mx-error +. return +. \} +. ds doc-mx-stack-mac-\n[doc-mx-stack-no] \*[doc-mx#s1] +. rm doc-mx#s1 +. +. \" III.3. MACRO/KEY: exactly MACRO with exactly content KEY +. shift 1 +. if (\n[.$] > 0) .ds doc-mx-stack-arg-\n[doc-mx-stack-no] \$* +.. +. +.\" NS Hook call-ins for mdoc(7) macros which support mdocmx(7). +.\" NS Because of the (grr) recursive descendent behaviour it is +.\" NS complicated to get (1) at all macro arguments and (2) arguments +.\" NS in plain text form. +.\" NS In general any supported macro calls doc-mx-mac-enter, which +.\" NS can be given further arguments in which case any call to +.\" NS doc-mx-mac-add-arg is effectively a no-op (this is the usual +.\" NS way to add arguments for those macros where this is the only +.\" NS possible time and place to get access to plain text content), +.\" NS then doc-mx-mac-add-arg is called repeatedly for each macro +.\" NS argument (usually done automatically from doc-print-recursive), +.\" NS and the macro level is left via doc-mx-mac-leave (this is also +.\" NS called from within doc-print-recursive). +.\" NS +.\" NS modifies: +.\" NS doc-mx-ard argument recursion depth counter +.\" NS doc-mx-arnNO macro name on recursion depth NO +.\" NS doc-mx-araNO argument string on recursion depth NO +.\" NS doc-mx-arxNO bypass - don't process this level! +. +.nr doc-mx-ard 0 +. +.de doc-mx-mac-enter +. if d doc-mx-error .return +. if !d doc-mx-gogogo .return +. +. doc-mx-mac-leave-check +. +. ie 'Ar'\$1' .ds doc-mx#s1 +. el .ie 'Cm'\$1' .ds doc-mx#s1 +. el .ie 'Dv'\$1' .ds doc-mx#s1 +. el .ie 'Er'\$1' .ds doc-mx#s1 +. el .ie 'Ev'\$1' .ds doc-mx#s1 +. el .ie 'Fl'\$1' .ds doc-mx#s1 +. el .ie 'Fn'\$1' .ds doc-mx#s1 +. el .ie 'Fo'\$1' .ds doc-mx#s1 +. el .ie 'Ic'\$1' .ds doc-mx#s1 +. el .ie 'Pa'\$1' .ds doc-mx#s1 +. el .ie 'Va'\$1' .ds doc-mx#s1 +. \" mdoc(7) macros supported automatically +. el .ie 'Sh'\$1' .ds doc-mx#s1 +. el .ie 'Ss'\$1' .ds doc-mx#s1 +. el .ie 'Sx'\$1' .ds doc-mx#s1 +. el .ie 'Xr'\$1' .ds doc-mx#s1 +. \" Bypass this level! +. el \{\ +. ds doc-mx-arx\n[doc-mx-ard] +. return +. \} +. rm doc-mx#s1 +. nr doc-mx-ard +1 +. ds doc-mx-arn\n[doc-mx-ard] \$1 +. +. \" Unfortunately mdoc(7) uses a recursive descendent parser (ssiigghh!) +. \" and modifies arguments before starting recursion, so in order to be +. \" able to provide references and anchors via string comparison some +. \" ugly hacks are necessary: doc-mx-mac-add-arg will effectively +. \" ignore its arguments because we _now_ create the result! +. shift +. if (\n[.$] == 0) .return +. while (\n[.$] > 0) \{\ +. doc-mx-mac-add-arg "\$1" +. shift +. \} +. ds doc-mx-arx\n[doc-mx-ard] +.. +. +.de doc-mx-mac-add-arg +. if d doc-mx-error .return +. if !d doc-mx-gogogo .return +. +. \" Level ignored? +. if d doc-mx-arx\n[doc-mx-ard] .return +. +. ie d doc-mx-ara\n[doc-mx-ard] \ +. ds doc-mx-ara\n[doc-mx-ard] \*[doc-mx-ara\n[doc-mx-ard]] \$* +. el .ds doc-mx-ara\n[doc-mx-ard] \$* +.. +. +.\" Deal with doc-print-recursive sequencing +.de doc-mx-mac-sequence +. if d doc-mx-error .return +. if !d doc-mx-gogogo .return +. +. ds doc-mx-mac#noclose +. doc-mx-mac-leave +. rm doc-mx-mac#noclose +.. +. +.de doc-mx-mac-leave-check +. if d doc-mx-error .return +. if !d doc-mx-gogogo .return +. +. if d doc-mx-mac-leave-last \{\ +. rm doc-mx-arx\n[doc-mx-ard] +. rm doc-mx-arn\n[doc-mx-ard] +. nr doc-mx-ard -1 +. rm doc-mx-mac-leave-last +. \} +.. +. +.de doc-mx-mac-leave +. if d doc-mx-error .return +. if !d doc-mx-gogogo .return +. +. \" After doc-mx-mac-sequence we get called again immediately +. if d doc-mx-mac-leave-last \{\ +. doc-mx-mac-leave-check +. return +. \} +. ds doc-mx-mac-leave-last +. +. \" Level ignored? +. if d doc-mx-arx\n[doc-mx-ard] \{\ +. if !d doc-mx-mac#noclose .rm doc-mx-arx\n[doc-mx-ard] +. \" May be one of the pre-prepared argument hacks +. if !d doc-mx-arn\n[doc-mx-ard] \{\ +. if !d doc-mx-mac#noclose .nr doc-mx-ard -1 +. return +. \} +. \} +. +. \" .Xr and .Sx are special: they can't create anchors, only references +. ie 'Xr'\*[doc-mx-arn\n[doc-mx-ard]]' \{\ +. \" Argument resplit necessary +. doc-mx-mac-leave-xr \*[doc-mx-ara\n[doc-mx-ard]] +. \} +. el .ie 'Sx'\*[doc-mx-arn\n[doc-mx-ard]]' \{\ +. ds mx#mac-leave-sx +. doc-mx-mac-key-find Sh "\*[doc-mx-ara\n[doc-mx-ard]]" +. if d mx#mac-leave-sx \ +. doc-mx-mac-key-find Ss "\*[doc-mx-ara\n[doc-mx-ard]]" +. rm mx#mac-leave-sx +. \} +. el \{\ +. doc-mx-mac-key-find \*[doc-mx-arn\n[doc-mx-ard]] \ + "\*[doc-mx-ara\n[doc-mx-ard]]" +. \} +. +. rm doc-mx-ara\n[doc-mx-ard] +. if !d doc-mx-mac#noclose \{\ +. rm doc-mx-arn\n[doc-mx-ard] +. nr doc-mx-ard -1 +. \} +.. +. +.\" .Xr creates external references which requires special handling. +.\" This one would be nice, but the problem with this approach is that +.\" $PAGER will _scroll_ to the anchor, so for .Xr we want unique anchors +.de doc-mx-mac-leave-xr-nonono +. \" Do we have seen this .Xr before?.. +. nr doc-mx#n1 \n[doc-mx-Xr-no] +. while (\n[doc-mx#n1] > 0) \{\ +. if '\$1'\*[doc-mx-Xr-\n[doc-mx#n1]-section]' \{\ +. if '\$2'\*[doc-mx-Xr-\n[doc-mx#n1]-name]' \{\ +. nr doc-mx#n1 \*[doc-mx-Xr-\n[doc-mx#n1]-ref] +. break +. \} +. \} +. nr doc-mx#n1 -1 +. \} +. +. \" ..otherwise create a new slot with a new reference number +. if (\n[doc-mx#n1] == 0) \{\ +. nr doc-mx-Xr-no +1 +. ds doc-mx-Xr-\n[doc-mx-Xr-no]-section \$1 +. ds doc-mx-Xr-\n[doc-mx-Xr-no]-name \$2 +. ds doc-mx-Xr-\n[doc-mx-Xr-no]-ref \n[doc-mx-refno] +. nr doc-mx#n1 \n[doc-mx-refno] +. nr doc-mx-refno +1 +. \} +. +\%\X'tty: mdocmx xr \n[doc-mx#n1] \$1 \$2'[\n[doc-mx#n1]]\c +. rm doc-mx#n1 +.. +.\" So use the running version with unique anchors instead +.de doc-mx-mac-leave-xr +. nr doc-mx#n1 \n[doc-mx-refno] +. nr doc-mx-refno +1 +\%\X'tty: mdocmx xr \n[doc-mx#n1] \$1 \$2'[\n[doc-mx#n1]]\c +. rm doc-mx#n1 +.. +. +.\" Try to find an occurrence of key-content $1 in macro stack $1 +.de doc-mx-mac-key-find +. \" If .Mx stack is not empty, check if we can pop it: define mx#anchor +. ie 'Sx'\$1' . +. el .ie 'Xr'\$1' . +. el .ie 'Sh'\$1' .ds doc-mx#showref +. el .ie 'Ss'\$1' .ds doc-mx#showref +. el .if (\n[doc-mx-stack-no] > 0) \{\ +. ds mx#anchor +. ie !d doc-mx-stack-mac-\n[doc-mx-stack-no] . +. el .ie !'\$1'\*[doc-mx-stack-mac-\n[doc-mx-stack-no]]' .rm mx#anchor +. el .ie !d doc-mx-stack-arg-\n[doc-mx-stack-no] . +. el .if !'\$2'\*[doc-mx-stack-arg-\n[doc-mx-stack-no]]' .rm mx#anchor +. +. if d mx#anchor \{\ +. rm mx#anchor +. rm doc-mx-stack-arg-\n[doc-mx-stack-no] +. rm doc-mx-stack-mac-\n[doc-mx-stack-no] +. nr doc-mx-stack-no -1 +. +. if !d doc-mx-preprocessed \{\ +. nr doc-mx-\$1-no +1 +. ds doc-mx-\$1-\n[doc-mx-\$1-no]-arg \$2 +. ds doc-mx-\$1-\n[doc-mx-\$1-no]-ref \n[doc-mx-refno] +. nr doc-mx-refno +1 +\%\X'tty: mdocmx \$1 \*[doc-mx-\$1-\n[doc-mx-\$1-no]-ref]'\c +. ds doc-mx-\$1-\n[doc-mx-\$1-no]-anchor +. return +. \} +. \" Remove the faked anchor to enforce it's real creation +. rm doc-mx-\$1-\n[doc-mx-\$1-no]-anchor +. \} +. \} +. +. nr doc-mx#n1 \n[doc-mx-\$1-no] +. while (\n[doc-mx#n1] > 0) \{\ +. if '\$2'\*[doc-mx-\$1-\n[doc-mx#n1]-arg]' \{\ +. ds doc-mx#s1 \*[doc-mx-\$1-\n[doc-mx#n1]-ref] +. \" Special call hook (for doc-mx-mac-leave, .Sx command)? +. ie d mx#mac-leave-sx \{\ +\%[\*[doc-mx#s1]]\c +. \} +. el .ie d doc-mx-\$1-\n[doc-mx-\$1-no]-anchor \{\ +\%[\*[doc-mx#s1]]\c +. \} +. el .ie d doc-mx#showref \{\ +\%\X'tty: mdocmx \$1 \*[doc-mx#s1]'[\*[doc-mx#s1]]\c +. \} +. el \{\ +. ds doc-mx-\$1-\n[doc-mx-\$1-no]-anchor +\%\X'tty: mdocmx \$1 \*[doc-mx#s1]'\c +.\"\%\X'tty: mdocmx \$1 \*[doc-mx#s1]'[\*[doc-mx#s1]]\c +. \} +. rm doc-mx#s1 +. rm mx#mac-leave-sx +. break +. \} +. nr doc-mx#n1 -1 +. \} +. rm doc-mx#n1 +. rm doc-mx#showref +.. +. +. .\" NS doc-hyphen-flags global register .\" NS the parameter for the `.hy' request .\" NS @@ -1041,6 +1432,7 @@ .\" NS doc-reg-Sh .\" NS doc-reg-Sh1 .\" NS doc-section-XXX +.\" NS doc-mx-Sh .\" NS .\" NS width register `Sh' set in doc-common . @@ -1062,7 +1454,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Sh-font]\c -. doc-print-recursive +. doc-print-recursive Sh . \} . el \{\ . tm Usage: .Sh section_name ... (#\n[.c]) @@ -1080,6 +1472,7 @@ . . ds doc-macro-name Sh . doc-parse-args \$@ +. ds doc-dpr-preloader "\$* . . if t \ . ad @@ -1147,7 +1540,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Sh-font]\c -. doc-print-recursive +. doc-print-recursive Sh . . if t \ . ss \n[doc-reg-Sh] \n[doc-reg-Sh1] @@ -1166,6 +1559,7 @@ .\" NS local variable: .\" NS doc-reg-Ss .\" NS doc-reg-Ss1 +.\" NS doc-mx-Ss .\" NS .\" NS width register `Ss' set above . @@ -1179,7 +1573,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Sh-font]\c -. doc-print-recursive +. doc-print-recursive Ss . \} . el \{\ . tm Usage: .Ss subsection_name ... (#\n[.c]) @@ -1197,6 +1591,7 @@ . . ds doc-macro-name Ss . doc-parse-args \$@ +. ds doc-dpr-preloader "\$* . . sp . if !\n[cR] \ @@ -1211,7 +1606,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Sh-font]\c -. doc-print-recursive +. doc-print-recursive Ss . . ss \n[doc-reg-Ss] \n[doc-reg-Ss1] . diff --git a/tmac/doc-syms b/tmac/doc-syms index 084dd82..f11d20f 100644 --- a/tmac/doc-syms +++ b/tmac/doc-syms @@ -72,7 +72,8 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. ds doc-dpr-preloader UNIX +. doc-print-recursive Ux .. . . @@ -158,7 +159,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive Bx .. . . @@ -260,7 +261,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive At .. . . @@ -324,7 +325,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive Dx .. . . @@ -388,7 +389,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive Fx .. . . @@ -453,7 +454,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive Nx .. . . @@ -505,7 +506,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive Ox .. . . @@ -557,7 +558,7 @@ . if \n[doc-num-args] \ . doc-parse-space-vector . -. doc-print-recursive +. doc-print-recursive Bsx .. . . @@ -726,7 +727,7 @@ . \" replacing argument with result . ds doc-arg\n[doc-arg-ptr] "\*[doc-str-St1] . -. doc-print-recursive +. doc-print-recursive St . \} . el \{\ . doc-St-usage @@ -856,6 +857,7 @@ . el \{\ . tmc "mdoc warning: .Lb: no description for library . tm1 " `\*[doc-arg\n[doc-arg-ptr]]' available (#\n[.c]) +. ds doc-dpr-preloader \*[doc-arg\n[doc-arg-ptr]] . ds doc-str-Lb1 library \*[Lq]\*[doc-arg\n[doc-arg-ptr]]\*[Rq] . \} . @@ -864,7 +866,7 @@ . . if \n[doc-in-library-section] \ . br -. doc-print-recursive +. doc-print-recursive Lb . if \n[doc-in-library-section] \ . br . \} diff --git a/tmac/doc.tmac b/tmac/doc.tmac index 80c6b88..7243892 100644 --- a/tmac/doc.tmac +++ b/tmac/doc.tmac @@ -473,27 +473,46 @@ .\" NS doc-str-dpr . .de doc-print-recursive +. if (\n[.$] > 0) \{\ +. if d doc-dpr-mxopen .doc-mx-mac-leave +. ie d doc-dpr-preloader \{\ +. doc-mx-mac-enter \$1 \*[doc-dpr-preloader] +. rm doc-dpr-preloader +. \} +. el .doc-mx-mac-enter "\$1" +. ds doc-dpr-mxopen +. \} +. . nr doc-reg-dpr1 \n[doc-type\n[doc-arg-ptr]] . ds doc-str-dpr "\*[doc-arg\n[doc-arg-ptr]] . . ie (\n[doc-reg-dpr1] == 1) \{\ +. if d doc-dpr-mxopen \{\ +. rm doc-dpr-mxopen +. doc-mx-mac-leave +. \} . nop \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]\c . \*[doc-str-dpr] . \} . el \{\ . nr doc-reg-dpr \n[doc-arg-ptr] +. nr doc-arg-ptr +1 . . \" the `\%' prevents hyphenation on a dash (`-') -. ie (\n[doc-reg-dpr1] == 2) \ +. ie (\n[doc-reg-dpr1] == 2) \{\ +. doc-mx-mac-add-arg \*[doc-str-dpr] . nop \%\*[doc-str-dpr]\&\c +. \} . el \{\ +. doc-mx-mac-sequence . \" punctuation character . nop \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]\c . nop \)\*[doc-str-dpr]\f[]\s[0]\c . \} . -. nr doc-arg-ptr +1 . ie (\n[doc-arg-limit] < \n[doc-arg-ptr]) \{\ +. rm doc-dpr-mxopen +. doc-mx-mac-leave . \" last argument . nop \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]\c . doc-print-and-reset @@ -562,7 +581,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-\$0-font]\c -. doc-print-recursive +. doc-print-recursive "\$0" .\" \} . \} . el \{\ @@ -624,7 +643,7 @@ . nr doc-arg-limit \n[doc-arg-ptr] . doc-parse-space-vector . \} -. doc-print-recursive +. doc-print-recursive Ar . \} .. . @@ -691,17 +710,17 @@ . in +\n[doc-indent-synopsis]u . ti -\n[doc-indent-synopsis]u . nop \*[doc-Nm-font]\c -. doc-print-recursive +. doc-print-recursive Cd . if !\n[doc-indent-synopsis-active] \ . in -\n[doc-indent-synopsis]u . \} . el \{\ . nop \*[doc-Nm-font]\c -. doc-print-recursive +. doc-print-recursive Cd . \}\} . el \{\ . nop \*[doc-Nm-font]\c -. doc-print-recursive +. doc-print-recursive Cd . \}\} . el \{\ . tm Usage: .Cd configuration_file_declaration ... (#\n[.c]) @@ -857,6 +876,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . +. ds doc-dpr-preloader \*[doc-arg\n[doc-arg-ptr]] . ie \n[doc-in-synopsis-section] \{\ . ie "\*[doc-macro-name]"In" \{\ . doc-do-func-decl @@ -866,19 +886,19 @@ . br . nr doc-arg-ptr +1 . ie (\n[doc-arg-limit] >= \n[doc-arg-ptr]) \ -. doc-print-recursive +. doc-print-recursive In . el \ . doc-reset-args . \} . el \{\ . ds doc-arg\n[doc-arg-ptr] "<\*[doc-Pa-font]\*[doc-arg\n[doc-arg-ptr]] . as doc-arg\n[doc-arg-ptr] \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]> -. doc-print-recursive +. doc-print-recursive In . \}\} . el \{\ . ds doc-arg\n[doc-arg-ptr] "<\*[doc-Pa-font]\*[doc-arg\n[doc-arg-ptr]] . as doc-arg\n[doc-arg-ptr] \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]> -. doc-print-recursive +. doc-print-recursive In . \}\} . el \{\ . tm Usage: .In include_file ... (#\n[.c]) @@ -980,6 +1000,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . +. ds doc-dpr-preloader "\*[doc-command-name]" . ie !(\n[doc-type\n[doc-arg-ptr]] == 2) \{\ . ie "\*[doc-command-name]"" \ . tm Usage: .Nm name ... (#\n[.c]) @@ -1015,7 +1036,7 @@ . . nop \*[doc-Nm-font]\c . \} -. doc-print-recursive +. doc-print-recursive Nm . \} .. . @@ -1062,7 +1083,7 @@ . nr doc-arg-limit \n[doc-arg-ptr] . doc-parse-space-vector . \} -. doc-print-recursive +. doc-print-recursive Pa . \} . el \{\ . nop \*[doc-Pa-font]~\f[]\s[0]\c @@ -1120,7 +1141,7 @@ . nop \)\*[doc-Tn-font-size]\c . ie !\n[doc-is-reference] \{\ . nop \)\*[doc-Tn-font-shape]\c -. doc-print-recursive +. doc-print-recursive Tn . \} . el \ . doc-do-references @@ -2070,7 +2091,7 @@ . if \n[doc-arg-limit] \{\ . nr doc-arg-ptr +1 . ie (\n[doc-arg-limit] >= \n[doc-arg-ptr]) \ -. doc-print-recursive +. doc-print-recursive Ns . el \ . doc-reset-args . \} @@ -2089,7 +2110,7 @@ . nop \)'\)\c . nr doc-arg-ptr +1 . ie (\n[doc-arg-limit] >= \n[doc-arg-ptr]) \ -. doc-print-recursive +. doc-print-recursive Ap . el \ . doc-reset-args . \} @@ -2268,7 +2289,7 @@ . ie (\n[doc-arg-limit] > \n[doc-arg-ptr]) \{\ . \" skip `Sm' argument . nr doc-arg-ptr +1 -. doc-print-recursive +. doc-print-recursive Sm . \} . el \ . doc-reset-args @@ -3773,7 +3794,7 @@ . \*[doc-arg1] . el \{\ . nr doc-arg-ptr 1 -. doc-print-recursive +. doc-print-recursive It . \}\}\} . el \{\ . tm1 "mdoc warning: .It macros in lists of type `\*[doc-str-It]' @@ -4269,18 +4290,21 @@ . ie (\n[doc-type\n[doc-arg-ptr]] == 2) \{\ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] -. ds doc-arg\n[doc-arg-ptr] \*[doc-Xr-font]\*[doc-arg\n[doc-arg-ptr]]\f[]\s[0] . . if (\n[doc-arg-limit] > \n[doc-arg-ptr]) \{\ . nr doc-reg-Xr (\n[doc-arg-ptr] + 1) . \" modify second argument if it is a string and . \" remove space in between . if (\n[doc-type\n[doc-reg-Xr]] == 2) \{\ +. ds doc-dpr-preloader \*[doc-arg\n[doc-reg-Xr]] \ + \*[doc-arg\n[doc-arg-ptr]] . ds doc-arg\n[doc-reg-Xr] \*[lp]\*[doc-arg\n[doc-reg-Xr]]\*[rp] . ds doc-space\n[doc-arg-ptr] . \} . \} -. doc-print-recursive +. +. ds doc-arg\n[doc-arg-ptr] \*[doc-Xr-font]\*[doc-arg\n[doc-arg-ptr]]\f[]\s[0] +. doc-print-recursive Xr . \} . el \ . doc-Xr-usage @@ -4458,7 +4482,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Li-font]\c -. doc-print-recursive +. doc-print-recursive Dl . \} . el \ . tm Usage: .Dl argument ... (#\n[.c]) @@ -4490,7 +4514,7 @@ . ds doc-macro-name D1 . doc-parse-args \$@ . nr doc-arg-ptr 1 -. doc-print-recursive +. doc-print-recursive D1 . \} . el \ . tm Usage: .D1 argument ... (#\n[.c]) @@ -4556,7 +4580,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Ft-font]\c -. doc-print-recursive +. doc-print-recursive Vt . . if \n[doc-in-synopsis-section] \{\ . ie \n[doc-have-old-func] \ @@ -4624,7 +4648,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Ft-font]\c -. doc-print-recursive +. doc-print-recursive Ft .. . . @@ -4698,7 +4722,7 @@ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Fa-font]\c -. doc-print-recursive +. doc-print-recursive Fa . . if \n[doc-in-synopsis-section] \ . if \n[doc-have-func] \ @@ -4855,6 +4879,8 @@ . return . \} . +. ds doc-dpr-preloader \*[doc-arg\n[doc-arg-ptr]] +. . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] . nop \*[doc-Fn-font]\*[doc-arg\n[doc-arg-ptr]]\c @@ -4877,11 +4903,14 @@ . nr doc-arg-ptr -1 . nop \)\*[doc-space\n[doc-arg-ptr]]\c . nr doc-arg-ptr +1 -. -. doc-print-recursive +. doc-print-recursive Fn . \} -. el \ +. el \{\ +. doc-mx-mac-enter Fn \*[doc-dpr-preloader] +. rm doc-dpr-preloader +. doc-mx-mac-leave . doc-print-and-reset +. \} . . if \n[doc-in-synopsis-section] \ . if !\n[doc-indent-synopsis-active] \ @@ -5019,6 +5048,9 @@ . nr doc-arg-ptr +1 . doc-print-prefixes . if (\n[doc-arg-limit] >= \n[doc-arg-ptr]) \{\ +. doc-mx-mac-enter Fo "\*[doc-arg\n[doc-arg-ptr]]" +. doc-mx-mac-leave +. . nr doc-func-arg-count 1 . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] @@ -5085,7 +5117,7 @@ . ie (\n[doc-arg-limit] >= \n[doc-arg-ptr]) \{\ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] -. doc-print-recursive +. doc-print-recursive Fc . \} . el \ . doc-print-and-reset @@ -5540,7 +5572,7 @@ . \} . el \{\ . nop \*[doc-Em-font]\c -. doc-print-recursive +. doc-print-recursive %B . \} .. . @@ -6112,7 +6144,7 @@ . \} . el \{\ . nop \*[doc-Em-font]\c -. doc-print-recursive +. doc-print-recursive %T . \} .. . @@ -6338,7 +6370,7 @@ . ie (\n[doc-arg-limit] >= \n[doc-arg-ptr]) \{\ . nr doc-curr-font \n[.f] . nr doc-curr-size \n[.ps] -. doc-print-recursive +. doc-print-recursive An . \} . el \{\ . tm Usage: .An author_name ... (#\n[.c])