version 1.46, 2011/04/09 15:35:30 |
version 1.47, 2011/04/17 09:08:19 |
Line 460 mandoc_strdup(const char *ptr) |
|
Line 460 mandoc_strdup(const char *ptr) |
|
* or to the null byte terminating the argument line. |
* or to the null byte terminating the argument line. |
*/ |
*/ |
char * |
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; |
char *start, *cp; |
int quoted, pairs, white; |
int quoted, pairs, white; |
|
|
/* Quoting can only start with a new word. */ |
/* Quoting can only start with a new word. */ |
start = *cpp; |
start = *cpp; |
|
quoted = 0; |
if ('"' == *start) { |
if ('"' == *start) { |
quoted = 1; |
quoted = 1; |
start++; |
start++; |
} else |
} |
quoted = 0; |
|
|
|
pairs = 0; |
pairs = 0; |
white = 0; |
white = 0; |
Line 507 mandoc_getarg(struct mparse *parse, char **cpp, int ln |
|
Line 508 mandoc_getarg(struct mparse *parse, char **cpp, int ln |
|
} |
} |
|
|
/* Quoted argument without a closing quote. */ |
/* Quoted argument without a closing quote. */ |
if (1 == quoted) |
if (dowarn && 1 == quoted) |
mandoc_msg(MANDOCERR_BADQUOTE, parse, ln, *pos, NULL); |
mandoc_msg(MANDOCERR_BADQUOTE, parse, ln, *pos, NULL); |
|
|
/* Null-terminate this argument and move to the next one. */ |
/* Null-terminate this argument and move to the next one. */ |
Line 521 mandoc_getarg(struct mparse *parse, char **cpp, int ln |
|
Line 522 mandoc_getarg(struct mparse *parse, char **cpp, int ln |
|
*pos += (int)(cp - start) + (quoted ? 1 : 0); |
*pos += (int)(cp - start) + (quoted ? 1 : 0); |
*cpp = cp; |
*cpp = cp; |
|
|
if ('\0' == *cp && (white || ' ' == cp[-1])) |
if (dowarn && '\0' == *cp && (white || ' ' == cp[-1])) |
mandoc_msg(MANDOCERR_EOLNSPACE, parse, ln, *pos, NULL); |
mandoc_msg(MANDOCERR_EOLNSPACE, parse, ln, *pos, NULL); |
|
|
return(start); |
return(start); |