diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-09-18 08:57:25 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-09-18 08:57:25 -0700 |
commit | b7895d8ec2e29e7f4e5b1cd4519fb56397523b8a (patch) | |
tree | 26e03ea12022cd53236a45a86377e327552ade0d | |
parent | 3cdb65b4e15141e675cd7003f94f24b829422927 (diff) | |
download | man-b7895d8ec2e29e7f4e5b1cd4519fb56397523b8a.tar.gz man-b7895d8ec2e29e7f4e5b1cd4519fb56397523b8a.tar.bz2 man-b7895d8ec2e29e7f4e5b1cd4519fb56397523b8a.zip |
Fix broken argument delimiting in macro calls.
The argument line of a macro must be expanded first,
and then broken into words according to the original
quotes. For instance .mac \\$* passes multiple arguments,
not a single argument containing spaces. And
.mac "\\$*" must pass a single argument; moreover,
if \\$* expands into stuff that contains double quotes,
those should probably not be recognized.
-rw-r--r-- | man2html/man2html.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/man2html/man2html.c b/man2html/man2html.c index 1a9309e..642847c 100644 --- a/man2html/man2html.c +++ b/man2html/man2html.c @@ -2854,19 +2854,19 @@ scan_request(char *c) { int oldnargs; int deflen; int onff; - sl=fill_words(c+j, wordlist, SIZE(wordlist), &words, '\n'); - c=sl+1; - *sl=0; + char *h=NULL; + + /* expand first, then break into words. */ + trans_char(c+j,'"','\b'); + if (mandoc_command) + c=scan_troff_mandoc(c+j,1,&h); + else + c=scan_troff(c+j,1,&h); + trans_char(h,'"','\a'); + trans_char(h,'\b','"'); + fill_words(h, wordlist, SIZE(wordlist), &words, '\n'); for (i=1; i<words; i++) wordlist[i][-1]=0; - for (i=0; i<words; i++) { - char *h=NULL; - if (mandoc_command) - scan_troff_mandoc(wordlist[i],1,&h); - else - scan_troff(wordlist[i],1,&h); - wordlist[i]=h; - } for (i=words; i<SIZE(wordlist); i++) wordlist[i]=NULL; deflen = strlen(owndef->st); @@ -2884,8 +2884,7 @@ scan_request(char *c) { newline_for_fun=onff; argument=oldargument; nargs=oldnargs; - for (i=0; i<words; i++) if (wordlist[i]) free(wordlist[i]); - *sl='\n'; + free(h); } else if (mandoc_command && ((isupper(*c) && islower(c[1])) || (islower(*c) && isupper(c[1])))) { @@ -2954,6 +2953,9 @@ scan_troff(char *c, int san, char **result) { /* san : stop at newline */ h++; FLUSHIBP; h = scan_escape(h); + } else if (*h == '\b') { + intbuff[ibp++]=*h++; + if (ibp>480) { FLUSHIBP; } } else if (*h == controlsym && h[-1] == '\n') { h++; FLUSHIBP; |