diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-11-01 10:20:20 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-11-01 10:20:20 -0500 |
commit | e20e964083a048ad4cbb88cc1af3790694f51dfa (patch) | |
tree | 09a704610f44afd4ad023245a9f59d901c3c4345 /src | |
parent | 1be7e54fa70a40b16164f69e7153ada0e4935994 (diff) |
Bidding interface
Diffstat (limited to 'src')
-rw-r--r-- | src/c/urweb.c | 41 | ||||
-rw-r--r-- | src/cjr_print.sml | 16 | ||||
-rw-r--r-- | src/corify.sml | 4 |
3 files changed, 48 insertions, 13 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 7dd6d222..3cf8fd47 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -1668,14 +1668,16 @@ uw_Basis_time uw_Basis_unurlifyTime(uw_context ctx, char **s) { return uw_Basis_unurlifyInt(ctx, s); } -static uw_Basis_string uw_unurlifyString_to(uw_context ctx, char *r, char *s) { +static uw_Basis_string uw_unurlifyString_to(int fromClient, uw_context ctx, char *r, char *s) { char *s1, *s2 = s; int n; - if (*s2 == '_') - ++s2; - else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F')) - s2 += 3; + if (!fromClient) { + if (*s2 == '_') + ++s2; + else if (s2[0] == '%' && s2[1] == '5' && (s2[2] == 'f' || s2[2] == 'F')) + s2 += 3; + } for (s1 = r; *s2; ++s1, ++s2) { char c = *s2; @@ -1724,7 +1726,21 @@ uw_Basis_string uw_Basis_unurlifyString(uw_context ctx, char **s) { uw_check_heap(ctx, len + 1); r = ctx->heap.front; - ctx->heap.front = uw_unurlifyString_to(ctx, ctx->heap.front, *s); + ctx->heap.front = uw_unurlifyString_to(0, ctx, ctx->heap.front, *s); + *s = new_s; + return r; +} + +uw_Basis_string uw_Basis_unurlifyString_fromClient(uw_context ctx, char **s) { + char *new_s = uw_unurlify_advance(*s); + char *r, *s1, *s2; + int len, n; + + len = strlen(*s); + uw_check_heap(ctx, len + 1); + + r = ctx->heap.front; + ctx->heap.front = uw_unurlifyString_to(1, ctx, ctx->heap.front, *s); *s = new_s; return r; } @@ -1963,6 +1979,19 @@ uw_Basis_string uw_Basis_substring(uw_context ctx, uw_Basis_string s, uw_Basis_i } +uw_Basis_string uw_Basis_str1(uw_context ctx, uw_Basis_char ch) { + char *r; + + uw_check_heap(ctx, 2); + r = ctx->heap.front; + r[0] = ch; + r[1] = 0; + + ctx->heap.front += 2; + + return r; +} + uw_Basis_string uw_strdup(uw_context ctx, uw_Basis_string s1) { int len = uw_Basis_strlen(ctx, s1) + 1; char *s; diff --git a/src/cjr_print.sml b/src/cjr_print.sml index d63c9099..164035eb 100644 --- a/src/cjr_print.sml +++ b/src/cjr_print.sml @@ -561,11 +561,15 @@ fun capitalize s = else str (Char.toUpper (String.sub (s, 0))) ^ String.extract (s, 1, NONE) -fun unurlify env (t, loc) = +fun unurlify fromClient env (t, loc) = let fun unurlify' rf t = case t of - TFfi ("Basis", "unit") => string ("uw_unit_v") + TFfi ("Basis", "unit") => string "uw_unit_v" + | TFfi ("Basis", "string") => string (if fromClient then + "uw_Basis_unurlifyString_fromClient(ctx, &request)" + else + "uw_Basis_unurlifyString(ctx, &request)") | TFfi (m, t) => string ("uw_" ^ ident m ^ "_unurlify" ^ capitalize t ^ "(ctx, &request)") | TRecord 0 => string "uw_unit_v" @@ -1835,7 +1839,7 @@ fun p_exp' par env (e, loc) = let fun getIt () = if isUnboxable t then - unurlify env t + unurlify false env t else box [string "({", newline, @@ -1845,7 +1849,7 @@ fun p_exp' par env (e, loc) = string "));", newline, string "*tmp = ", - unurlify env t, + unurlify false env t, string ";", newline, string "tmp;", @@ -2441,7 +2445,7 @@ fun p_file env (ds, ps) = space, string "=", space, - unurlify env t, + unurlify true env t, string ";", newline] end @@ -2599,7 +2603,7 @@ fun p_file env (ds, ps) = space, string "=", space, - unurlify env t, + unurlify false env t, string ";", newline]) ts), defInputs, diff --git a/src/corify.sml b/src/corify.sml index a4979790..9bf322f3 100644 --- a/src/corify.sml +++ b/src/corify.sml @@ -43,8 +43,10 @@ fun doRestify k (mods, s) = String.extract (s, 5, NONE) else s + val s = String.concatWith "/" (rev (s :: mods)) + val s = String.implode (List.filter (fn ch => ch <> #"$") (String.explode s)) in - Settings.rewrite k (String.concatWith "/" (rev (s :: mods))) + Settings.rewrite k s end val relify = CharVector.map (fn #"/" => #"_" |