diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-12-19 12:38:11 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-12-19 12:38:11 -0500 |
commit | e478b4d432d65b33613a601f71204fc0c656c3db (patch) | |
tree | 120f43205b07cf55f8d1af41742dd275a4d863ca /src/c/urweb.c | |
parent | ed7c55c7d3d47e59b73cda4d1d7663bec6728934 (diff) |
Displayed an alert dialog
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r-- | src/c/urweb.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 7a9b3e79..64cdb81e 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -1056,6 +1056,41 @@ char *uw_Basis_ensqlBool(uw_Basis_bool b) { return (char *)&true; } +uw_Basis_string uw_Basis_jsifyString(uw_context ctx, uw_Basis_string s) { + char *r, *s2; + + uw_check_heap(ctx, strlen(s) * 4 + 2); + + r = s2 = ctx->heap_front; + *s2++ = '"'; + + for (; *s; s++) { + char c = *s; + + switch (c) { + case '"': + strcpy(s2, "\\\""); + s2 += 2; + break; + case '\\': + strcpy(s2, "\\\\"); + s2 += 2; + break; + default: + if (isprint(c)) + *s2++ = c; + else { + sprintf(s2, "\\%3o", c); + s2 += 4; + } + } + } + + strcpy(s2, "\""); + ctx->heap_front = s2 + 1; + return r; +} + uw_Basis_string uw_Basis_intToString(uw_context ctx, uw_Basis_int n) { int len; char *r; |