diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-05-30 09:31:50 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-05-30 09:31:50 -0400 |
commit | ce09df0fd2af2465c1df0fbeacf0cb6a07cd2add (patch) | |
tree | fbcc9d6f1fc4ec715af7af96f489195487cc4fc0 /src/c | |
parent | 8fa4027917a95498a0b354e614aaad7e0210e2d7 (diff) |
Fix bug with string literals in unAs
Diffstat (limited to 'src/c')
-rw-r--r-- | src/c/urweb.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 1edf47e0..865ce024 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3562,7 +3562,7 @@ __attribute__((noreturn)) void uw_redirect(uw_context ctx, uw_Basis_string url) } uw_Basis_string uw_Basis_unAs(uw_context ctx, uw_Basis_string s) { - uw_Basis_string r = uw_malloc(ctx, strlen(s) + 1); + uw_Basis_string ret = uw_malloc(ctx, strlen(s) + 1), r = ret; for (; *s; ++s) { if (s[0] == '\'') { @@ -3572,27 +3572,21 @@ uw_Basis_string uw_Basis_unAs(uw_context ctx, uw_Basis_string s) { *r++ = '\''; break; } else if (s[0] == '\\') { - if (s[1] == '\\') { - *r++ = '\\'; - *r++ = '\\'; - ++s; - } else if (s[1] == '\'') { - *r++ = '\\'; - *r++ = '\''; - ++s; - } else - *r++ = '\''; + *r++ = '\\'; + *r++ = s[1]; + ++s; } else *r++ = s[0]; } if (*s == 0) break; - } else if (s[0] == 'T' && s[1] == '.') - ++s; + } else if (s[0] == 'T' && s[1] == '_' && s[2] == 'T' && s[3] == '.') + s += 3; else *r++ = s[0]; } - return r; + *r = 0; + return ret; } uw_Basis_string uw_Basis_mstrcat(uw_context ctx, ...) { |