projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Nico Golde:
[apps/madmutt.git]
/
makedoc.c
diff --git
a/makedoc.c
b/makedoc.c
index
e07b6fa
..
3f04b00
100644
(file)
--- a/
makedoc.c
+++ b/
makedoc.c
@@
-76,15
+76,17
@@
enum output_formats_t {
#define D_NL (1 << 0)
#define D_EM (1 << 1)
#define D_BF (1 << 2)
#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,
enum {
SP_START_EM,
SP_START_BF,
+ SP_START_TT,
SP_END_FT,
SP_NEWLINE,
SP_NEWPAR,
SP_END_FT,
SP_NEWLINE,
SP_NEWPAR,
@@
-188,7
+190,7
@@
static void add_var (const char *name)
outbuf[outcount - 1].descr = NULL;
}
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);
{
size_t lnew = STRLEN (s), lold = STRLEN (outbuf[outcount - 1].descr);
@@
-215,7
+217,7
@@
static int add_c (int c)
char buf[2] = "\0\0";
buf[0] = c;
char buf[2] = "\0\0";
buf[0] = c;
- return (add (buf));
+ return (add
_s
(buf));
}
static void makedoc (FILE * in, FILE * out)
}
static void makedoc (FILE * in, FILE * out)
@@
-604,7
+606,7
@@
static void conf_char_to_escape (unsigned int c)
char buff[16];
char_to_escape (buff, c);
char buff[16];
char_to_escape (buff, c);
- add (buff);
+ add
_s
(buff);
}
static void conf_print_strval (const char *v)
}
static void conf_print_strval (const char *v)
@@
-631,9
+633,9
@@
static void man_print_strval (const char *v)
}
if (*v == '"')
}
if (*v == '"')
- add ("\\(rq");
+ add
_s
("\\(rq");
else if (*v == '\\')
else if (*v == '\\')
- add ("\\\\");
+ add
_s
("\\\\");
else
add_c (*v);
}
else
add_c (*v);
}
@@
-657,27
+659,27
@@
static int sgml_fputc (int c)
{
switch (c) {
case '<':
{
switch (c) {
case '<':
- return add ("<");
+ return add
_s
("<");
case '>':
case '>':
- return add (">");
+ return add
_s
(">");
case '$':
case '$':
- return add ("$");
+ return add
_s
("$");
case '_':
case '_':
- return add ("_");
+ return add
_s
("_");
case '%':
case '%':
- return add ("%");
+ return add
_s
("%");
case '&':
case '&':
- return add ("&");
+ return add
_s
("&");
case '\\':
case '\\':
- return add ("\");
+ return add
_s
("\");
case '"':
case '"':
- return add ("&dquot;");
+ return add
_s
("&dquot;");
case '[':
case '[':
- return add ("[");
+ return add
_s
("[");
case ']':
case ']':
- return add ("]");
+ return add
_s
("]");
case '~':
case '~':
- return add ("˜");
+ return add
_s
("˜");
default:
return add_c (c);
}
default:
return add_c (c);
}
@@
-703,59
+705,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) {
{
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);
conf_print_strval (val);
- add ("\"");
+ add
_s
("\"");
}
else if (type != DT_SYN) {
}
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) {
if (type == DT_STR || type == DT_RX || type == DT_ADDR
|| type == DT_PATH) {
- add ("\n# Default: \"");
+ add
_s
("\n# Default: \"");
conf_print_strval (val);
conf_print_strval (val);
- add ("\"");
+ add
_s
("\"");
}
else {
}
else {
- add ("\n# Default: ");
- add (val);
+ add
_s
("\n# Default: ");
+ add
_s
(val);
}
}
- add ("\n# ");
+ add
_s
("\n# ");
break;
}
/* manual page */
case F_MAN:
{
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_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);
man_print_strval (val);
- add ("\\(rq\n");
+ add
_s
("\\(rq\n");
}
else {
}
else {
- add ("Default: ");
- add (val);
+ add
_s
("Default: ");
+ add
_s
(val);
add_c ('\n');
}
add_c ('\n');
}
- add (".fi");
+ add
_s
(".fi");
break;
}
break;
}
@@
-763,25
+765,25
@@
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 ("\n<sect2>");
+ add
_s
("\n<sect2>");
sgml_fputs (varname);
sgml_fputs (varname);
- add ("<label id=\"");
- add (varname);
- add ("\">");
- add ("\n<p>\nType: <tt>");
- add (type2human (type));
- add ("</tt>\n\n");
+ add
_s
("<label id=\"");
+ add
_s
(varname);
+ add
_s
("\">");
+ add
_s
("\n<p>\nType: <tt>");
+ add
_s
(type2human (type));
+ add
_s
("</tt>\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) {
- add ("<p>\nDefault: <tt>&dquot;");
+ add
_s
("<p>\nDefault: <tt>&dquot;");
sgml_print_strval (val);
sgml_print_strval (val);
- add ("&dquot;</tt>");
+ add
_s
("&dquot;</tt>");
}
else {
}
else {
- add ("<p>\nDefault: <tt>");
- add (val);
- add ("</tt>");
+ add
_s
("<p>\nDefault: <tt>");
+ add
_s
(val);
+ add
_s
("</tt>");
}
break;
}
}
break;
}
@@
-803,6
+805,7
@@
static void print_confline (const char *varname, int type, const char *val)
**
** - \fI switches to italics
** - \fB switches to boldface
**
** - \fI switches to italics
** - \fB switches to boldface
+ ** - \fT switches to typewriter for SGML
** - \fP switches to normal display
** - .dl on a line starts a definition list (name taken taken from HTML).
** - .dt starts a term in a definition list.
** - \fP switches to normal display
** - .dl on a line starts a definition list (name taken taken from HTML).
** - .dt starts a term in a definition list.
@@
-838,7
+841,7
@@
static int flush_doc (int docstat)
if (docstat & (D_DL))
docstat = print_it (SP_END_DL, NULL, docstat);
if (docstat & (D_DL))
docstat = print_it (SP_END_DL, NULL, docstat);
- if (docstat & (D_EM | D_BF))
+ if (docstat & (D_EM | D_BF
| D_TT
))
docstat = print_it (SP_END_FT, NULL, docstat);
docstat = print_it (SP_NEWLINE, NULL, 0);
docstat = print_it (SP_END_FT, NULL, docstat);
docstat = print_it (SP_NEWLINE, NULL, 0);
@@
-863,7
+866,7
@@
static int print_it (int special, char *str, int docstat)
static int Continuation = 0;
case SP_END_FT:
static int Continuation = 0;
case SP_END_FT:
- docstat &= ~(D_EM | D_BF);
+ docstat &= ~(D_EM | D_BF
| D_TT
);
break;
case SP_START_BF:
docstat |= D_BF;
break;
case SP_START_BF:
docstat |= D_BF;
@@
-871,12
+874,15
@@
static int print_it (int special, char *str, int docstat)
case SP_START_EM:
docstat |= D_EM;
break;
case SP_START_EM:
docstat |= D_EM;
break;
+ case SP_START_TT:
+ docstat |= D_TT;
+ break;
case SP_NEWLINE:
{
if (onl)
docstat |= onl;
else {
case SP_NEWLINE:
{
if (onl)
docstat |= onl;
else {
- add ("\n# ");
+ add
_s
("\n# ");
docstat |= D_NL;
}
if (docstat & D_DL)
docstat |= D_NL;
}
if (docstat & D_DL)
@@
-891,15
+897,15
@@
static int print_it (int special, char *str, int docstat)
}
if (!(onl & D_NL))
}
if (!(onl & D_NL))
- add ("\n# ");
- add ("\n# ");
+ add
_s
("\n# ");
+ add
_s
("\n# ");
docstat |= D_NP;
break;
}
case SP_START_TAB:
{
if (!onl)
docstat |= D_NP;
break;
}
case SP_START_TAB:
{
if (!onl)
- add ("\n# ");
+ add
_s
("\n# ");
docstat |= D_TAB;
break;
}
docstat |= D_TAB;
break;
}
@@
-935,9
+941,9
@@
static int print_it (int special, char *str, int docstat)
{
if (Continuation) {
Continuation = 0;
{
if (Continuation) {
Continuation = 0;
- add (" ");
+ add
_s
(" ");
}
}
- add (str);
+ add
_s
(str);
if (docstat & D_DT) {
int i;
if (docstat & D_DT) {
int i;
@@
-958,22
+964,28
@@
static int print_it (int special, char *str, int docstat)
switch (special) {
case SP_END_FT:
{
switch (special) {
case SP_END_FT:
{
- add ("\\fP");
- docstat &= ~(D_EM | D_BF);
+ add
_s
("\\fP");
+ docstat &= ~(D_EM | D_BF
| D_TT
);
break;
}
case SP_START_BF:
{
break;
}
case SP_START_BF:
{
- add ("\\fB");
+ add
_s
("\\fB");
docstat |= D_BF;
docstat |= D_BF;
- docstat &= ~
D_EM
;
+ docstat &= ~
(D_EM | D_TT)
;
break;
}
case SP_START_EM:
{
break;
}
case SP_START_EM:
{
- add ("\\fI");
+ add
_s
("\\fI");
docstat |= D_EM;
docstat |= D_EM;
- docstat &= ~D_BF;
+ docstat &= ~(D_BF | D_TT);
+ break;
+ }
+ case SP_START_TT:
+ {
+ docstat |= D_TT;
+ docstat &= ~(D_BF | D_EM);
break;
}
case SP_NEWLINE:
break;
}
case SP_NEWLINE:
@@
-995,43
+1007,43
@@
static int print_it (int special, char *str, int docstat)
if (!(onl & D_NL))
add_c ('\n');
if (!(onl & D_NL))
add_c ('\n');
- add (".IP\n");
+ add
_s
(".IP\n");
docstat |= D_NP;
break;
}
case SP_START_TAB:
{
docstat |= D_NP;
break;
}
case SP_START_TAB:
{
- add ("\n.IP\n.DS\n.sp\n.ft CR\n.nf\n");
+ add
_s
("\n.IP\n.DS\n.sp\n.ft CR\n.nf\n");
docstat |= D_TAB | D_NL;
break;
}
case SP_END_TAB:
{
docstat |= D_TAB | D_NL;
break;
}
case SP_END_TAB:
{
- add ("\n.fi\n.ec\n.ft P\n.sp\n");
+ add
_s
("\n.fi\n.ec\n.ft P\n.sp\n");
docstat &= ~D_TAB;
docstat |= D_NL;
break;
}
case SP_START_DL:
{
docstat &= ~D_TAB;
docstat |= D_NL;
break;
}
case SP_START_DL:
{
- add ("\n.RS");
+ add
_s
("\n.RS");
docstat |= D_DL;
break;
}
case SP_DT:
{
docstat |= D_DL;
break;
}
case SP_DT:
{
- add ("\n.IP ");
+ add
_s
("\n.IP ");
break;
}
case SP_DD:
{
break;
}
case SP_DD:
{
- add ("\n");
+ add
_s
("\n");
break;
}
case SP_END_DL:
{
break;
}
case SP_END_DL:
{
- add ("\n.RE");
+ add
_s
("\n.RE");
docstat &= ~D_DL;
break;
}
docstat &= ~D_DL;
break;
}
@@
-1040,15
+1052,15
@@
static int print_it (int special, char *str, int docstat)
while (*str) {
for (; *str; str++) {
if (*str == '"')
while (*str) {
for (; *str; str++) {
if (*str == '"')
- add ("\\(rq");
+ add
_s
("\\(rq");
else if (*str == '\\')
else if (*str == '\\')
- add ("\\\\");
+ add
_s
("\\\\");
else if (!strncmp (str, "``", 2)) {
else if (!strncmp (str, "``", 2)) {
- add ("\\(lq");
+ add
_s
("\\(lq");
str++;
}
else if (!strncmp (str, "''", 2)) {
str++;
}
else if (!strncmp (str, "''", 2)) {
- add ("\\(rq");
+ add
_s
("\\(rq");
str++;
}
else
str++;
}
else
@@
-1068,24
+1080,33
@@
static int print_it (int special, char *str, int docstat)
case SP_END_FT:
{
if (docstat & D_EM)
case SP_END_FT:
{
if (docstat & D_EM)
- add ("</em>");
+ add
_s
("</em>");
if (docstat & D_BF)
if (docstat & D_BF)
- add ("</bf>");
- docstat &= ~(D_EM | D_BF);
+ add_s ("</bf>");
+ if (docstat & D_TT)
+ add_s ("</tt>");
+ docstat &= ~(D_EM | D_BF | D_TT);
break;
}
case SP_START_BF:
{
break;
}
case SP_START_BF:
{
- add ("<bf>");
+ add
_s
("<bf>");
docstat |= D_BF;
docstat |= D_BF;
- docstat &= ~
D_EM
;
+ docstat &= ~
(D_EM | D_TT)
;
break;
}
case SP_START_EM:
{
break;
}
case SP_START_EM:
{
- add ("<em>");
+ add
_s
("<em>");
docstat |= D_EM;
docstat |= D_EM;
- docstat &= ~D_BF;
+ docstat &= ~(D_BF | D_TT);
+ break;
+ }
+ case SP_START_TT:
+ {
+ add_s ("<tt>");
+ docstat |= D_TT;
+ docstat &= ~(D_EM | D_BF);
break;
}
case SP_NEWLINE:
break;
}
case SP_NEWLINE:
@@
-1093,7
+1114,7
@@
static int print_it (int special, char *str, int docstat)
if (onl)
docstat |= onl;
else {
if (onl)
docstat |= onl;
else {
- add ("\n");
+ add
_s
("\n");
docstat |= D_NL;
}
break;
docstat |= D_NL;
}
break;
@@
-1106,51
+1127,51
@@
static int print_it (int special, char *str, int docstat)
}
if (!(onl & D_NL))
}
if (!(onl & D_NL))
- add ("\n");
- add ("\n<p>\n");
+ add
_s
("\n");
+ add
_s
("\n<p>\n");
docstat |= D_NP;
break;
}
case SP_START_TAB:
{
docstat |= D_NP;
break;
}
case SP_START_TAB:
{
- add ("\n<tscreen><verb>\n");
+ add
_s
("\n<tscreen><verb>\n");
docstat |= D_TAB | D_NL;
break;
}
case SP_END_TAB:
{
docstat |= D_TAB | D_NL;
break;
}
case SP_END_TAB:
{
- add ("\n</verb></tscreen>");
+ add
_s
("\n</verb></tscreen>");
docstat &= ~D_TAB;
docstat |= D_NL;
break;
}
case SP_START_DL:
{
docstat &= ~D_TAB;
docstat |= D_NL;
break;
}
case SP_START_DL:
{
- add ("\n<descrip>\n");
+ add
_s
("\n<descrip>\n");
docstat |= D_DL;
break;
}
case SP_DT:
{
docstat |= D_DL;
break;
}
case SP_DT:
{
- add ("<tag>");
+ add
_s
("<tag>");
break;
}
case SP_DD:
{
break;
}
case SP_DD:
{
- add ("</tag>");
+ add
_s
("</tag>");
break;
}
case SP_END_DL:
{
break;
}
case SP_END_DL:
{
- add ("</descrip>\n");
+ add
_s
("</descrip>\n");
docstat &= ~D_DL;
break;
}
case SP_STR:
{
if (docstat & D_TAB)
docstat &= ~D_DL;
break;
}
case SP_STR:
{
if (docstat & D_TAB)
- add (str);
+ add
_s
(str);
else
sgml_fputs (str);
break;
else
sgml_fputs (str);
break;
@@
-1173,17
+1194,17
@@
void print_ref (int output_dollar, const char *ref)
case F_MAN:
if (output_dollar)
add_c ('$');
case F_MAN:
if (output_dollar)
add_c ('$');
- add (ref);
+ add
_s
(ref);
break;
case F_SGML:
break;
case F_SGML:
- add ("<ref id=\"");
- add (ref);
- add ("\" name=\"");
+ add
_s
("<ref id=\"");
+ add
_s
(ref);
+ add
_s
("\" name=\"");
if (output_dollar)
if (output_dollar)
- add ("$");
+ add
_s
("$");
sgml_fputs (ref);
sgml_fputs (ref);
- add ("\">");
+ add
_s
("\">");
break;
default:
break;
default:
@@
-1244,6
+1265,11
@@
static int handle_docline (char *l, int docstat)
docstat = print_it (SP_START_BF, NULL, docstat);
s += 2;
}
docstat = print_it (SP_START_BF, NULL, docstat);
s += 2;
}
+ else if (!strncmp (s, "\\fT", 3)) {
+ docstat = commit_buff (buff, &d, docstat);
+ docstat = print_it (SP_START_TT, NULL, docstat);
+ s += 2;
+ }
else if (!strncmp (s, "\\fP", 3)) {
docstat = commit_buff (buff, &d, docstat);
docstat = print_it (SP_END_FT, NULL, docstat);
else if (!strncmp (s, "\\fP", 3)) {
docstat = commit_buff (buff, &d, docstat);
docstat = print_it (SP_END_FT, NULL, docstat);