From 4473c7bda0b6d9e3b6c9bc46ed483bed741d719e Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 15 Jun 2008 12:44:10 +0000 Subject: [PATCH] Implement backslash-newline escapes. Implement "" quoting of strings. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2678 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishtest/vtc.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishtest/vtc.c b/varnish-cache/bin/varnishtest/vtc.c index d124bbca..702d2f0a 100644 --- a/varnish-cache/bin/varnishtest/vtc.c +++ b/varnish-cache/bin/varnishtest/vtc.c @@ -76,7 +76,7 @@ void 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 @@ parse_string(char *buf, const struct cmds *cmd, void *priv) 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; -- 2.39.5