comparison src/c/urweb.c @ 566:a152905c3c3b

Displayed an alert dialog
author Adam Chlipala <adamc@hcoop.net>
date Fri, 19 Dec 2008 12:38:11 -0500
parents 74800be65591
children ac947e2f29ff
comparison
equal deleted inserted replaced
565:74800be65591 566:a152905c3c3b
1052 1052
1053 if (b == uw_Basis_False) 1053 if (b == uw_Basis_False)
1054 return (char *)&false; 1054 return (char *)&false;
1055 else 1055 else
1056 return (char *)&true; 1056 return (char *)&true;
1057 }
1058
1059 uw_Basis_string uw_Basis_jsifyString(uw_context ctx, uw_Basis_string s) {
1060 char *r, *s2;
1061
1062 uw_check_heap(ctx, strlen(s) * 4 + 2);
1063
1064 r = s2 = ctx->heap_front;
1065 *s2++ = '"';
1066
1067 for (; *s; s++) {
1068 char c = *s;
1069
1070 switch (c) {
1071 case '"':
1072 strcpy(s2, "\\\"");
1073 s2 += 2;
1074 break;
1075 case '\\':
1076 strcpy(s2, "\\\\");
1077 s2 += 2;
1078 break;
1079 default:
1080 if (isprint(c))
1081 *s2++ = c;
1082 else {
1083 sprintf(s2, "\\%3o", c);
1084 s2 += 4;
1085 }
1086 }
1087 }
1088
1089 strcpy(s2, "\"");
1090 ctx->heap_front = s2 + 1;
1091 return r;
1057 } 1092 }
1058 1093
1059 uw_Basis_string uw_Basis_intToString(uw_context ctx, uw_Basis_int n) { 1094 uw_Basis_string uw_Basis_intToString(uw_context ctx, uw_Basis_int n) {
1060 int len; 1095 int len;
1061 char *r; 1096 char *r;