Commit 39694dfa authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Expose the good string backslash implementation from argv.c and

replace a half-baked one in vtc.c with it.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4219 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent ed02f4f0
......@@ -133,19 +133,9 @@ parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl)
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,
......
......@@ -42,6 +42,8 @@ struct vsb;
/* 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)
......
......@@ -44,11 +44,12 @@ SVNID("$Id$")
#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;
......@@ -104,13 +105,16 @@ BackSlash(const char *s, char *res)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment