diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-11-01 14:26:20 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-11-01 14:26:20 -0500 |
commit | 70da89d392d5c9649157e53944db9a49d2149da3 (patch) | |
tree | 554465c7355d6fe0d310a16f4a7fa5a4e0675870 /src/c | |
parent | 7aaaa9a22a7eede386cda3cfbb3fc906619415d9 (diff) |
Initial form for paper assignment
Diffstat (limited to 'src/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; |