Commit 8f09fb58 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

FlexeLint inspired polishing:

Better choice of data types.



git-svn-id: http://www.varnish-cache.org/svn/trunk@2961 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 49da5759
......@@ -48,32 +48,33 @@
#include "libvarnish.h"
static int
BackSlash(const char *s, int *res)
BackSlash(const char *s, char *res)
{
int i, r;
int r;
char c;
unsigned u;
assert(*s == '\\');
r = i = 0;
r = c = 0;
switch(s[1]) {
case 'n':
i = '\n';
c = '\n';
r = 2;
break;
case 'r':
i = '\r';
c = '\r';
r = 2;
break;
case 't':
i = '\t';
c = '\t';
r = 2;
break;
case '"':
i = '"';
c = '"';
r = 2;
break;
case '\\':
i = '\\';
c = '\\';
r = 2;
break;
case '0': case '1': case '2': case '3':
......@@ -83,13 +84,14 @@ BackSlash(const char *s, int *res)
break;
if (s[r] - '0' > 7)
break;
i <<= 3;
i |= s[r] - '0';
c <<= 3; /*lint !e701 signed left shift */
c |= s[r] - '0';
}
break;
case 'x':
if (1 == sscanf(s + 1, "x%02x", &u)) {
i = u;
assert(!(u & ~0xff));
c = u; /*lint !e734 loss of precision */
r = 4;
}
break;
......@@ -97,7 +99,7 @@ BackSlash(const char *s, int *res)
break;
}
if (res != NULL)
*res = i;
*res = c;
return (r);
}
......@@ -106,7 +108,7 @@ BackSlashDecode(const char *s, const char *e)
{
const char *q;
char *p, *r;
int i, j;
int i;
p = calloc((e - s) + 1, 1);
if (p == NULL)
......@@ -116,9 +118,9 @@ BackSlashDecode(const char *s, const char *e)
*r++ = *q++;
continue;
}
i = BackSlash(q, &j);
i = BackSlash(q, r);
q += i;
*r++ = j;
r++;
}
*r = '\0';
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