X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=makedoc.c;h=3652332ca917ab6d7b72f8fe6f86f235dce16f16;hb=616031722dea23d357d8b50d41ae7b40cfdd7d3c;hp=71864be87269720128d7a043bcd8d7d64767a012;hpb=452ffdd4bbcd8f2dd9e4811c115824b556814ebb;p=apps%2Fmadmutt.git diff --git a/makedoc.c b/makedoc.c index 71864be..3652332 100644 --- a/makedoc.c +++ b/makedoc.c @@ -82,12 +82,15 @@ enum output_formats_t { #define D_INIT (1 << 6) #define D_DL (1 << 7) #define D_DT (1 << 8) +#define D_DD (1 << 9) +#define D_PA (1 << 10) enum { SP_START_EM, SP_START_BF, SP_START_TT, SP_END_FT, + SP_END_PAR, SP_NEWLINE, SP_NEWPAR, SP_STR, @@ -96,7 +99,9 @@ enum { SP_START_DL, SP_DT, SP_DD, + SP_END_DD, SP_END_DL, + SP_END_SECT, SP_REFER }; @@ -116,6 +121,7 @@ static void handle_confline (char *); static void makedoc (FILE *, FILE *); static int sgml_fputc (int); static int sgml_fputs (const char *); +static int sgml_id_fputs (const char *); static void add_var (const char *); static int add_s (const char *); static int add_c (int); @@ -613,7 +619,7 @@ static int sgml_fputc (int c) case '\\': return add_s ("\"); case '"': - return add_s ("&dquot;"); + return add_s ("""); case '[': return add_s ("["); case ']': @@ -634,6 +640,21 @@ static int sgml_fputs (const char *s) return 0; } +/* reduce CDATA to ID */ +static int sgml_id_fputs (const char *s) { + char id; + + for (; *s; s++) { + if (*s == '_') + id = '-'; + else + id = *s; + if (sgml_fputc ((unsigned int) id) == EOF) + return EOF; + } + return 0; +} + static void print_confline (const char *varname, int type, const char *val) { if (type == DT_SYN) @@ -712,28 +733,28 @@ static void print_confline (const char *varname, int type, const char *val) /* SGML based manual */ case F_SGML: { - add_s ("\n"); + add_s ("\n\n"); sgml_fputs (varname); - add_s ("<label id=\""); - add_s (varname); - add_s ("\">"); - add_s ("\n<p>\nType: <tt>"); + add_s ("\nType: "); add_s (type2human (type)); - add_s ("\n\n"); + add_s ("\n\n"); if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) { - add_s ("

\nDefault: &dquot;"); + add_s ("\nDefault: ""); sgml_print_strval (val); - add_s ("&dquot;"); + add_s ("""); } else { - add_s ("

\n"); + add_s ("\n"); add_s (type == DT_SYS ? "Value: " : "Default: "); - add_s (""); + add_s (""); add_s (val); - add_s (""); + add_s (""); } + add_s ("\n"); break; } /* make gcc happy */ @@ -784,6 +805,9 @@ static int flush_doc (int docstat) exit (1); } + if (docstat & (D_PA)) + docstat = print_it (SP_END_PAR, NULL, docstat); + if (docstat & (D_TAB)) docstat = print_it (SP_END_TAB, NULL, docstat); @@ -793,6 +817,8 @@ static int flush_doc (int docstat) if (docstat & (D_EM | D_BF | D_TT)) docstat = print_it (SP_END_FT, NULL, docstat); + docstat = print_it (SP_END_SECT, NULL, docstat); + docstat = print_it (SP_NEWLINE, NULL, 0); fd_recurse--; @@ -1029,31 +1055,31 @@ static int print_it (int special, char *str, int docstat) case SP_END_FT: { if (docstat & D_EM) - add_s (""); + add_s (""); if (docstat & D_BF) - add_s (""); + add_s (""); if (docstat & D_TT) - add_s (""); + add_s (""); docstat &= ~(D_EM | D_BF | D_TT); break; } case SP_START_BF: { - add_s (""); + add_s (""); docstat |= D_BF; docstat &= ~(D_EM | D_TT); break; } case SP_START_EM: { - add_s (""); + add_s (""); docstat |= D_EM; docstat &= ~(D_BF | D_TT); break; } case SP_START_TT: { - add_s (""); + add_s (""); docstat |= D_TT; docstat &= ~(D_EM | D_BF); break; @@ -1077,44 +1103,65 @@ static int print_it (int special, char *str, int docstat) if (!(onl & D_NL)) add_s ("\n"); - add_s ("\n

\n"); + if (docstat & D_PA) + add_s ("\n"); + add_s ("\n"); docstat |= D_NP; + docstat |= D_PA; break; } case SP_START_TAB: { - add_s ("\n\n"); + add_s ("\n\n"); docstat |= D_TAB | D_NL; break; } case SP_END_TAB: { - add_s ("\n"); + add_s ("\n"); docstat &= ~D_TAB; docstat |= D_NL; break; } case SP_START_DL: { - add_s ("\n\n"); + add_s ("\n\n"); docstat |= D_DL; break; } case SP_DT: { - add_s (""); + add_s (""); break; } case SP_DD: { - add_s (""); + add_s ("\n\n"); + docstat |= D_DD; break; } case SP_END_DL: { - add_s ("\n"); - docstat &= ~D_DL; + add_s ("\n"); + docstat &= ~(D_DL|D_DD); + break; + } + case SP_END_PAR: + { + add_s ("\n"); + docstat &= ~D_PA; + break; + } + case SP_END_DD: + { + add_s ("\n"); + docstat &= ~D_DD; + break; + } + case SP_END_SECT: + { + add_s ("\n"); break; } case SP_STR: @@ -1147,13 +1194,13 @@ void print_ref (int output_dollar, const char *ref) break; case F_SGML: - add_s ("\n"); if (output_dollar) add_s ("$"); sgml_fputs (ref); - add_s ("\">"); + add_s (""); break; default: @@ -1225,6 +1272,10 @@ static int handle_docline (char *l, int docstat) s += 2; } else if (!strncmp (s, ".dt", 3)) { + if (docstat & D_DD) { + docstat = commit_buff (buff, &d, docstat); + docstat = print_it (SP_END_DD, NULL, docstat); + } docstat = commit_buff (buff, &d, docstat); docstat = print_it (SP_DT, NULL, docstat); s += 3;