X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..939639fcf1dad1b8f3a85d641f41d11c49281f3c:/doc/makedoc.c diff --git a/doc/makedoc.c b/doc/makedoc.c index 528d372..5112809 100644 --- a/doc/makedoc.c +++ b/doc/makedoc.c @@ -76,11 +76,14 @@ enum output_formats_t #define D_DT (1 << 7) #define D_DD (1 << 8) #define D_PA (1 << 9) +#define D_IL (1 << 10) +#define D_TT (1 << 11) enum { SP_START_EM, SP_START_BF, + SP_START_TT, SP_END_FT, SP_NEWLINE, SP_NEWPAR, @@ -93,6 +96,8 @@ enum SP_DD, SP_END_DD, SP_END_DL, + SP_START_IL, + SP_END_IL, SP_END_SECT, SP_REFER }; @@ -571,6 +576,8 @@ static void man_print_strval (const char *v, FILE *out) fputs ("\\(rq", out); else if (*v == '\\') fputs ("\\\\", out); + else if (*v == '-') + fputs ("\\-", out); else fputc (*v, out); } @@ -595,17 +602,10 @@ static int sgml_fputc (int c, FILE *out) { switch (c) { + /* the bare minimum for escaping */ case '<': return fputs ("<", out); case '>': return fputs (">", out); - case '$': return fputs ("$", out); - case '_': return fputs ("_", out); - case '%': return fputs ("%", out); case '&': return fputs ("&", out); - case '\\': return fputs ("\", out); - case '"': return fputs (""", out); - case '[': return fputs ("[", out); - case ']': return fputs ("]", out); - case '~': return fputs ("˜", out); default: return fputc (c, out); } } @@ -615,7 +615,7 @@ static int sgml_fputs (const char *s, FILE *out) for (; *s; s++) if (sgml_fputc ((unsigned int) *s, out) == EOF) return EOF; - + return 0; } @@ -624,12 +624,17 @@ static int sgml_id_fputs (const char *s, FILE* out) { char id; + if (*s == '<') + s++; + for (; *s; s++) { if (*s == '_') id = '-'; else id = *s; + if (*s == '>' && !*(s+1)) + break; if (fputc ((unsigned int) id, out) == EOF) return EOF; @@ -683,8 +688,11 @@ static void print_confline (const char *varname, int type, const char *val, FILE man_print_strval (val, out); fputs ("\\(rq\n", out); } - else - fprintf (out, "Default: %s\n", val); + else { + fputs ("Default: ", out); + man_print_strval (val, out); + fputs ("\n", out); + } fputs (".fi", out); @@ -699,12 +707,21 @@ static void print_confline (const char *varname, int type, const char *val, FILE fputs ("\">\n", out); sgml_fputs (varname, out); fprintf (out, "\nType: %s", type2human (type)); + if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) { - fputs ("\nDefault: "", out); - sgml_print_strval (val, out); - fputs (""\n", out); + if (val && *val) + { + fputs ("\nDefault: ", out); + sgml_print_strval (val, out); + fputs ("", out); + } + else + { + fputs ("\nDefault: (empty)", out); + } + fputs ("\n", out); } else fprintf (out, "\nDefault: %s\n", val); @@ -733,6 +750,9 @@ static void print_confline (const char *varname, int type, const char *val, FILE ** - .dt starts a term in a definition list. ** - .dd starts a definition in a definition list. ** - .de on a line finishes a definition list. + ** - .il on a line starts an itemzied list + ** - .dd starts an item in an itemized list + ** - .ie on a line finishes an itemized list ** - .ts on a line starts a "tscreen" environment (name taken from SGML). ** - .te on a line finishes this environment. ** - .pp on a line starts a paragraph. @@ -766,7 +786,7 @@ static int flush_doc (int docstat, FILE *out) if (docstat & (D_DL)) docstat = print_it (SP_END_DL, NULL, out, docstat); - if (docstat & (D_EM | D_BF)) + if (docstat & (D_EM | D_BF | D_TT)) docstat = print_it (SP_END_FT, NULL, out, docstat); docstat = print_it (SP_END_SECT, NULL, out, docstat); @@ -794,9 +814,10 @@ static int print_it (int special, char *str, FILE *out, int docstat) { static int Continuation = 0; - case SP_END_FT: docstat &= ~(D_EM|D_BF); break; + case SP_END_FT: docstat &= ~(D_EM|D_BF|D_TT); break; case SP_START_BF: docstat |= D_BF; break; case SP_START_EM: docstat |= D_EM; break; + case SP_START_TT: docstat |= D_TT; break; case SP_NEWLINE: { if (onl) @@ -850,6 +871,8 @@ static int print_it (int special, char *str, FILE *out, int docstat) } case SP_DD: { + if (docstat & D_IL) + fputs ("- ", out); Continuation = 0; break; } @@ -859,6 +882,17 @@ static int print_it (int special, char *str, FILE *out, int docstat) docstat &= ~D_DL; break; } + case SP_START_IL: + { + docstat |= D_IL; + break; + } + case SP_END_IL: + { + Continuation = 0; + docstat &= ~D_IL; + break; + } case SP_STR: { if (Continuation) @@ -890,23 +924,30 @@ static int print_it (int special, char *str, FILE *out, int docstat) case SP_END_FT: { fputs ("\\fP", out); - docstat &= ~(D_EM|D_BF); + docstat &= ~(D_EM|D_BF|D_TT); break; } case SP_START_BF: { fputs ("\\fB", out); docstat |= D_BF; - docstat &= ~D_EM; + docstat &= ~(D_EM|D_TT); break; } case SP_START_EM: { fputs ("\\fI", out); docstat |= D_EM; - docstat &= ~D_BF; + docstat &= ~(D_BF|D_TT); break; } + case SP_START_TT: + { + fputs ("\\fC", out); + docstat |= D_TT; + docstat &= ~(D_BF|D_EM); + break; + } case SP_NEWLINE: { if (onl) @@ -959,7 +1000,10 @@ static int print_it (int special, char *str, FILE *out, int docstat) } case SP_DD: { - fputs ("\n", out); + if (docstat & D_IL) + fputs (".TP\n\\(hy ", out); + else + fputs ("\n", out); break; } case SP_END_DL: @@ -968,6 +1012,18 @@ static int print_it (int special, char *str, FILE *out, int docstat) docstat &= ~D_DL; break; } + case SP_START_IL: + { + fputs (".RS\n.PD 0\n", out); + docstat |= D_IL; + break; + } + case SP_END_IL: + { + fputs (".RE\n.PD 1", out); + docstat &= ~D_DL; + break; + } case SP_STR: { while (*str) @@ -978,6 +1034,8 @@ static int print_it (int special, char *str, FILE *out, int docstat) fputs ("\\(rq", out); else if (*str == '\\') fputs ("\\\\", out); + else if (*str == '-') + fputs ("\\-", out); else if (!strncmp (str, "``", 2)) { fputs ("\\(lq", out); @@ -1007,23 +1065,31 @@ static int print_it (int special, char *str, FILE *out, int docstat) { if (docstat & D_EM) fputs ("", out); if (docstat & D_BF) fputs ("", out); - docstat &= ~(D_EM|D_BF); + if (docstat & D_TT) fputs ("", out); + docstat &= ~(D_EM|D_BF|D_TT); break; } case SP_START_BF: { fputs ("", out); docstat |= D_BF; - docstat &= ~D_EM; + docstat &= ~(D_EM|D_TT); break; } case SP_START_EM: { fputs ("", out); docstat |= D_EM; - docstat &= ~D_BF; + docstat &= ~(D_BF|D_TT); break; } + case SP_START_TT: + { + fputs ("", out); + docstat |= D_TT; + docstat &= ~(D_BF|D_EM); + break; + } case SP_NEWLINE: { if (onl) @@ -1062,43 +1128,76 @@ static int print_it (int special, char *str, FILE *out, int docstat) } case SP_START_TAB: { + if (docstat & D_PA) + { + fputs ("\n\n", out); + docstat &= ~D_PA; + } fputs ("\n\n", out); docstat |= D_TAB | D_NL; break; } case SP_END_TAB: { - fputs ("\n", out); + fputs ("", out); docstat &= ~D_TAB; docstat |= D_NL; break; } case SP_START_DL: { - fputs ("\n\n", out); + if (docstat & D_PA) + { + fputs ("\n\n", out); + docstat &= ~D_PA; + } + fputs ("\n\n\n\n", out); docstat |= D_DL; break; } case SP_DT: { - fputs ("", out); + fputs ("", out); break; } case SP_DD: { docstat |= D_DD; - fputs ("\n", out); + if (docstat & D_DL) + fputs("", out); + else + fputs ("", out); break; } case SP_END_DD: { + if (docstat & D_DL) + fputs ("\n", out); + else + fputs ("", out); docstat &= ~D_DD; - fputs ("\n", out); break; } case SP_END_DL: { - fputs ("\n", out); + fputs ("\n", out); + docstat &= ~(D_DD|D_DL); + break; + } + case SP_START_IL: + { + if (docstat & D_PA) + { + fputs ("\n\n", out); + docstat &= ~D_PA; + } + fputs ("\n\n", out); + docstat |= D_IL; + break; + } + case SP_END_IL: + { + fputs ("\n", out); docstat &= ~(D_DD|D_DL); break; } @@ -1110,9 +1209,28 @@ static int print_it (int special, char *str, FILE *out, int docstat) case SP_STR: { if (docstat & D_TAB) - fputs (str, out); - else sgml_fputs (str, out); + else + { + while (*str) + { + for (; *str; str++) + { + if (!strncmp (str, "``", 2)) + { + fputs ("", out); + str++; + } + else if (!strncmp (str, "''", 2)) + { + fputs ("", out); + str++; + } + else + sgml_fputc (*str, out); + } + } + } break; } } @@ -1142,7 +1260,7 @@ void print_ref (FILE *out, int output_dollar, const char *ref) sgml_id_fputs (ref, out); fputs ("\">", out); if (output_dollar) - fputs ("$", out); + fputc ('$', out); sgml_fputs (ref, out); fputs ("", out); break; @@ -1183,6 +1301,10 @@ static int handle_docline (char *l, FILE *out, int docstat) return print_it (SP_START_DL, NULL, out, docstat); else if (!strncmp (l, ".de", 3)) return print_it (SP_END_DL, NULL, out, docstat); + else if (!strncmp (l, ".il", 3)) + return print_it (SP_START_IL, NULL, out, docstat); + else if (!strncmp (l, ".ie", 3)) + return print_it (SP_END_IL, NULL, out, docstat); else if (!strncmp (l, ". ", 2)) *l = ' '; @@ -1210,6 +1332,12 @@ static int handle_docline (char *l, FILE *out, int docstat) docstat = print_it (SP_START_BF, NULL, out, docstat); s += 2; } + else if (!strncmp (s, "\\fC", 3)) + { + docstat = commit_buff (buff, &d, out, docstat); + docstat = print_it (SP_START_TT, NULL, out, docstat); + s += 2; + } else if (!strncmp (s, "\\fP", 3)) { docstat = commit_buff (buff, &d, out, docstat); @@ -1229,6 +1357,11 @@ static int handle_docline (char *l, FILE *out, int docstat) } else if (!strncmp (s, ".dd", 3)) { + if ((docstat & D_IL) && (docstat & D_DD)) + { + docstat = commit_buff (buff, &d, out, docstat); + docstat = print_it (SP_END_DD, NULL, out, docstat); + } docstat = commit_buff (buff, &d, out, docstat); docstat = print_it (SP_DD, NULL, out, docstat); s += 3; @@ -1252,7 +1385,7 @@ static int handle_docline (char *l, FILE *out, int docstat) else { ref = s; - while (isalnum ((unsigned char) *s) || *s == '-' || *s == '_') + while (isalnum ((unsigned char) *s) || (*s && strchr("-_<>", *s))) ++s; docstat = commit_buff (buff, &d, out, docstat);