diff options
author | 2009-11-01 14:26:20 -0500 | |
---|---|---|
committer | 2009-11-01 14:26:20 -0500 | |
commit | 7560a81cd846d47d3d4d642cc470e3b09c5e1826 (patch) | |
tree | 554465c7355d6fe0d310a16f4a7fa5a4e0675870 /src/c/urweb.c | |
parent | 1beaf9527c0b6ab4b2f06267966e9e89a26550ff (diff) |
Initial form for paper assignment
Diffstat (limited to 'src/c/urweb.c')
-rw-r--r-- | src/c/urweb.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 3cf8fd47..8d63d174 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -1232,6 +1232,37 @@ uw_Basis_string uw_Basis_jsifyString(uw_context ctx, uw_Basis_string s) { return r; } +uw_Basis_string uw_Basis_jsifyChar(uw_context ctx, uw_Basis_char c) { + char *r, *s2; + + uw_check_heap(ctx, 6); + + r = s2 = ctx->heap.front; + *s2++ = '"'; + + 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 + 2; + return r; +} + uw_Basis_string uw_Basis_jsifyString_ws(uw_context ctx, uw_Basis_string s) { char *r, *s2; |