projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove most of the debug code: often makes the code unreadable, for little
[apps/madmutt.git]
/
makedoc.c
diff --git
a/makedoc.c
b/makedoc.c
index
88305db
..
3844569
100644
(file)
--- a/
makedoc.c
+++ b/
makedoc.c
@@
-31,6
+31,7
@@
#include <ctype.h>
#include <errno.h>
#include <ctype.h>
#include <errno.h>
+#include <lib-lib/str.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@
-107,7
+108,6
@@
enum {
enum output_formats_t OutputFormat = F_NONE;
char *Progname;
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 char *get_token (char *, size_t, char *);
static char *skip_ws (char *);
@@
-147,9
+147,6
@@
int main (int argc, char *argv[])
case 's':
OutputFormat = F_SGML;
break;
case 's':
OutputFormat = F_SGML;
break;
- case 'd':
- Debug++;
- break;
default:
{
fprintf (stderr, "%s: bad command line parameter.\n", Progname);
default:
{
fprintf (stderr, "%s: bad command line parameter.\n", Progname);
@@
-191,7
+188,7
@@
static void add_var (const char *name)
{
outbuf = realloc (outbuf, (++outcount) * sizeof (var_t));
outbuf[outcount - 1].seen = 0;
{
outbuf = realloc (outbuf, (++outcount) * sizeof (var_t));
outbuf[outcount - 1].seen = 0;
- outbuf[outcount - 1].name = strdup
(name);
+ outbuf[outcount - 1].name = strdup(name);
outbuf[outcount - 1].descr = NULL;
}
outbuf[outcount - 1].descr = NULL;
}
@@
-207,7
+204,7
@@
static int add_s (const char *s)
}
if (lold == 0)
}
if (lold == 0)
- outbuf[outcount - 1].descr = strdup
(s);
+ outbuf[outcount - 1].descr = strdup(s);
else {
outbuf[outcount - 1].descr =
realloc (outbuf[outcount - 1].descr, lold + lnew + 1);
else {
outbuf[outcount - 1].descr =
realloc (outbuf[outcount - 1].descr, lold + lnew + 1);
@@
-247,11
+244,6
@@
static void makedoc (FILE * in, FILE * out)
if (!(p = get_token (token, sizeof (token), buffer)))
continue;
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, "/*++*/"))
active = 1;
else if (!strcmp (token, "/*--*/")) {
if (!strcmp (token, "/*++*/"))
active = 1;
else if (!strcmp (token, "/*--*/")) {
@@
-298,35
+290,19
@@
static char *get_token (char *d, size_t l, char *s)
short is_quoted = 0;
char *dd = d;
short is_quoted = 0;
char *dd = d;
- if (Debug)
- fprintf (stderr, "%s: get_token called for `%s'.\n", Progname, s);
-
s = skip_ws (s);
s = skip_ws (s);
- if (Debug > 1)
- fprintf (stderr, "%s: argumet after skip_ws(): `%s'.\n", Progname, s);
-
if (!*s) {
if (!*s) {
- if (Debug)
- fprintf (stderr, "%s: no more tokens on this line.\n", Progname);
return NULL;
}
if (strchr (single_char_tokens, *s)) {
return NULL;
}
if (strchr (single_char_tokens, *s)) {
- if (Debug) {
- fprintf (stderr, "%s: found single character token `%c'.\n",
- Progname, *s);
- }
d[0] = *s++;
d[1] = 0;
return s;
}
if (*s == '"') {
d[0] = *s++;
d[1] = 0;
return s;
}
if (*s == '"') {
- if (Debug) {
- fprintf (stderr, "%s: found quote character.\n", Progname);
- }
-
s++;
is_quoted = 1;
}
s++;
is_quoted = 1;
}
@@
-369,12
+345,6
@@
static char *get_token (char *d, size_t l, char *s)
*d = '\0';
*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;
}
return t;
}
@@
-471,8
+441,6
@@
static void handle_confline (char *s)
return;
if (!strcmp (buff, "|")) {
return;
if (!strcmp (buff, "|")) {
- if (Debug)
- fprintf (stderr, "%s: Expecting <subtype> <comma>.\n", Progname);
/* ignore subtype and comma */
if (!(s = get_token (buff, sizeof (buff), s)))
return;
/* ignore subtype and comma */
if (!(s = get_token (buff, sizeof (buff), s)))
return;
@@
-500,26
+468,21
@@
static void handle_confline (char *s)
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);
-
/* <default value> or UL <default value> */
if (!(s = get_token (buff, sizeof (buff), s)))
return;
if (!strcmp (buff, "UL")) {
/* <default value> or UL <default value> */
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;
}
- memset
(val, 0, sizeof
(val));
+ memset
(val, 0, sizeof
(val));
do {
if (!strcmp (buff, "}"))
break;
do {
if (!strcmp (buff, "}"))
break;
-
strncpy (val + STRLEN (val), buff, sizeof (val) - STRLEN (val)
);
+
m_strcat(val, sizeof(val), buff
);
}
while ((s = get_token (buff, sizeof (buff), s)));
}
while ((s = get_token (buff, sizeof (buff), s)));
@@
-608,14
+571,17
@@
static int sgml_fputc (int c)
return add_s ("<");
case '>':
return add_s (">");
return add_s ("<");
case '>':
return add_s (">");
+#if 0
case '$':
return add_s ("$");
case '_':
return add_s ("_");
case '%':
return add_s ("%");
case '$':
return add_s ("$");
case '_':
return add_s ("_");
case '%':
return add_s ("%");
+#endif
case '&':
return add_s ("&");
case '&':
return add_s ("&");
+#if 0
case '\\':
return add_s ("\");
case '"':
case '\\':
return add_s ("\");
case '"':
@@
-626,6
+592,7
@@
static int sgml_fputc (int c)
return add_s ("]");
case '~':
return add_s ("˜");
return add_s ("]");
case '~':
return add_s ("˜");
+#endif
default:
return add_c (c);
}
default:
return add_c (c);
}
@@
-733,16
+700,11
@@
static void print_confline (const char *varname, int type, const char *val)
/* SGML based manual */
case F_SGML:
{
/* SGML based manual */
case F_SGML:
{
- add_s ("\n<sect1 id=\"");
- sgml_id_fputs (varname);
- add_s ("\">\n<title>");
+ add_s ("\n<madmutt-doc:vardef name=\"");
sgml_fputs (varname);
sgml_fputs (varname);
- add_s ("
</title
>\n<para>Type: <literal>");
+ add_s ("
\"
>\n<para>Type: <literal>");
add_s (type2human (type));
add_s ("</literal></para>\n");
add_s (type2human (type));
add_s ("</literal></para>\n");
- add_s ("<indexterm><primary>Configuration Variables</primary><secondary>");
- sgml_fputs (varname);
- add_s ("</secondary></indexterm>\n\n");
if (type == DT_STR || type == DT_RX || type == DT_ADDR
|| type == DT_PATH) {
if (type == DT_STR || type == DT_RX || type == DT_ADDR
|| type == DT_PATH) {
@@
-1164,7
+1126,7
@@
static int print_it (int special, char *str, int docstat)
}
case SP_END_SECT:
{
}
case SP_END_SECT:
{
- add_s ("</
sect1
>\n");
+ add_s ("</
madmutt-doc:vardef
>\n");
break;
}
case SP_STR:
break;
}
case SP_STR:
@@
-1201,7
+1163,7
@@
void print_ref (int output_dollar, const char *ref)
sgml_id_fputs (ref);
add_s ("\">\n");
if (output_dollar)
sgml_id_fputs (ref);
add_s ("\">\n");
if (output_dollar)
- add_s ("
$
");
+ add_s ("
$
");
sgml_fputs (ref);
add_s ("</link>");
break;
sgml_fputs (ref);
add_s ("</link>");
break;
@@
-1229,9
+1191,6
@@
static int handle_docline (char *l, int docstat)
l = skip_ws (l);
l = skip_ws (l);
- if (Debug)
- fprintf (stderr, "%s: handle_docline `%s'\n", Progname, l);
-
if (!strncmp (l, ".pp", 3))
return print_it (SP_NEWPAR, NULL, docstat);
else if (!strncmp (l, ".ts", 3))
if (!strncmp (l, ".pp", 3))
return print_it (SP_NEWPAR, NULL, docstat);
else if (!strncmp (l, ".ts", 3))