comparison src/cjr_print.sml @ 1285:514be09d5018

Better UTF-8 escaping for JavaScript and SQL literals
author Adam Chlipala <adam@chlipala.net>
date Tue, 10 Aug 2010 15:55:43 -0400
parents be2ef50780ed
children acabf3935060
comparison
equal deleted inserted replaced
1284:43ca083678f8 1285:514be09d5018
2126 newline] 2126 newline]
2127 | DDatabase _ => box [] 2127 | DDatabase _ => box []
2128 | DPreparedStatements _ => box [] 2128 | DPreparedStatements _ => box []
2129 2129
2130 | DJavaScript s => box [string "static char jslib[] = \"", 2130 | DJavaScript s => box [string "static char jslib[] = \"",
2131 string (String.toString s), 2131 string (String.toCString s),
2132 string "\";"] 2132 string "\";"]
2133 | DCookie s => box [string "/*", 2133 | DCookie s => box [string "/*",
2134 space, 2134 space,
2135 string "cookie", 2135 string "cookie",
2136 space, 2136 space,
2583 prefix ^ String.extract (s, 1, NONE) 2583 prefix ^ String.extract (s, 1, NONE)
2584 else 2584 else
2585 prefix ^ s 2585 prefix ^ s
2586 in 2586 in
2587 box [string "if (!strncmp(request, \"", 2587 box [string "if (!strncmp(request, \"",
2588 string (String.toString s), 2588 string (String.toCString s),
2589 string "\", ", 2589 string "\", ",
2590 string (Int.toString (size s)), 2590 string (Int.toString (size s)),
2591 string ") && (request[", 2591 string ") && (request[",
2592 string (Int.toString (size s)), 2592 string (Int.toString (size s)),
2593 string "] == 0 || request[", 2593 string "] == 0 || request[",
2759 box [p_list_sep (box []) 2759 box [p_list_sep (box [])
2760 (fn rule => 2760 (fn rule =>
2761 box [string "if (!str", 2761 box [string "if (!str",
2762 case #kind rule of 2762 case #kind rule of
2763 Settings.Exact => box [string "cmp(s, \"", 2763 Settings.Exact => box [string "cmp(s, \"",
2764 string (String.toString (#pattern rule)), 2764 string (String.toCString (#pattern rule)),
2765 string "\"))"] 2765 string "\"))"]
2766 | Settings.Prefix => box [string "ncmp(s, \"", 2766 | Settings.Prefix => box [string "ncmp(s, \"",
2767 string (String.toString (#pattern rule)), 2767 string (String.toCString (#pattern rule)),
2768 string "\", ", 2768 string "\", ",
2769 string (Int.toString (size (#pattern rule))), 2769 string (Int.toString (size (#pattern rule))),
2770 string "))"], 2770 string "))"],
2771 string " return ", 2771 string " return ",
2772 string (case #action rule of 2772 string (case #action rule of