more escape handling

SVN revision: 16716
This commit is contained in:
Carsten Haitzler 2005-09-14 13:45:12 +00:00
parent 7141435c0d
commit f4337d5358
1 changed files with 17 additions and 16 deletions

View File

@ -1061,6 +1061,22 @@ _format_is_param(char *item)
return 0;
}
static char *
_str_deescape(char *str)
{
char *s2, *s, *d;
s2 = malloc(strlen(str) + 1);
if (!s2) return NULL;
for (s = str, d = s2; *s != 0; s++, d++)
{
if ((*s == '\\') && (s[1] != 0)) s++;
*d = *s;
}
*d = 0;
return s2;
}
static void
_format_param_parse(char *item, char **key, char **val)
{
@ -1074,22 +1090,7 @@ _format_param_parse(char *item, char **key, char **val)
k[p - item] = 0;
*key = k;
p++;
v = strdup(p);
pv = v;
for (;;)
{
if (*p == 0)
{
*pv = 0;
break;
}
else if (*p != '"')
{
*pv = *p;
}
pv++;
p++;
}
v = _str_deescape(p);
*val = v;
}