aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandoc.c
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
commit0880ade932d57aac1fa88eaaf4668570bff7cf1d (patch)
tree6248d908a8f84be2ed64c5e34082dcb3e41f650b /mandoc.c
parenta8417ed4885aa3e6440de50e68bc15bb0309ca7f (diff)
downloadmandoc-0880ade932d57aac1fa88eaaf4668570bff7cf1d.tar.gz
mandoc-0880ade932d57aac1fa88eaaf4668570bff7cf1d.tar.zst
mandoc-0880ade932d57aac1fa88eaaf4668570bff7cf1d.zip
Get mdoc_argv.c ready to use [some of] mandoc_getarg() by giving said
function a parameter to suppress warnings.
Diffstat (limited to 'mandoc.c')
-rw-r--r--mandoc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/mandoc.c b/mandoc.c
index 2c59d598..ca73afd7 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.46 2011/04/09 15:35:30 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.47 2011/04/17 09:08:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);