diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-05-17 03:16:39 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-05-17 03:16:39 -0700 |
commit | dfbf19b9a96474b8c1bacac85e43605e5691ceb2 (patch) | |
tree | 94889c4de98f2cb22ff228b2bf19aef93ed5c557 | |
parent | 6c6e85a516f668ff35a9370cafdceceb10bf93d7 (diff) | |
download | man-master.tar.gz man-master.tar.bz2 man-master.zip |
The escape-at-end-of-line fixes have the side effect
of adding some 20,000 blank lines to the HTML output
for the TXR man page.
The reason is that the logic is applied even within
macro expansions which have internal escapes.
we introduce a recursion depth variable which is
incremented for each call to scan_request.
The escnl flag is only set at recursion depth 0,
unless we are in no-fill mode. The exception for
no-fill mode is because there are a few cases where
macro-expansion produces nofill mode output, like
the .mets macro in the TXR man page.
-rw-r--r-- | man2html/man2html.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/man2html/man2html.c b/man2html/man2html.c index 6c8799d..d190fd1 100644 --- a/man2html/man2html.c +++ b/man2html/man2html.c @@ -48,6 +48,7 @@ int still_dd=0; int tabstops[20] = { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96 }; int maxtstop=12; int curpos=0; +int recdepth=0; /* request recursion depth */ static char *scan_troff(char *c, int san, char **result); static char *scan_troff_raw(char *c, int san, char **result); @@ -1659,6 +1660,8 @@ scan_request(char *c) { if (c[0] == '\n') return c+1; + recdepth++; + j = strcspn(c, " \n\t"); j += strspn(c + j, " \t"); @@ -3008,6 +3011,9 @@ scan_request(char *c) { if (fillout) { out_html(NEWLINE); curpos++; } NEWLINE[0]='\n'; } + + --recdepth; + return c; } @@ -3051,9 +3057,12 @@ do_scan_troff(char *c, int san, int htmlesc, char **result) { /* san : stop at n FLUSHIBP; h = scan_escape(h); outbuffer[obp] = 0; - if (*h == '\n' && - ((obp > 0 && !isspace(outbuffer[obp-1])) || !fillout)) - escnl = 1; + if (*h == '\n') { + if (recdepth == 0 && ((obp > 0 && !isspace(outbuffer[obp-1])))) + escnl = 1; + else if (!fillout) + escnl = 1; + } } else if (*h == '\b') { intbuff[ibp++]=*h++; if (ibp>480) { FLUSHIBP; } |