diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-09-15 14:29:06 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-09-15 14:29:06 -0700 |
commit | 5fbc5eae2872b0258ee247a2b7f5a115d9e8e13b (patch) | |
tree | 45d38b4960099cbba2b0dbc34a421a925e4f783b | |
parent | ab9826be651451405d88e79bbdf5872046684ee5 (diff) | |
download | man-5fbc5eae2872b0258ee247a2b7f5a115d9e8e13b.tar.gz man-5fbc5eae2872b0258ee247a2b7f5a115d9e8e13b.tar.bz2 man-5fbc5eae2872b0258ee247a2b7f5a115d9e8e13b.zip |
Make \n[IDENT] work.
This needs str_to_code to be expanded a little bit.
-rw-r--r-- | man2html/man2html.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/man2html/man2html.c b/man2html/man2html.c index 115d314..7e78446 100644 --- a/man2html/man2html.c +++ b/man2html/man2html.c @@ -111,21 +111,27 @@ expand_int(int nr) return num; } -static int str_to_code(char *str) +static int str_to_code(char *str, char *delim) { - int code, count; + int code, count; - for (count = 0, code = 0; count < 4 && *str && !isspace(*str); count++) { - code *= 256; - code += *str++; - } + if (!delim) + delim = "\t\n "; - if (count == 1) { - code *= 256; - code += ' '; - } + for (count = 0, code = 0; + count < 4 && *str && !strchr(delim, *str); + count++) + { + code *= 256; + code += *str++; + } - return code; + if (count == 1) { + code *= 256; + code += ' '; + } + + return code; } static char outbuffer[1024]; @@ -673,7 +679,9 @@ scan_escape(char *c) { i=V(c[0],c[1]); c=c+1; } else if (*c=='[') { - abort(); + c++; + i=str_to_code(c, "]\n"); + c += strcspn(c, "]\n"); } else { i=V(c[0],' '); } @@ -689,7 +697,8 @@ scan_escape(char *c) { default: intresult=0; break; } } - h=expand_int(intresult); + if (output_possible) + h=expand_int(intresult); break; case 'w': c++; @@ -1322,7 +1331,8 @@ char *scan_expression(char *c, int *result) { case '&': value = (value && value2); break; case ':': value = (value || value2); break; default: fprintf(stderr, - "man2html: Unknown operator %c.\n", oper); + "man2html: Unknown operator char '%c' (0x%02d), context \"%s\".\n", + oper, oper, c-1); } oper=0; } @@ -1622,7 +1632,7 @@ scan_request(char *c) { else c = scan_escape(c+1); } else { - i=str_to_code(c); + i=str_to_code(c, 0); switch (i) { case V('a','b'): h=c+j; @@ -1639,7 +1649,7 @@ scan_request(char *c) { { STRDEF *de; c=c+j; - i=str_to_code(c); + i=str_to_code(c, 0); if (*c == '\n') { c++;break; } while (*c && *c!='\n') c++; c++; @@ -1673,7 +1683,7 @@ scan_request(char *c) { int oldcurpos=curpos; c=c+j; while (*c == ' ') c++; - i=str_to_code(c); + i=str_to_code(c, 0); j=0; while (c[j] && c[j]!='\n') j++; if (j<3) { c=c+j; break; } @@ -1804,7 +1814,7 @@ scan_request(char *c) { out_html(change_to_font(*c)); c++; } else { - int nr = str_to_code(c); + int nr = str_to_code(c, 0); out_html(change_to_font(nr)); c += strcspn(c, " \t\n"); } @@ -2313,7 +2323,7 @@ scan_request(char *c) { int olen=0; c=c+j; sl=fill_words(c, wordlist, SIZE(wordlist), &words, '\n'); - i=str_to_code(c); + i=str_to_code(c, 0); if (words == 1) { wordlist[1]=".."; j = 2; |