summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-04-17 09:08:19 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-04-17 09:08:19 +0000
commit3a57b035c09a784e5ce7ada2b1a4ce22ed7320fe (patch)
tree515d02d4ccb4880b38f6df7c57a3f8e598c1736d
parent9ccae84ab6241d21623e7c1872a91f839f32e1c9 (diff)
downloadmandoc-3a57b035c09a784e5ce7ada2b1a4ce22ed7320fe.tar.gz
Get mdoc_argv.c ready to use [some of] mandoc_getarg() by giving said
function a parameter to suppress warnings.
-rw-r--r--libmandoc.h3
-rw-r--r--libmdoc.h20
-rw-r--r--man_macro.c2
-rw-r--r--mandoc.c11
-rw-r--r--roff.c2
5 files changed, 20 insertions, 18 deletions
diff --git a/libmandoc.h b/libmandoc.h
index cdfa2c6e..e78c5494 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -74,7 +74,8 @@ void mandoc_msg(enum mandocerr, struct mparse *,
void mandoc_vmsg(enum mandocerr, struct mparse *,
int, int, const char *, ...);
char *mandoc_strdup(const char *);
-char *mandoc_getarg(struct mparse *, char **, int, int *);
+char *mandoc_getarg(struct mparse *,
+ char **, int, int, int *);
char *mandoc_normdate(struct mparse *, char *, int, int);
int mandoc_eos(const char *, size_t, int);
int mandoc_hyph(const char *, const char *);
diff --git a/libmdoc.h b/libmdoc.h
index 357d24a8..2b4b2b70 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -62,20 +62,20 @@ struct mdoc_macro {
enum margserr {
ARGS_ERROR,
- ARGS_EOLN,
- ARGS_WORD,
- ARGS_PUNCT,
- ARGS_QWORD,
- ARGS_PHRASE,
- ARGS_PPHRASE,
- ARGS_PEND
+ ARGS_EOLN, /* end-of-line */
+ ARGS_WORD, /* normal word */
+ ARGS_PUNCT, /* series of punctuation */
+ ARGS_QWORD, /* quoted word */
+ ARGS_PHRASE, /* Ta'd phrase (-column) */
+ ARGS_PPHRASE, /* tabbed phrase (-column) */
+ ARGS_PEND /* last phrase (-column) */
};
enum margverr {
ARGV_ERROR,
- ARGV_EOLN,
- ARGV_ARG,
- ARGV_WORD
+ ARGV_EOLN, /* end of line */
+ ARGV_ARG, /* valid argument */
+ ARGV_WORD /* normal word (or bad argument---same thing) */
};
/*
diff --git a/man_macro.c b/man_macro.c
index aff3fb00..cab56cf1 100644
--- a/man_macro.c
+++ b/man_macro.c
@@ -484,6 +484,6 @@ man_args(struct man *m, int line, int *pos, char *buf, char **v)
if ('\0' == *start)
return(0);
- *v = mandoc_getarg(m->parse, v, line, pos);
+ *v = mandoc_getarg(m->parse, v, line, 1, pos);
return(1);
}
diff --git a/mandoc.c b/mandoc.c
index 4b2bd3f3..6ca21577 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -460,18 +460,19 @@ mandoc_strdup(const char *ptr)
* or to the null byte terminating the argument line.
*/
char *
-mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos)
+mandoc_getarg(struct mparse *parse,
+ char **cpp, int ln, int dowarn, int *pos)
{
char *start, *cp;
int quoted, pairs, white;
/* Quoting can only start with a new word. */
start = *cpp;
+ quoted = 0;
if ('"' == *start) {
quoted = 1;
start++;
- } else
- quoted = 0;
+ }
pairs = 0;
white = 0;
@@ -507,7 +508,7 @@ mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos)
}
/* Quoted argument without a closing quote. */
- if (1 == quoted)
+ if (dowarn && 1 == quoted)
mandoc_msg(MANDOCERR_BADQUOTE, parse, ln, *pos, NULL);
/* Null-terminate this argument and move to the next one. */
@@ -521,7 +522,7 @@ mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos)
*pos += (int)(cp - start) + (quoted ? 1 : 0);
*cpp = cp;
- if ('\0' == *cp && (white || ' ' == cp[-1]))
+ if (dowarn && '\0' == *cp && (white || ' ' == cp[-1]))
mandoc_msg(MANDOCERR_EOLNSPACE, parse, ln, *pos, NULL);
return(start);
diff --git a/roff.c b/roff.c
index c86bb31a..9955fe92 100644
--- a/roff.c
+++ b/roff.c
@@ -1238,7 +1238,7 @@ roff_userdef(ROFF_ARGS)
cp = *bufp + pos;
for (i = 0; i < 9; i++)
arg[i] = '\0' == *cp ? "" :
- mandoc_getarg(r->parse, &cp, ln, &pos);
+ mandoc_getarg(r->parse, &cp, ln, 1, &pos);
/*
* Expand macro arguments.