summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
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 /mdoc.c
parent98c1a46e2586de979ce0fc696b15d91fb80166c5 (diff)
downloadmandoc-29086c29fdd989b9c086bf25e0790ba21243c4ff.tar.gz
mandoc-29086c29fdd989b9c086bf25e0790ba21243c4ff.tar.zst
mandoc-29086c29fdd989b9c086bf25e0790ba21243c4ff.zip
Lint fixes (type-safety for enums via -cefuh).
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c22
1 files changed, 12 insertions, 10 deletions
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);