Module Name: src
Committed By: wiz
Date: Tue Dec 17 09:28:10 UTC 2013
Modified Files:
src/external/bsd/mdocml/dist: mdoc_argv.c
Log Message:
Fix handling of nested double quotes.
>From Ingo Schwarze <[email protected]> based on patch by enami@
in PR 48438.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/mdocml/dist/mdoc_argv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/mdocml/dist/mdoc_argv.c
diff -u src/external/bsd/mdocml/dist/mdoc_argv.c:1.4 src/external/bsd/mdocml/dist/mdoc_argv.c:1.5
--- src/external/bsd/mdocml/dist/mdoc_argv.c:1.4 Wed Apr 3 14:50:26 2013
+++ src/external/bsd/mdocml/dist/mdoc_argv.c Tue Dec 17 09:28:10 2013
@@ -453,6 +453,7 @@ args(struct mdoc *m, int line, int *pos,
char *buf, enum argsflag fl, char **v)
{
char *p, *pp;
+ int pairs;
enum margserr rc;
if ('\0' == buf[*pos]) {
@@ -546,6 +547,8 @@ args(struct mdoc *m, int line, int *pos,
/*
* Process a quoted literal. A quote begins with a double-quote
* and ends with a double-quote NOT preceded by a double-quote.
+ * Null-terminate the literal in place.
+ * Collapse pairs of quotes inside quoted literals.
* Whitespace is NOT involved in literal termination.
*/
@@ -556,13 +559,22 @@ args(struct mdoc *m, int line, int *pos,
if (MDOC_PPHRASE & m->flags)
m->flags |= MDOC_PHRASELIT;
+ pairs = 0;
for ( ; buf[*pos]; (*pos)++) {
+ /* Move following text left after quoted quotes. */
+ if (pairs)
+ buf[*pos - pairs] = buf[*pos];
if ('\"' != buf[*pos])
continue;
+ /* Unquoted quotes end quoted args. */
if ('\"' != buf[*pos + 1])
break;
+ /* Quoted quotes collapse. */
+ pairs++;
(*pos)++;
}
+ if (pairs)
+ buf[*pos - pairs] = '\0';
if ('\0' == buf[*pos]) {
if (MDOC_PPHRASE & m->flags)