* mdocml: Get mdoc_argv.c ready to use [some of] mandoc_getarg() by giving
@ 2011-04-17 9:08 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-04-17 9:08 UTC (permalink / raw)
To: source
Log Message:
-----------
Get mdoc_argv.c ready to use [some of] mandoc_getarg() by giving said
function a parameter to suppress warnings.
Modified Files:
--------------
mdocml:
libmandoc.h
libmdoc.h
man_macro.c
mandoc.c
roff.c
Revision Data
-------------
Index: mandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -Lmandoc.c -Lmandoc.c -u -p -r1.46 -r1.47
--- mandoc.c
+++ 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
}
/* 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
*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);
Index: libmdoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmdoc.h,v
retrieving revision 1.72
retrieving revision 1.73
diff -Llibmdoc.h -Llibmdoc.h -u -p -r1.72 -r1.73
--- libmdoc.h
+++ 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) */
};
/*
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.134
retrieving revision 1.135
diff -Lroff.c -Lroff.c -u -p -r1.134 -r1.135
--- roff.c
+++ 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.
Index: man_macro.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_macro.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -Lman_macro.c -Lman_macro.c -u -p -r1.60 -r1.61
--- man_macro.c
+++ man_macro.c
@@ -484,6 +484,6 @@ man_args(struct man *m, int line, int *p
if ('\0' == *start)
return(0);
- *v = mandoc_getarg(m->parse, v, line, pos);
+ *v = mandoc_getarg(m->parse, v, line, 1, pos);
return(1);
}
Index: libmandoc.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/libmandoc.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -Llibmandoc.h -Llibmandoc.h -u -p -r1.18 -r1.19
--- libmandoc.h
+++ libmandoc.h
@@ -74,7 +74,8 @@ void mandoc_msg(enum mandocerr, struct
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 *);
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-04-17 9:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-17 9:08 mdocml: Get mdoc_argv.c ready to use [some of] mandoc_getarg() by giving kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).