summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-05-08 07:30:19 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-05-08 07:30:19 +0000
commit29086c29fdd989b9c086bf25e0790ba21243c4ff (patch)
tree50a8ad3ca3079d5cf210d324169efe8e8f96b62d
parent98c1a46e2586de979ce0fc696b15d91fb80166c5 (diff)
downloadmandoc-29086c29fdd989b9c086bf25e0790ba21243c4ff.tar.gz
mandoc-29086c29fdd989b9c086bf25e0790ba21243c4ff.tar.zst
mandoc-29086c29fdd989b9c086bf25e0790ba21243c4ff.zip
Lint fixes (type-safety for enums via -cefuh).
-rw-r--r--index.sgml10
-rw-r--r--libmdoc.h5
-rw-r--r--man.c11
-rw-r--r--man_hash.c4
-rw-r--r--mdoc.c22
-rw-r--r--mdoc_action.c10
-rw-r--r--mdoc_argv.c27
-rw-r--r--mdoc_hash.c4
-rw-r--r--mdoc_macro.c8
-rw-r--r--mdoc_strings.c4
-rw-r--r--mdoc_validate.c4
11 files changed, 57 insertions, 52 deletions
diff --git a/index.sgml b/index.sgml
index afaf0d13..3ea70a1a 100644
--- a/index.sgml
+++ b/index.sgml
@@ -219,11 +219,11 @@
<COL CLASS="date">
<TBODY>
<TR>
- <TD VALIGN="top"><SPAN CLASS="date">xx-05-2010</SPAN></TD>
+ <TD VALIGN="top"><SPAN CLASS="date">XX-XX-2010</SPAN></TD>
<TD VALIGN="top">
- Clean-up in internal <SPAN CLASS="flag">-mdoc</SPAN> library. Rolled back
- break-at-hyphen (broken). <SPAN CLASS="flag">-DUGLY</SPAN> is now the default
- (why not).
+ Rolled back break-at-hyphen (broken). <SPAN CLASS="flag">-DUGLY</SPAN> is now
+ the default (I don't like feature splits). Free-form text is not de-chunked any
+ more: lines are passed whole-sale into the front-end, including whitespace.
Version: <SPAN CLASS="rev">1.9.24</SPAN>.
</TD>
</TR>
@@ -309,7 +309,7 @@
<TR>
<TD>
<DIV CLASS="foot">
- Copyright &#169; 2008&#8211;2010 Kristaps Dzonsons, $Date: 2010/05/07 06:05:38 $
+ Copyright &#169; 2008&#8211;2010 Kristaps Dzonsons, $Date: 2010/05/08 07:30:19 $
</DIV>
</TD>
</TR>
diff --git a/libmdoc.h b/libmdoc.h
index f9a0ca2f..dc90df13 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.38 2010/05/07 06:05:38 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.39 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -163,8 +163,7 @@ int mdoc_isdelim(const char *);
size_t mdoc_isescape(const char *);
enum mdoc_sec mdoc_atosec(const char *);
time_t mdoc_atotime(const char *);
-
-size_t mdoc_macro2len(int);
+size_t mdoc_macro2len(enum mdoct);
const char *mdoc_a2att(const char *);
const char *mdoc_a2lib(const char *);
const char *mdoc_a2st(const char *);
diff --git a/man.c b/man.c
index f7b2bba3..a92fac8d 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.61 2010/05/07 15:49:36 kristaps Exp $ */
+/* $Id: man.c,v 1.62 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -435,8 +435,7 @@ static int
macrowarn(struct man *m, int ln, const char *buf)
{
if ( ! (MAN_IGN_MACRO & m->pflags))
- return(man_verr(m, ln, 0,
- "unknown macro: %s%s",
+ return(man_verr(m, ln, 0, "unknown macro: %s%s",
buf, strlen(buf) > 3 ? "..." : ""));
return(man_vwarn(m, ln, 0, "unknown macro: %s%s",
buf, strlen(buf) > 3 ? "..." : ""));
@@ -462,6 +461,7 @@ man_pmacro(struct man *m, int ln, char *buf)
* Skip whitespace between the control character and initial
* text. "Whitespace" is both spaces and tabs.
*/
+
if (' ' == buf[i] || '\t' == buf[i]) {
i++;
while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))
@@ -510,7 +510,10 @@ man_pmacro(struct man *m, int ln, char *buf)
while (buf[i] && ' ' == buf[i])
i++;
- /* Trailing whitespace? */
+ /*
+ * Trailing whitespace. Note that tabs are allowed to be passed
+ * into the parser as "text", so we only warn about spaces here.
+ */
if ('\0' == buf[i] && ' ' == buf[i - 1])
if ( ! man_pwarn(m, ln, i - 1, WTSPACE))
diff --git a/man_hash.c b/man_hash.c
index 587baeda..ef079ca2 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -1,4 +1,4 @@
-/* $Id: man_hash.c,v 1.18 2010/03/27 10:14:32 kristaps Exp $ */
+/* $Id: man_hash.c,v 1.19 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -63,7 +63,7 @@ man_hash_init(void)
assert(/* LINTED */
MAN_MAX < UCHAR_MAX);
- for (i = 0; i < MAN_MAX; i++) {
+ for (i = 0; i < (int)MAN_MAX; i++) {
x = man_macronames[i][0];
assert(isalpha((u_char)x) || '.' == x);
diff --git a/mdoc.c b/mdoc.c
index e3741cdd..5974c19b 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.124 2010/05/07 15:49:36 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.125 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -542,7 +542,7 @@ mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p)
len = strlen(p);
- n = node_alloc(m, line, pos, -1, MDOC_TEXT);
+ n = node_alloc(m, line, pos, MDOC_MAX, MDOC_TEXT);
n->string = mandoc_malloc(len + 1);
sv = strlcpy(n->string, p, len + 1);
@@ -681,13 +681,11 @@ mdoc_ptext(struct mdoc *m, int line, char *buf)
}
-
static int
macrowarn(struct mdoc *m, int ln, const char *buf)
{
if ( ! (MDOC_IGN_MACRO & m->pflags))
- return(mdoc_verr(m, ln, 0,
- "unknown macro: %s%s",
+ return(mdoc_verr(m, ln, 0, "unknown macro: %s%s",
buf, strlen(buf) > 3 ? "..." : ""));
return(mdoc_vwarn(m, ln, 0, "unknown macro: %s%s",
buf, strlen(buf) > 3 ? "..." : ""));
@@ -701,8 +699,9 @@ macrowarn(struct mdoc *m, int ln, const char *buf)
int
mdoc_pmacro(struct mdoc *m, int ln, char *buf)
{
- int i, j, c;
- char mac[5];
+ enum mdoct tok;
+ int i, j;
+ char mac[5];
/* Empty lines are ignored. */
@@ -744,7 +743,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf)
return(1);
}
- if (MDOC_MAX == (c = mdoc_hash_find(mac))) {
+ if (MDOC_MAX == (tok = mdoc_hash_find(mac))) {
if ( ! macrowarn(m, ln, mac))
goto err;
return(1);
@@ -755,7 +754,10 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf)
while (buf[i] && ' ' == buf[i])
i++;
- /* Trailing whitespace? */
+ /*
+ * Trailing whitespace. Note that tabs are allowed to be passed
+ * into the parser as "text", so we only warn about spaces here.
+ */
if ('\0' == buf[i] && ' ' == buf[i - 1])
if ( ! mdoc_pwarn(m, ln, i - 1, ETAILWS))
@@ -765,7 +767,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf)
* Begin recursive parse sequence. Since we're at the start of
* the line, we don't need to do callable/parseable checks.
*/
- if ( ! mdoc_macro(m, c, ln, 1, &i, buf))
+ if ( ! mdoc_macro(m, tok, ln, 1, &i, buf))
goto err;
return(1);
diff --git a/mdoc_action.c b/mdoc_action.c
index 1d0245c7..b9b95f99 100644
--- a/mdoc_action.c
+++ b/mdoc_action.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_action.c,v 1.53 2010/04/06 11:33:00 kristaps Exp $ */
+/* $Id: mdoc_action.c,v 1.54 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -44,7 +44,7 @@ struct actions {
static int concat(struct mdoc *, char *,
const struct mdoc_node *, size_t);
-static inline int order_rs(int);
+static inline int order_rs(enum mdoct);
static int post_ar(POST_ARGS);
static int post_at(POST_ARGS);
@@ -196,7 +196,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = {
#define RSORD_MAX 14
-static const int rsord[RSORD_MAX] = {
+static const enum mdoct rsord[RSORD_MAX] = {
MDOC__A,
MDOC__T,
MDOC__B,
@@ -945,11 +945,11 @@ post_display(POST_ARGS)
static inline int
-order_rs(int t)
+order_rs(enum mdoct t)
{
int i;
- for (i = 0; i < RSORD_MAX; i++)
+ for (i = 0; i < (int)RSORD_MAX; i++)
if (rsord[i] == t)
return(i);
diff --git a/mdoc_argv.c b/mdoc_argv.c
index c1a5ee31..8f973e21 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.42 2010/05/07 15:49:36 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.43 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -666,16 +666,16 @@ static int
argv_multi(struct mdoc *m, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
- int c;
+ enum margserr ac;
char *p;
for (v->sz = 0; ; v->sz++) {
if ('-' == buf[*pos])
break;
- c = args(m, line, pos, buf, 0, &p);
- if (ARGS_ERROR == c)
+ ac = args(m, line, pos, buf, 0, &p);
+ if (ARGS_ERROR == ac)
return(0);
- else if (ARGS_EOLN == c)
+ else if (ARGS_EOLN == ac)
break;
if (0 == v->sz % MULTI_STEP)
@@ -693,16 +693,16 @@ static int
argv_opt_single(struct mdoc *m, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
- int c;
+ enum margserr ac;
char *p;
if ('-' == buf[*pos])
return(1);
- c = args(m, line, pos, buf, 0, &p);
- if (ARGS_ERROR == c)
+ ac = args(m, line, pos, buf, 0, &p);
+ if (ARGS_ERROR == ac)
return(0);
- if (ARGS_EOLN == c)
+ if (ARGS_EOLN == ac)
return(1);
v->sz = 1;
@@ -720,15 +720,16 @@ static int
argv_single(struct mdoc *m, int line,
struct mdoc_argv *v, int *pos, char *buf)
{
- int c, ppos;
+ int ppos;
+ enum margserr ac;
char *p;
ppos = *pos;
- c = args(m, line, pos, buf, 0, &p);
- if (ARGS_ERROR == c)
+ ac = args(m, line, pos, buf, 0, &p);
+ if (ARGS_ERROR == ac)
return(0);
- if (ARGS_EOLN == c)
+ if (ARGS_EOLN == ac)
return(mdoc_perr(m, line, ppos, EARGVAL));
v->sz = 1;
diff --git a/mdoc_hash.c b/mdoc_hash.c
index 0b89cd8a..25cf603d 100644
--- a/mdoc_hash.c
+++ b/mdoc_hash.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_hash.c,v 1.13 2010/03/31 07:13:53 kristaps Exp $ */
+/* $Id: mdoc_hash.c,v 1.14 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -43,7 +43,7 @@ mdoc_hash_init(void)
memset(table, UCHAR_MAX, sizeof(table));
- for (i = 0; i < MDOC_MAX; i++) {
+ for (i = 0; i < (int)MDOC_MAX; i++) {
p = mdoc_macronames[i];
if (isalpha((u_char)p[1]))
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 86eb7b83..5275f520 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.57 2010/05/07 06:05:38 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.58 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -45,7 +45,7 @@ static int obsolete(MACRO_PROT_ARGS);
static int append_delims(struct mdoc *,
int, int *, char *);
-static enum mdoct lookup(int, const char *);
+static enum mdoct lookup(enum mdoct, const char *);
static enum mdoct lookup_raw(const char *);
static int phrase(struct mdoc *, int, int, char *);
static enum mdoct rew_alt(enum mdoct);
@@ -267,7 +267,7 @@ mdoc_macroend(struct mdoc *m)
* Look up a macro from within a subsequent context.
*/
static enum mdoct
-lookup(int from, const char *p)
+lookup(enum mdoct from, const char *p)
{
/* FIXME: make -diag lists be un-PARSED. */
@@ -283,7 +283,7 @@ lookup(int from, const char *p)
static enum mdoct
lookup_raw(const char *p)
{
- int res;
+ enum mdoct res;
if (MDOC_MAX == (res = mdoc_hash_find(p)))
return(MDOC_MAX);
diff --git a/mdoc_strings.c b/mdoc_strings.c
index 9007fa32..bfe4c652 100644
--- a/mdoc_strings.c
+++ b/mdoc_strings.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_strings.c,v 1.16 2010/04/03 12:46:35 kristaps Exp $ */
+/* $Id: mdoc_strings.c,v 1.17 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -127,7 +127,7 @@ mdoc_atosec(const char *p)
/* FIXME: move this into an editable .in file. */
size_t
-mdoc_macro2len(int macro)
+mdoc_macro2len(enum mdoct macro)
{
switch (macro) {
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 61eb7cc1..b442293c 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.69 2010/04/07 19:35:42 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.70 2010/05/08 07:30:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -747,7 +747,7 @@ pre_sh(PRE_ARGS)
if (MDOC_BLOCK != n->type)
return(1);
- return(check_parent(mdoc, n, -1, MDOC_ROOT));
+ return(check_parent(mdoc, n, MDOC_MAX, MDOC_ROOT));
}