X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=makedoc.c;h=91f6630281bd364240158913f211cd15f38a6895;hp=cbbc42700bc0469b689bea36b3f0836b63bbdb9e;hb=7d29626ce4e1fa932c6349c7253e6f774df069fc;hpb=7a88114b82edda96b7f57d33787e927ee0eb5cd8 diff --git a/makedoc.c b/makedoc.c index cbbc427..91f6630 100644 --- a/makedoc.c +++ b/makedoc.c @@ -1,20 +1,14 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1999-2000 Thomas Roessler - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - */ + * + * 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. + */ /** ** This program parses mutt's init.h and generates documentation in @@ -27,60 +21,48 @@ ** **/ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include - -#include - -#ifdef HAVE_UNISTD_H -# include -#endif +#include #ifdef HAVE_GETOPT_H # include #endif -#ifndef HAVE_STRERROR -#ifndef STDC_HEADERS -extern int sys_nerr; -extern char *sys_errlist[]; -#endif - -#define strerror(x) ((x) > 0 && (x) < sys_nerr) ? sys_errlist[(x)] : 0 -#endif /* !HAVE_STRERROR */ - -extern int optind; +typedef struct { + short seen; + char *name; + char *descr; +} var_t; -#define BUFFSIZE 2048 +static int outcount = 0; +static var_t *outbuf = NULL; -static char lastvar[BUFFSIZE]; -static int sort_error = 0; - -enum output_formats_t +static int var_cmp (const void *a, const void *b) { + return (m_strcmp (((var_t *) a)->name, ((var_t *) b)->name)); +} + +enum output_formats_t { F_CONF, F_MAN, F_SGML, F_NONE }; -#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) - -enum -{ +#define D_NL (1 << 0) +#define D_EM (1 << 1) +#define D_BF (1 << 2) +#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) +#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, @@ -89,27 +71,31 @@ enum SP_START_DL, SP_DT, SP_DD, + SP_END_DD, SP_END_DL, + SP_END_SECT, SP_REFER }; enum output_formats_t OutputFormat = F_NONE; char *Progname; -short Debug = 0; static char *get_token (char *, size_t, char *); static char *skip_ws (char *); static const char *type2human (int); static int buff2type (const char *); -static int flush_doc (int, FILE *); -static int handle_docline (char *, FILE *, int); -static int print_it (int, char *, FILE *, int); -static void print_confline (const char *, int, const char *, FILE *); -static void handle_confline (char *, FILE *); +static int flush_doc (int); +static int handle_docline (char *, int); +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, FILE *); -static int sgml_fputs (const char *, 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); int main (int argc, char *argv[]) { @@ -120,80 +106,106 @@ int main (int argc, char *argv[]) Progname++; else Progname = argv[0]; - - while ((c = getopt (argc, argv, "cmsd")) != EOF) - { - switch (c) - { - case 'c': OutputFormat = F_CONF; break; - case 'm': OutputFormat = F_MAN; break; - case 's': OutputFormat = F_SGML; break; - case 'd': Debug++; break; - default: + + while ((c = getopt (argc, argv, "cmsd")) != EOF) { + switch (c) { + case 'c': + OutputFormat = F_CONF; + break; + case 'm': + OutputFormat = F_MAN; + break; + case 's': + OutputFormat = F_SGML; + break; + default: { - fprintf (stderr, "%s: bad command line parameter.\n", Progname); - exit (1); + fprintf (stderr, "%s: bad command line parameter.\n", Progname); + exit (1); } } } - if (optind != argc) - { - if ((f = fopen (argv[optind], "r")) == NULL) - { + if (optind != argc) { + if ((f = fopen (argv[optind], "r")) == NULL) { fprintf (stderr, "%s: Can't open %s (%s).\n", - Progname, argv[optind], strerror (errno)); + Progname, argv[optind], strerror (errno)); exit (1); } } - else + else f = stdin; - switch (OutputFormat) - { - case F_CONF: - case F_MAN: - case F_SGML: - lastvar[0] = '\0'; - makedoc (f, stdout); break; - default: + switch (OutputFormat) { + case F_CONF: + case F_MAN: + case F_SGML: + makedoc (f, stdout); + break; + default: { - fprintf (stderr, "%s: No output format specified.\n", - Progname); + fprintf (stderr, "%s: No output format specified.\n", Progname); exit (1); } } - + if (f != stdin) - fclose (f); - + m_fclose(&f); + exit (1); } -static void remember (const char* s) +static void add_var (const char *name) +{ + p_realloc(&outbuf, ++outcount); + outbuf[outcount - 1].seen = 0; + outbuf[outcount - 1].name = strdup(name); + outbuf[outcount - 1].descr = NULL; +} + +static int add_s (const char *s) +{ + size_t lnew = m_strlen(s), lold = m_strlen(outbuf[outcount - 1].descr); + + if (lnew == 0) + return (0); + if (!outbuf[outcount - 1].seen) { + lold = 0; + outbuf[outcount - 1].seen = 1; + } + + if (lold == 0) + outbuf[outcount - 1].descr = strdup(s); + else { + p_realloc(&outbuf[outcount - 1].descr, lold + lnew + 1); + memcpy(&(outbuf[outcount - 1].descr[lold - 1]) + 1, s, lnew); + } + outbuf[outcount - 1].descr[lold + lnew] = '\0'; + return (1); +} + +static int add_c (int c) { - int l = strlen (s); - lastvar[0] = '\0'; - strncpy (lastvar, s, strlen (s)); - lastvar[l] = '\0'; + char buf[2] = "\0\0"; + + buf[0] = c; + return (add_s (buf)); } -static void makedoc (FILE *in, FILE *out) +static void makedoc (FILE * in, FILE * out) { - char buffer[BUFFSIZE]; - char token[BUFFSIZE]; + char buffer[BUFSIZ]; + char token[BUFSIZ]; char *p; int active = 0; int line = 0; int docstat = D_INIT; - while ((fgets (buffer, sizeof (buffer), in))) - { + while ((fgets (buffer, sizeof (buffer), in))) { line++; - if ((p = strchr (buffer, '\n')) == NULL) - { + if ((p = strchr (buffer, '\n')) == NULL) { fprintf (stderr, "%s: Line %d too long. Ask a wizard to enlarge\n" - "%s: my buffer size.\n", Progname, line, Progname); + "%s: my buffer size.\n", Progname, line, Progname); exit (1); } else @@ -202,31 +214,30 @@ static void makedoc (FILE *in, FILE *out) if (!(p = get_token (token, sizeof (token), buffer))) continue; - if (Debug) - { - fprintf (stderr, "%s: line %d. first token: \"%s\".\n", - Progname, line, token); - } - - if (!strcmp (token, "/*++*/")) + if (!m_strcmp (token, "/*++*/")) active = 1; - else if (!strcmp (token, "/*--*/")) - { - docstat = flush_doc (docstat, out); + else if (!m_strcmp (token, "/*--*/")) { + docstat = flush_doc (docstat); active = 0; } - else if (active && (!strcmp (token, "/**") || !strcmp (token, "**"))) - docstat = handle_docline (p, out, docstat); - else if (active && !strcmp (token, "{")) - { - docstat = flush_doc (docstat, out); - handle_confline (p, out); + else if (active && (!m_strcmp (token, "/**") || !m_strcmp (token, "**"))) + docstat = handle_docline (p, docstat); + else if (active && !m_strcmp (token, "{")) { + docstat = flush_doc (docstat); + handle_confline (p); } } - flush_doc (docstat, out); + flush_doc (docstat); fputs ("\n", out); - if (sort_error == 1) - fputs ("makedoc: warning: there're sorting errors in vars\n", stderr); + qsort (outbuf, outcount, sizeof (var_t), &var_cmp); + for (line = 0; line < outcount; line++) { + if (outbuf[line].descr) { + fprintf (out, "%s\n", outbuf[line].descr); + p_delete(&outbuf[line].descr); + } + p_delete(&outbuf[line].name); + } + p_delete(&outbuf); } /* skip whitespace */ @@ -247,69 +258,49 @@ static char *get_token (char *d, size_t l, char *s) { char *t; short is_quoted = 0; - char *dd = d; - if (Debug) - fprintf (stderr, "%s: get_token called for `%s'.\n", - Progname, s); - s = skip_ws (s); - if (Debug > 1) - fprintf (stderr, "%s: argumet after skip_ws(): `%s'.\n", - Progname, s); - - if (!*s) - { - if (Debug) - fprintf (stderr, "%s: no more tokens on this line.\n", Progname); + if (!*s) { return NULL; } - if (strchr (single_char_tokens, *s)) - { - if (Debug) - { - fprintf (stderr, "%s: found single character token `%c'.\n", - Progname, *s); - } + if (strchr (single_char_tokens, *s)) { d[0] = *s++; d[1] = 0; return s; } - if (*s == '"') - { - if (Debug) - { - fprintf (stderr, "%s: found quote character.\n", Progname); - } - + if (*s == '"') { s++; is_quoted = 1; } - for (t = s; *t && --l > 0; t++) - { + for (t = s; *t && --l > 0; t++) { if (*t == '\\' && !t[1]) break; - if (is_quoted && *t == '\\') - { - switch ((*d = *++t)) - { - case 'n': *d = '\n'; break; - case 't': *d = '\t'; break; - case 'r': *d = '\r'; break; - case 'a': *d = '\a'; break; + if (is_quoted && *t == '\\') { + switch ((*d = *++t)) { + case 'n': + *d = '\n'; + break; + case 't': + *d = '\t'; + break; + case 'r': + *d = '\r'; + break; + case 'a': + *d = '\a'; + break; } d++; continue; } - if (is_quoted && *t == '"') - { + if (is_quoted && *t == '"') { t++; break; } @@ -323,14 +314,6 @@ static char *get_token (char *d, size_t l, char *s) *d = '\0'; - if (Debug) - { - fprintf (stderr, "%s: Got %stoken: `%s'.\n", - Progname, is_quoted ? "quoted " : "", dd); - fprintf (stderr, "%s: Remainder: `%s'.\n", - Progname, t); - } - return t; } @@ -347,8 +330,7 @@ static char *get_token (char *d, size_t l, char *s) * following string definitions! */ -enum -{ +enum { DT_NONE = 0, DT_BOOL, DT_NUM, @@ -359,39 +341,37 @@ enum DT_RX, DT_MAGIC, DT_SYN, - DT_ADDR + DT_ADDR, + DT_SYS }; -struct -{ - char *machine; - char *human; -} -types[] = -{ - { "DT_NONE", "-none-" }, - { "DT_BOOL", "boolean" }, - { "DT_NUM", "number" }, - { "DT_STR", "string" }, - { "DT_PATH", "path" }, - { "DT_QUAD", "quadoption" }, - { "DT_SORT", "sort order" }, - { "DT_RX", "regular expression" }, - { "DT_MAGIC", "folder magic" }, - { "DT_SYN", NULL }, - { "DT_ADDR", "e-mail address" }, - { NULL, NULL } +struct { + const char *machine; + const char *human; +} types[] = { + {"DT_NONE", "-none-"}, + {"DT_BOOL", "boolean"}, + {"DT_NUM", "number"}, + {"DT_STR", "string"}, + {"DT_PATH", "path"}, + {"DT_QUAD", "quadoption"}, + {"DT_SORT", "sort order"}, + {"DT_RX", "regular expression"}, + {"DT_MAGIC", "folder magic"}, + {"DT_SYN", NULL}, + {"DT_ADDR", "e-mail address"}, + {"DT_SYS", "system property"}, + {NULL, NULL} }; - static int buff2type (const char *s) { int type; - + for (type = DT_NONE; types[type].machine; type++) - if (!strcmp (types[type].machine, s)) - return type; - + if (!m_strcmp (types[type].machine, s)) + return type; + return DT_NONE; } @@ -399,312 +379,299 @@ static const char *type2human (int type) { return types[type].human; } -static void handle_confline (char *s, FILE *out) +static void handle_confline (char *s) { - char varname[BUFFSIZE]; - char buff[BUFFSIZE]; - char tmp[BUFFSIZE]; + char varname[BUFSIZ]; + char buff[BUFSIZ]; int type; - - char val[BUFFSIZE]; + + char val[BUFSIZ]; /* xxx - put this into an actual state machine? */ /* variable name */ if (!(s = get_token (varname, sizeof (varname), s))) return; - else - { - if (lastvar[0] && strncmp (lastvar, varname, strlen (lastvar)) > 0) - sort_error = 1; - remember (varname); - } - + /* comma */ - if (!(s = get_token (buff, sizeof (buff), s))) return; - + if (!(s = get_token (buff, sizeof (buff), s))) + return; + /* type */ - if (!(s = get_token (buff, sizeof (buff), s))) return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; type = buff2type (buff); /* possibly a "|" or comma */ - if (!(s = get_token (buff, sizeof (buff), s))) return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; - if (!strcmp (buff, "|")) - { - if (Debug) fprintf (stderr, "%s: Expecting .\n", Progname); + if (!m_strcmp (buff, "|")) { /* ignore subtype and comma */ - if (!(s = get_token (buff, sizeof (buff), s))) return; - if (!(s = get_token (buff, sizeof (buff), s))) return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; } /* redraw, comma */ - - while (1) - { - if (!(s = get_token (buff, sizeof (buff), s))) return; - if (!strcmp (buff, ",")) + + while (1) { + if (!(s = get_token (buff, sizeof (buff), s))) + return; + if (!m_strcmp (buff, ",")) break; } /* option name or UL &address */ - if (!(s = get_token (buff, sizeof (buff), s))) return; - if (!strcmp (buff, "UL")) - if (!(s = get_token (buff, sizeof (buff), s))) return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; + if (!m_strcmp (buff, "UL")) + if (!(s = get_token (buff, sizeof (buff), s))) + return; /* comma */ - if (!(s = get_token (buff, sizeof (buff), s))) return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; - if (Debug) fprintf (stderr, "%s: Expecting default value.\n", Progname); - /* or UL */ - if (!(s = get_token (buff, sizeof (buff), s))) return; - if (!strcmp (buff, "UL")) - { - if (Debug) fprintf (stderr, "%s: Skipping UL.\n", Progname); - if (!(s = get_token (buff, sizeof (buff), s))) return; + if (!(s = get_token (buff, sizeof (buff), s))) + return; + if (!m_strcmp (buff, "UL")) { + if (!(s = get_token (buff, sizeof (buff), s))) + return; } - memset (tmp, 0, sizeof (tmp)); + memset(val, 0, sizeof(val)); - do - { - if (!strcmp (buff, "}")) + do { + if (!m_strcmp (buff, "}")) break; - strncpy (tmp + strlen (tmp), buff, sizeof (tmp) - strlen (tmp)); + m_strcat(val, sizeof(val), buff); } while ((s = get_token (buff, sizeof (buff), s))); - pretty_default (val, sizeof (val), tmp, type); - print_confline (varname, type, val, out); + add_var (varname); + print_confline (varname, type, val); } -static void pretty_default (char *t, size_t l, const char *s, int type) +static void char_to_escape (char *dest, int len, unsigned int c) { - 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) - { - case '\r': strcpy (dest, "\\r"); break; /* __STRCPY_CHECKED__ */ - case '\n': strcpy (dest, "\\n"); break; /* __STRCPY_CHECKED__ */ - case '\t': strcpy (dest, "\\t"); break; /* __STRCPY_CHECKED__ */ - case '\f': strcpy (dest, "\\f"); break; /* __STRCPY_CHECKED__ */ - default: sprintf (dest, "\\%03o", c); break; + switch (c) { + case '\r': + m_strcpy(dest, len, "\\r"); + break; + case '\n': + m_strcpy(dest, len, "\\n"); + break; + case '\t': + m_strcpy(dest, len, "\\t"); + break; + case '\f': + m_strcpy(dest, len, "\\f"); + break; + default: + sprintf (dest, len, "\\%03o", c); + break; } } -static void conf_char_to_escape (unsigned int c , FILE *out) +static void conf_char_to_escape (unsigned int c) { char buff[16]; - char_to_escape (buff, c); - fputs (buff, out); + + char_to_escape(buff, sizeof(buff), c); + add_s (buff); } -static void conf_print_strval (const char *v, FILE *out) +static void conf_print_strval (const char *v) { - for (; *v; v++) - { - if (*v < ' ' || *v & 0x80) - { - conf_char_to_escape ((unsigned int) *v, out); + for (; *v; v++) { + if (*v < ' ' || *v & 0x80) { + conf_char_to_escape ((unsigned int) *v); continue; } - if (*v == '"' || *v == '\\') - fputc ('\\', out); - fputc (*v, out); + if (*v == '"' || *v == '\\') + add_c ('\\'); + add_c (*v); } } -static void man_print_strval (const char *v, FILE *out) +static void man_print_strval (const char *v) { - for (; *v; v++) - { - if (*v < ' ' || *v & 0x80) - { - fputc ('\\', out); - conf_char_to_escape ((unsigned int) *v, out); + for (; *v; v++) { + if (*v < ' ' || *v & 0x80) { + add_c ('\\'); + conf_char_to_escape ((unsigned int) *v); continue; } - + if (*v == '"') - fputs ("\\(rq", out); + add_s ("\\(rq"); else if (*v == '\\') - fputs ("\\\\", out); + add_s ("\\\\"); else - fputc (*v, out); + add_c (*v); } } -static void sgml_print_strval (const char *v, FILE *out) +static void sgml_print_strval (const char *v) { char buff[16]; - for (; *v; v++) - { - if (*v < ' ' || *v & 0x80) - { - char_to_escape (buff, (unsigned int) *v); - sgml_fputs (buff, out); + + for (; *v; v++) { + if (*v < ' ' || *v & 0x80) { + char_to_escape(buff, sizeof(buff), (unsigned int) *v); + sgml_fputs (buff); continue; } - sgml_fputc ((unsigned int) *v, out); + sgml_fputc ((unsigned int) *v); } } -static int sgml_fputc (int c, FILE *out) +static int sgml_fputc (int c) { - switch (c) - { - 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 ("&dquot;", out); - case '[': return fputs ("[", out); - case ']': return fputs ("]", out); - case '~': return fputs ("˜", out); - default: return fputc (c, out); + switch (c) { + case '<': + return add_s ("<"); + case '>': + return add_s (">"); + case '&': + return add_s ("&"); + default: + return add_c (c); } } -static int sgml_fputs (const char *s, FILE *out) +static int sgml_fputs (const char *s) { for (; *s; s++) - if (sgml_fputc ((unsigned int) *s, out) == EOF) + if (sgml_fputc ((unsigned int) *s) == EOF) return EOF; - + return 0; } -static void print_confline (const char *varname, int type, const char *val, FILE *out) +/* 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) return; - - switch (OutputFormat) - { + if (type == DT_SYN) + return; + + switch (OutputFormat) { /* configuration file */ - case F_CONF: + case F_CONF: { - if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) - { - fprintf (out, "\n# set %s=\"", varname); - conf_print_strval (val, out); - fputs ("\"", out); + if (type == DT_SYS) { + add_s ("\n# set ?"); + add_s (varname); + add_s (" prints "); + add_s (val); + break; } - else if (type != DT_SYN) - fprintf (out, "\n# set %s=%s", varname, val); - - fprintf (out, "\n#\n# Name: %s", varname); - fprintf (out, "\n# Type: %s", type2human (type)); - if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) - { - fputs ("\n# Default: \"", out); - conf_print_strval (val, out); - fputs ("\"", out); + if (type == DT_STR || type == DT_RX || type == DT_ADDR + || type == DT_PATH) { + add_s ("\n# set "); + add_s (varname); + add_s ("=\""); + conf_print_strval (val); + add_s ("\""); + } + else if (type != DT_SYN) { + add_s ("\n# set "); + add_s (varname); + add_s ("="); + add_s (val); + } + + 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_s ("\n# Default: \""); + conf_print_strval (val); + add_s ("\""); + } + else { + add_s ("\n# Default: "); + add_s (val); } - else - fprintf (out, "\n# Default: %s", val); - fputs ("\n# ", out); + add_s ("\n# "); break; } /* manual page */ - case F_MAN: + case F_MAN: { - fprintf (out, "\n.TP\n.B %s\n", varname); - fputs (".nf\n", out); - fprintf (out, "Type: %s\n", type2human (type)); - if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH) - { - fputs ("Default: \\(lq", out); - man_print_strval (val, out); - fputs ("\\(rq\n", out); + 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_s ("Default: \\(lq"); + man_print_strval (val); + add_s ("\\(rq\n"); } - else - fprintf (out, "Default: %s\n", val); - - fputs (".fi", out); + else { + add_s (type == DT_SYS ? "Value: " : "Default: "); + add_s (val); + add_c ('\n'); + } + add_s (".fi"); break; } - + /* SGML based manual */ - case F_SGML: + case F_SGML: { - fputs ("\n", out); sgml_fputs (varname, out); - fprintf (out, "