diff options
author | 2014-02-25 16:34:04 -0500 | |
---|---|---|
committer | 2014-02-25 16:34:04 -0500 | |
commit | 79a91292adaa9cd76edaf986ffe6ac7e9093260c (patch) | |
tree | 2ef3745f6c69baf9965649bd3e881a75d54e2460 | |
parent | c3b5b20061b27b3533645def1a9cdea53eba2f83 (diff) |
Parse new bytea output format from Postgres 9.x
-rw-r--r-- | src/c/urweb.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 7ff8a262..9bf72ce1 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3049,27 +3049,39 @@ uw_Basis_blob uw_Basis_stringToBlob_error(uw_context ctx, uw_Basis_string s, siz 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; } |