X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=makedoc.c;h=f739e232ff0270f1657ee7159751b33f09abf257;hp=42dcc601297c86eae180073c0b18640608e93ae5;hb=955b6b84c6eabd42a96ff0176003ef72d49d9c38;hpb=c3e57678c8be193fc137854020f3a90887be97c9 diff --git a/makedoc.c b/makedoc.c index 42dcc60..f739e23 100644 --- a/makedoc.c +++ b/makedoc.c @@ -2,6 +2,9 @@ * Copyright notice from original mutt: * Copyright (C) 1999-2000 Thomas Roessler * + * Parts were written/modified by: + * Rocco Rutte + * * This file is part of mutt-ng, see http://www.muttng.org/. * It's licensed under the GNU General Public License, * please see the file GPL in the top level source directory. @@ -73,15 +76,17 @@ enum output_formats_t { #define D_NL (1 << 0) #define D_EM (1 << 1) #define D_BF (1 << 2) -#define D_TAB (1 << 3) -#define D_NP (1 << 4) -#define D_INIT (1 << 5) -#define D_DL (1 << 6) -#define D_DT (1 << 7) +#define D_TT (1 << 3) +#define D_TAB (1 << 4) +#define D_NP (1 << 5) +#define D_INIT (1 << 6) +#define D_DL (1 << 7) +#define D_DT (1 << 8) enum { SP_START_EM, SP_START_BF, + SP_START_TT, SP_END_FT, SP_NEWLINE, SP_NEWPAR, @@ -109,7 +114,6 @@ static int print_it (int, char *, int); static void print_confline (const char *, int, const char *); static void handle_confline (char *); static void makedoc (FILE *, FILE *); -static void pretty_default (char *, size_t, const char *, int); static int sgml_fputc (int); static int sgml_fputs (const char *); static void add_var (const char *); @@ -185,7 +189,7 @@ static void add_var (const char *name) outbuf[outcount - 1].descr = NULL; } -static int add (const char *s) +static int add_s (const char *s) { size_t lnew = STRLEN (s), lold = STRLEN (outbuf[outcount - 1].descr); @@ -212,7 +216,7 @@ static int add_c (int c) char buf[2] = "\0\0"; buf[0] = c; - return (add (buf)); + return (add_s (buf)); } static void makedoc (FILE * in, FILE * out) @@ -434,7 +438,6 @@ static void handle_confline (char *s) { char varname[BUFFSIZE]; char buff[BUFFSIZE]; - char tmp[BUFFSIZE]; int type; char val[BUFFSIZE]; @@ -502,80 +505,20 @@ static void handle_confline (char *s) return; } - memset (tmp, 0, sizeof (tmp)); + memset (val, 0, sizeof (val)); do { if (!strcmp (buff, "}")) break; - strncpy (tmp + STRLEN (tmp), buff, sizeof (tmp) - STRLEN (tmp)); + strncpy (val + STRLEN (val), buff, sizeof (val) - STRLEN (val)); } while ((s = get_token (buff, sizeof (buff), s))); - pretty_default (val, sizeof (val), tmp, type); add_var (varname); print_confline (varname, type, val); } -static void pretty_default (char *t, size_t l, const char *s, int type) -{ - memset (t, 0, l); - l--; - - switch (type) { - case DT_QUAD: - { - if (!strcasecmp (s, "M_YES")) - strncpy (t, "yes", l); - else if (!strcasecmp (s, "M_NO")) - strncpy (t, "no", l); - else if (!strcasecmp (s, "M_ASKYES")) - strncpy (t, "ask-yes", l); - else if (!strcasecmp (s, "M_ASKNO")) - strncpy (t, "ask-no", l); - break; - } - case DT_BOOL: - { - if (atoi (s)) - strncpy (t, "yes", l); - else - strncpy (t, "no", l); - break; - } - case DT_SORT: - { - /* heuristic! */ - strncpy (t, s + 5, l); - for (; *t; t++) - *t = tolower ((unsigned char) *t); - break; - } - case DT_MAGIC: - { - /* heuristic! */ - strncpy (t, s + 2, l); - for (; *t; t++) - *t = tolower ((unsigned char) *t); - break; - } - case DT_STR: - case DT_RX: - case DT_ADDR: - case DT_PATH: - { - if (!strcmp (s, "0")) - break; - /* fallthrough */ - } - default: - { - strncpy (t, s, l); - break; - } - } -} - static void char_to_escape (char *dest, unsigned int c) { switch (c) { @@ -601,7 +544,7 @@ static void conf_char_to_escape (unsigned int c) char buff[16]; char_to_escape (buff, c); - add (buff); + add_s (buff); } static void conf_print_strval (const char *v) @@ -628,9 +571,9 @@ static void man_print_strval (const char *v) } if (*v == '"') - add ("\\(rq"); + add_s ("\\(rq"); else if (*v == '\\') - add ("\\\\"); + add_s ("\\\\"); else add_c (*v); } @@ -654,27 +597,27 @@ static int sgml_fputc (int c) { switch (c) { case '<': - return add ("<"); + return add_s ("<"); case '>': - return add (">"); + return add_s (">"); case '$': - return add ("$"); + return add_s ("$"); case '_': - return add ("_"); + return add_s ("_"); case '%': - return add ("%"); + return add_s ("%"); case '&': - return add ("&"); + return add_s ("&"); case '\\': - return add ("\"); + return add_s ("\"); case '"': - return add ("&dquot;"); + return add_s ("&dquot;"); case '[': - return add ("["); + return add_s ("["); case ']': - return add ("]"); + return add_s ("]"); case '~': - return add ("˜"); + return add_s ("˜"); default: return add_c (c); } @@ -700,59 +643,59 @@ static void print_confline (const char *varname, int type, const char *val) { if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) { - add ("\n# set "); - add (varname); - add ("\""); + add_s ("\n# set "); + add_s (varname); + add_s ("=\""); conf_print_strval (val); - add ("\""); + add_s ("\""); } else if (type != DT_SYN) { - add ("\n# set "); - add (varname); - add ("="); - add (val); + add_s ("\n# set "); + add_s (varname); + add_s ("="); + add_s (val); } - add ("\n#\n# Name: "); - add (varname); - add ("\n# Type: "); - add (type2human (type)); + add_s ("\n#\n# Name: "); + add_s (varname); + add_s ("\n# Type: "); + add_s (type2human (type)); if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) { - add ("\n# Default: \""); + add_s ("\n# Default: \""); conf_print_strval (val); - add ("\""); + add_s ("\""); } else { - add ("\n# Default: "); - add (val); + add_s ("\n# Default: "); + add_s (val); } - add ("\n# "); + add_s ("\n# "); break; } /* manual page */ case F_MAN: { - add (".TP\n.B "); - add (varname); - add ("\n.nf\n"); - add ("Type: "); - add (type2human (type)); + add_s (".TP\n.B "); + add_s (varname); + add_s ("\n.nf\n"); + add_s ("Type: "); + add_s (type2human (type)); add_c ('\n'); if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) { - add ("Default: \\(lq"); + add_s ("Default: \\(lq"); man_print_strval (val); - add ("\\(rq\n"); + add_s ("\\(rq\n"); } else { - add ("Default: "); - add (val); + add_s ("Default: "); + add_s (val); add_c ('\n'); } - add (".fi"); + add_s (".fi"); break; } @@ -760,25 +703,25 @@ static void print_confline (const char *varname, int type, const char *val) /* SGML based manual */ case F_SGML: { - add ("\n"); + add_s ("\n"); sgml_fputs (varname); - add ("