# HG changeset patch # User Adam Chlipala # Date 1393364044 18000 # Node ID 7075acda4456216360b7107f915dd41880778c4a # Parent 7db8356caef57b0572d34bdd16629ef7a53ee848 Parse new bytea output format from Postgres 9.x diff -r 7db8356caef5 -r 7075acda4456 src/c/urweb.c --- a/src/c/urweb.c Thu Feb 20 15:50:33 2014 -0500 +++ b/src/c/urweb.c Tue Feb 25 16:34:04 2014 -0500 @@ -3049,27 +3049,39 @@ uw_check_heap(ctx, len); - while (*s) { - if (s[0] == '\\') { - if (s[1] == '\\') { - *r++ = '\\'; - s += 2; - } else if (isdigit((int)s[1]) && isdigit((int)s[2]) && isdigit((int)s[3])) { - *r++ = (s[1] - '0') * 8 * 8 + ((s[2] - '0') * 8) + (s[3] - '0'); - s += 4; - } - else { - *r++ = '\\'; + if (s[0] == '\\' && s[1] == 'x') { + s += 2; + + while (*s) { + int n; + sscanf(s, "%02x", &n); + *r++ = n; + s += 2; + } + } else { + while (*s) { + if (s[0] == '\\') { + if (s[1] == '\\') { + *r++ = '\\'; + s += 2; + } else if (isdigit((int)s[1]) && isdigit((int)s[2]) && isdigit((int)s[3])) { + *r++ = (s[1] - '0') * 8 * 8 + ((s[2] - '0') * 8) + (s[3] - '0'); + s += 4; + } + else { + *r++ = '\\'; + ++s; + } + } else { + *r++ = s[0]; ++s; } - } else { - *r++ = s[0]; - ++s; } } b.size = r - ctx->heap.front; ctx->heap.front = r; + return b; }