diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-26 11:16:21 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-26 11:16:21 +0000 |
commit | 85e36c433929ad75eea12adc0e68cab5fdca3f1d (patch) | |
tree | c7b563cb2460da8d637536e9354b7cbd34298ccb | |
parent | 35f2108111d8f83fc25edd4c460e0f37db93901b (diff) | |
download | mandoc-85e36c433929ad75eea12adc0e68cab5fdca3f1d.tar.gz |
Fixed inheritence of initial macro into man_macro.
Removed warnxs from man_macro (man_vwarn).
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | man.c | 22 | ||||
-rw-r--r-- | man_macro.c | 19 |
3 files changed, 25 insertions, 18 deletions
@@ -41,7 +41,7 @@ MAINSRCS = main.c term.c ascii.c terminal.c tree.c compat.c LLNS = llib-llibmdoc.ln llib-llibman.ln llib-lmandoc.ln LNS = $(MAINLNS) $(MDOCLNS) $(MANLNS) LIBS = libmdoc.a libman.a -OBJS = $(MDOCOBJS) $(MAINOBJS) +OBJS = $(MDOCOBJS) $(MAINOBJS) $(MANOBJS) SRCS = $(MDOCSRCS) $(MAINSRCS) $(MANSRCS) DATAS = arch.in att.in lib.in msec.in st.in vol.in ascii.in HEADS = mdoc.h libmdoc.h man.h libman.h term.h @@ -275,7 +275,7 @@ man_ptext(struct man *m, int line, char *buf) int man_pmacro(struct man *m, int ln, char *buf) { - int i, j, c; + int i, j, c, ppos; char mac[5]; /* Comments and empties are quickly ignored. */ @@ -293,16 +293,18 @@ man_pmacro(struct man *m, int ln, char *buf) return(1); } + ppos = i; + if (buf[i] && '\\' == buf[i]) if (buf[i + 1] && '\"' == buf[i + 1]) return(1); /* Copy the first word into a nil-terminated buffer. */ - for (j = 0; j < 4; j++) { - if (0 == (mac[j] = buf[j + i])) + for (j = 0; j < 4; j++, i++) { + if (0 == (mac[j] = buf[i])) break; - else if (' ' == buf[j + i]) + else if (' ' == buf[i]) break; } @@ -310,22 +312,24 @@ man_pmacro(struct man *m, int ln, char *buf) if (j == 4 || j < 1) { if ( ! (MAN_IGN_MACRO & m->pflags)) { - (void)man_verr(m, ln, i, + (void)man_verr(m, ln, ppos, "ill-formed macro: %s", mac); goto err; } - if ( ! man_vwarn(m, ln, 0, "ill-formed macro: %s", mac)) + if ( ! man_vwarn(m, ln, ppos, + "ill-formed macro: %s", mac)) goto err; return(1); } if (MAN_MAX == (c = man_hash_find(m->htab, mac))) { if ( ! (MAN_IGN_MACRO & m->pflags)) { - (void)man_verr(m, ln, i, + (void)man_verr(m, ln, ppos, "unknown macro: %s", mac); goto err; } - if ( ! man_vwarn(m, ln, i, "unknown macro: %s", mac)) + if ( ! man_vwarn(m, ln, ppos, + "unknown macro: %s", mac)) goto err; return(1); } @@ -337,7 +341,7 @@ man_pmacro(struct man *m, int ln, char *buf) /* Begin recursive parse sequence. */ - if ( ! man_macro(m, c, ln, 1, &i, buf)) + if ( ! man_macro(m, c, ln, ppos, &i, buf)) goto err; return(1); diff --git a/man_macro.c b/man_macro.c index 87832e1c..518b1e8e 100644 --- a/man_macro.c +++ b/man_macro.c @@ -18,7 +18,6 @@ */ #include <assert.h> #include <ctype.h> -#include <err.h> /* XXX */ #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -113,7 +112,7 @@ man_macroend(struct man *m) /* ARGSUSED */ static int -man_args(struct man *man, int line, +man_args(struct man *m, int line, int *pos, char *buf, char **v) { @@ -146,8 +145,10 @@ man_args(struct man *man, int line, if (buf[*pos]) return(1); - warnx("tail whitespace"); - return(-1); + if ( ! man_vwarn(m, line, *pos, "trailing spaces")) + return(-1); + + return(1); } /* @@ -162,8 +163,9 @@ man_args(struct man *man, int line, (*pos)++; if (0 == buf[*pos]) { - warnx("unterminated quotation"); - return(-1); + if ( ! man_vwarn(m, line, *pos, "unterminated quote")) + return(-1); + return(1); } buf[(*pos)++] = 0; @@ -176,6 +178,7 @@ man_args(struct man *man, int line, if (buf[*pos]) return(1); - warnx("tail whitespace"); - return(-1); + if ( ! man_vwarn(m, line, *pos, "trailing spaces")) + return(-1); + return(1); } |