From 23b1f6b511c89c4916b65b466622a6dcdf1bb332 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 12 Jul 2009 15:05:40 -0400 Subject: MySQL demo/sql succeeds in reading no rows --- src/c/urweb.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/c/urweb.c') diff --git a/src/c/urweb.c b/src/c/urweb.c index f088e74d..4b92c2b4 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -2742,3 +2742,38 @@ __attribute__((noreturn)) void uw_return_blob(uw_context ctx, uw_Basis_blob b, u longjmp(ctx->jmp_buf, RETURN_BLOB); } + +uw_Basis_string uw_Basis_unAs(uw_context ctx, uw_Basis_string s) { + uw_Basis_string r = uw_malloc(ctx, strlen(s) + 1); + + for (; *s; ++s) { + if (s[0] == '\'') { + *r++ = '\''; + for (++s; *s; ++s) { + if (s[0] == '\'') { + *r++ = '\''; + break; + } else if (s[0] == '\\') { + if (s[1] == '\\') { + *r++ = '\\'; + *r++ = '\\'; + ++s; + } else if (s[1] == '\'') { + *r++ = '\\'; + *r++ = '\''; + ++s; + } else + *r++ = '\''; + } else + *r++ = s[0]; + } + if (*s == 0) break; + } else if (s[0] == 'T' && s[1] == '.') + ++s; + else + *r++ = s[0]; + } + + return r; +} + -- cgit v1.2.3