Mailing List Archive

r2678 - trunk/varnish-cache/bin/varnishtest
Author: phk
Date: 2008-06-15 14:44:10 +0200 (Sun, 15 Jun 2008)
New Revision: 2678

Modified:
trunk/varnish-cache/bin/varnishtest/vtc.c
Log:
Implement backslash-newline escapes.

Implement "" quoting of strings.



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 12:15:47 UTC (rev 2677)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 12:44:10 UTC (rev 2678)
@@ -76,7 +76,7 @@
parse_string(char *buf, const struct cmds *cmd, void *priv)
{
char *token_s[MAX_TOKENS], *token_e[MAX_TOKENS];
- char *p;
+ char *p, *q;
int nest_brace;
int tn;
const struct cmds *cp;
@@ -102,6 +102,31 @@
break;
} else if (isspace(*p)) { /* Inter-token whitespace */
p++;
+ } else if (*p == '\\' && p[1] == '\n') {
+ p += 2;
+ } else if (*p == '"') { /* quotes */
+ token_s[tn] = ++p;
+ q = p;
+ for (; *p != '\0'; p++) {
+ if (*p == '"')
+ break;
+
+ if (*p == '\\' && p[1] == 'n') {
+ *q++ = '\n';
+ p++;
+ } else if (*p == '\\' && p[1] == '\\') {
+ *q++ = '\\';
+ p++;
+ } else if (*p == '\\' && p[1] == '"') {
+ *q++ = '"';
+ p++;
+ } else {
+ assert(*p != '\n');
+ *q++ = *p;
+ }
+ }
+ token_e[tn++] = q;
+ p++;
} else if (*p == '{') { /* Braces */
nest_brace = 0;
token_s[tn] = p;