Mercurial > urweb
comparison src/c/urweb.c @ 1992:7075acda4456
Parse new bytea output format from Postgres 9.x
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Tue, 25 Feb 2014 16:34:04 -0500 |
parents | 819756825c8d |
children | 3d1d44111906 |
comparison
equal
deleted
inserted
replaced
1991:7db8356caef5 | 1992:7075acda4456 |
---|---|
3047 char *r = ctx->heap.front; | 3047 char *r = ctx->heap.front; |
3048 uw_Basis_blob b = {len, r}; | 3048 uw_Basis_blob b = {len, r}; |
3049 | 3049 |
3050 uw_check_heap(ctx, len); | 3050 uw_check_heap(ctx, len); |
3051 | 3051 |
3052 while (*s) { | 3052 if (s[0] == '\\' && s[1] == 'x') { |
3053 if (s[0] == '\\') { | 3053 s += 2; |
3054 if (s[1] == '\\') { | 3054 |
3055 *r++ = '\\'; | 3055 while (*s) { |
3056 s += 2; | 3056 int n; |
3057 } else if (isdigit((int)s[1]) && isdigit((int)s[2]) && isdigit((int)s[3])) { | 3057 sscanf(s, "%02x", &n); |
3058 *r++ = (s[1] - '0') * 8 * 8 + ((s[2] - '0') * 8) + (s[3] - '0'); | 3058 *r++ = n; |
3059 s += 4; | 3059 s += 2; |
3060 } | 3060 } |
3061 else { | 3061 } else { |
3062 *r++ = '\\'; | 3062 while (*s) { |
3063 if (s[0] == '\\') { | |
3064 if (s[1] == '\\') { | |
3065 *r++ = '\\'; | |
3066 s += 2; | |
3067 } else if (isdigit((int)s[1]) && isdigit((int)s[2]) && isdigit((int)s[3])) { | |
3068 *r++ = (s[1] - '0') * 8 * 8 + ((s[2] - '0') * 8) + (s[3] - '0'); | |
3069 s += 4; | |
3070 } | |
3071 else { | |
3072 *r++ = '\\'; | |
3073 ++s; | |
3074 } | |
3075 } else { | |
3076 *r++ = s[0]; | |
3063 ++s; | 3077 ++s; |
3064 } | 3078 } |
3065 } else { | |
3066 *r++ = s[0]; | |
3067 ++s; | |
3068 } | 3079 } |
3069 } | 3080 } |
3070 | 3081 |
3071 b.size = r - ctx->heap.front; | 3082 b.size = r - ctx->heap.front; |
3072 ctx->heap.front = r; | 3083 ctx->heap.front = r; |
3084 | |
3073 return b; | 3085 return b; |
3074 } | 3086 } |
3075 | 3087 |
3076 #define THE_PAST "expires=Sat, 01-Jan-2011 00:00:00 GMT" | 3088 #define THE_PAST "expires=Sat, 01-Jan-2011 00:00:00 GMT" |
3077 | 3089 |