diff src/c/urweb.c @ 1025:7facf72aaf0a

Initial form for paper assignment
author Adam Chlipala <adamc@hcoop.net>
date Sun, 01 Nov 2009 14:26:20 -0500
parents e46227efcbba
children be1aec7333a5
line wrap: on
line diff
--- a/src/c/urweb.c	Sun Nov 01 10:31:18 2009 -0500
+++ b/src/c/urweb.c	Sun Nov 01 14:26:20 2009 -0500
@@ -1232,6 +1232,37 @@
   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;