diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-08-20 08:59:12 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-08-20 08:59:12 +0000 |
commit | 715664aab2d78bfca25251802a317ec3d515ddf3 (patch) | |
tree | a31f6a986b9b1346b4afc83b2ce05ed14084c00f | |
parent | 077b83403c555a1a2160ae7dfb7439e5ae84c96d (diff) | |
download | mandoc-715664aab2d78bfca25251802a317ec3d515ddf3.tar.gz |
Delimiter whitespace is correctly flagged (required some special handling).
-rw-r--r-- | libmdoc.h | 6 | ||||
-rw-r--r-- | mdoc_argv.c | 24 | ||||
-rw-r--r-- | mdoc_macro.c | 4 |
3 files changed, 20 insertions, 14 deletions
@@ -171,14 +171,16 @@ void mdoc_argv_free(struct mdoc_arg *); int mdoc_args(struct mdoc *, int, int *, char *, int, char **); int mdoc_zargs(struct mdoc *, int, - int *, char *, char **); + int *, char *, int, char **); +#define ARGS_DELIM (1 << 1) +#define ARGS_TABSEP (1 << 2) +#define ARGS_NOWARN (1 << 3) #define ARGS_ERROR (-1) #define ARGS_EOLN (0) #define ARGS_WORD (1) #define ARGS_PUNCT (2) #define ARGS_QWORD (3) #define ARGS_PHRASE (4) - int mdoc_macroend(struct mdoc *); __END_DECLS diff --git a/mdoc_argv.c b/mdoc_argv.c index 0cb36ff9..adafc7b1 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -32,9 +32,6 @@ * There's no limit to the number or arguments that may be allocated. */ -#define ARGS_DELIM (1 << 1) -#define ARGS_TABSEP (1 << 2) - #define ARGV_NONE (1 << 0) #define ARGV_SINGLE (1 << 1) #define ARGV_MULTI (1 << 2) @@ -325,10 +322,11 @@ mdoc_argv_free(struct mdoc_arg *p) int -mdoc_zargs(struct mdoc *m, int line, int *pos, char *buf, char **v) +mdoc_zargs(struct mdoc *m, int line, int *pos, + char *buf, int flags, char **v) { - return(args(m, line, pos, buf, 0, v)); + return(args(m, line, pos, buf, flags, v)); } @@ -401,10 +399,14 @@ args(struct mdoc *m, int line, int *pos, i++; } - /* FIXME: warn about trailing whitespace. */ - if (0 == buf[i]) { *v = &buf[*pos]; + if (' ' != buf[i - 1]) + return(ARGS_PUNCT); + if (ARGS_NOWARN & fl) + return(ARGS_PUNCT); + if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) + return(ARGS_ERROR); return(ARGS_PUNCT); } } @@ -448,7 +450,7 @@ args(struct mdoc *m, int line, int *pos, p = strchr(*v, 0); /* Whitespace check for eoln case... */ - if (0 == *p && ' ' == *(p - 1)) + if (0 == *p && ' ' == *(p - 1) && ! (ARGS_NOWARN & fl)) if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) return(ARGS_ERROR); @@ -488,6 +490,8 @@ args(struct mdoc *m, int line, int *pos, } if (0 == buf[*pos]) { + if (ARGS_NOWARN & fl) + return(ARGS_QWORD); if ( ! mdoc_pwarn(m, line, *pos, EQUOTTERM)) return(ARGS_ERROR); return(ARGS_QWORD); @@ -501,7 +505,7 @@ args(struct mdoc *m, int line, int *pos, while (' ' == buf[*pos]) (*pos)++; - if (0 == buf[*pos]) + if (0 == buf[*pos] && ! (ARGS_NOWARN & fl)) if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) return(ARGS_ERROR); @@ -525,7 +529,7 @@ args(struct mdoc *m, int line, int *pos, while (' ' == buf[*pos]) (*pos)++; - if (0 == buf[*pos]) + if (0 == buf[*pos] && ! (ARGS_NOWARN & fl)) if ( ! mdoc_pwarn(m, line, *pos, ETAILWS)) return(ARGS_ERROR); diff --git a/mdoc_macro.c b/mdoc_macro.c index 4941f0c2..e6cf717f 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -600,7 +600,7 @@ append_delims(struct mdoc *mdoc, int line, int *pos, char *buf) for (;;) { lastarg = *pos; - c = mdoc_args(mdoc, line, pos, buf, 0, &p); + c = mdoc_zargs(mdoc, line, pos, buf, ARGS_NOWARN, &p); assert(ARGS_PHRASE != c); if (ARGS_ERROR == c) @@ -1326,7 +1326,7 @@ phrase(struct mdoc *m, int line, int ppos, char *buf) la = pos; /* Note: no calling context! */ - w = mdoc_zargs(m, line, &pos, buf, &p); + w = mdoc_zargs(m, line, &pos, buf, 0, &p); if (ARGS_ERROR == w) return(0); |