r4313 - in branches/2.0/varnish-cache: bin/varnishtest bin/varnishtest/tests include lib/libvarnish
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Thu Oct 8 17:12:41 CEST 2009
Author: tfheen
Date: 2009-10-08 17:12:41 +0200 (Thu, 08 Oct 2009)
New Revision: 4313
Modified:
branches/2.0/varnish-cache/bin/varnishtest/tests/c00001.vtc
branches/2.0/varnish-cache/bin/varnishtest/vtc.c
branches/2.0/varnish-cache/include/libvarnish.h
branches/2.0/varnish-cache/lib/libvarnish/argv.c
Log:
Merge r4219, r4220: Fix backslash parsing in varnishtest
r4219:
Expose the good string backslash implementation from argv.c and
replace a half-baked one in vtc.c with it.
r4220:
Add a newline to feed the new backslash handler
Modified: branches/2.0/varnish-cache/bin/varnishtest/tests/c00001.vtc
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/c00001.vtc 2009-10-08 15:01:02 UTC (rev 4312)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/c00001.vtc 2009-10-08 15:12:41 UTC (rev 4313)
@@ -36,7 +36,7 @@
expect resp.http.snafu2 == "_frap_"
expect resp.http.snafu3 == "_f\\rap_"
expect resp.http.snafu4 == "_f&rap_"
- expect resp.http.snafu5 == "_barffra\p_"
- # NB: have to escape the \\ in the next line
+ # NB: have to escape the \\ in the next two lines
+ expect resp.http.snafu5 == "_barffra\\p_"
expect resp.http.snafu6 == "_f&rap\\_"
} -run
Modified: branches/2.0/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/vtc.c 2009-10-08 15:01:02 UTC (rev 4312)
+++ branches/2.0/varnish-cache/bin/varnishtest/vtc.c 2009-10-08 15:12:41 UTC (rev 4313)
@@ -130,19 +130,9 @@
for (; *p != '\0'; p++) {
if (*p == '"')
break;
-
- if (*p == '\\' && p[1] == 'n') {
- *q++ = '\n';
- p++;
- } else if (*p == '\\' && p[1] == 'r') {
- *q++ = '\r';
- p++;
- } else if (*p == '\\' && p[1] == '\\') {
- *q++ = '\\';
- p++;
- } else if (*p == '\\' && p[1] == '"') {
- *q++ = '"';
- p++;
+ if (*p == '\\') {
+ p += BackSlash(p, q) - 1;
+ q++;
} else {
if (*p == '\n')
fprintf(stderr,
Modified: branches/2.0/varnish-cache/include/libvarnish.h
===================================================================
--- branches/2.0/varnish-cache/include/libvarnish.h 2009-10-08 15:01:02 UTC (rev 4312)
+++ branches/2.0/varnish-cache/include/libvarnish.h 2009-10-08 15:12:41 UTC (rev 4313)
@@ -42,6 +42,8 @@
/* from libvarnish/argv.c */
void FreeArgv(char **argv);
char **ParseArgv(const char *s, int flag);
+char *BackSlashDecode(const char *s, const char *e);
+int BackSlash(const char *s, char *res);
#define ARGV_COMMENT (1 << 0)
#define ARGV_COMMA (1 << 1)
Modified: branches/2.0/varnish-cache/lib/libvarnish/argv.c
===================================================================
--- branches/2.0/varnish-cache/lib/libvarnish/argv.c 2009-10-08 15:01:02 UTC (rev 4312)
+++ branches/2.0/varnish-cache/lib/libvarnish/argv.c 2009-10-08 15:12:41 UTC (rev 4313)
@@ -43,11 +43,12 @@
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <stdint.h>
#include "libvarnish.h"
-static int
+int
BackSlash(const char *s, char *res)
{
int r;
@@ -103,13 +104,16 @@
return (r);
}
-static char *
+char *
BackSlashDecode(const char *s, const char *e)
{
const char *q;
char *p, *r;
int i;
+ if (e == NULL)
+ e = strchr(s, '\0');
+ assert(e != NULL);
p = calloc((e - s) + 1, 1);
if (p == NULL)
return (p);
More information about the varnish-commit
mailing list