]> err.no Git - varnish/commitdiff
Implement backslash-newline escapes.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 15 Jun 2008 12:44:10 +0000 (12:44 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 15 Jun 2008 12:44:10 +0000 (12:44 +0000)
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

index d124bbca025976cc38c1cdf38c72393c01bb6138..702d2f0a417ccd077c7ddd4e745e472df63ae917 100644 (file)
@@ -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;