summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar fab <fabrice.leal.ch@gmail.com>2019-01-21 20:17:56 +0000
committerGravatar fab <fabrice.leal.ch@gmail.com>2019-01-21 20:17:56 +0000
commit0844858d23b5a0d695ad719a650e755cc21a235c (patch)
tree7759fcabbf8aad31aa51a42f09b12bbe359a9929
parent1448db1b509db4a897a5fb11a8d35ec643d82b50 (diff)
fixes for review 1
-rw-r--r--lib/js/urweb.js1
-rw-r--r--src/mono_opt.sml58
2 files changed, 30 insertions, 29 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 6b493c4f..357e4c1c 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -7,6 +7,7 @@ function needsDynPrefix() {
return scripts.length == 0;
}
+// Codepoint implementations brought from https://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/#String
if (!String.fromCodePoint) {
String.fromCodePoint = function () {
var chars = [], i;
diff --git a/src/mono_opt.sml b/src/mono_opt.sml
index 218be1ba..cc85f05b 100644
--- a/src/mono_opt.sml
+++ b/src/mono_opt.sml
@@ -68,9 +68,9 @@ fun htmlifySpecialChar ch = "&#" ^ Int.toString (ord ch) ^ ";"
fun hexPad c =
let
- val s = Int.fmt StringCvt.HEX c
+ val s = Int.fmt StringCvt.HEX c
in
- case size s of
+ case size s of
0 => "00"
| 1 => "0" ^ s
| _ => s
@@ -88,42 +88,42 @@ fun andb a b =
fun hexIt ch =
let
- val c = ord ch
+ val c = ord ch
in
- if (c <= 0x7f) then
- hexPad c
- else
- ((if (c <= 0x7fff) then
- hexPad (orb (rsh c 6) 0xc0)
- else
- (if (c <= 0xffff) then
- hexPad (orb (rsh c 12) 0xe0)
- else
- hexPad (orb (rsh c 18) 0xf0)
- ^ hexPad (orb (andb (rsh c 12) 0x3f) 0x80)
- )
- ^ hexPad (orb (andb (rsh c 6) 0x3f) 0x80))
- ) ^ hexPad (orb (andb c 0x3f) 0x80)
+ if (c <= 0x7f) then
+ hexPad c
+ else
+ ((if (c <= 0x7fff) then
+ hexPad (orb (rsh c 6) 0xc0)
+ else
+ (if (c <= 0xffff) then
+ hexPad (orb (rsh c 12) 0xe0)
+ else
+ hexPad (orb (rsh c 18) 0xf0)
+ ^ hexPad (orb (andb (rsh c 12) 0x3f) 0x80)
+ )
+ ^ hexPad (orb (andb (rsh c 6) 0x3f) 0x80))
+ ) ^ hexPad (orb (andb c 0x3f) 0x80)
end
fun urlifyCharAux ch =
case ch of
- #" " => "+"
+ #" " => "+"
| _ =>
- if ord ch = 0 then
- "_"
- else
- if Char.isAlphaNum ch then
- str ch
+ if ord ch = 0 then
+ "_"
+ else
+ if Char.isAlphaNum ch then
+ str ch
else
- "." ^ hexIt ch
-
+ "." ^ hexIt ch
+
fun urlifyChar c =
case c of
- #"_" => "_" ^ urlifyCharAux c
+ #"_" => "_" ^ urlifyCharAux c
| _ => urlifyCharAux c
-
-
+
+
fun urlifyString s =
case s of
"" => "_"
@@ -399,7 +399,7 @@ fun exp e =
EWrite (EPrim (Prim.String (Prim.Normal, urlifyChar c)), loc)
| EWrite (EFfiApp ("Basis", "urlifyChar", [e]), _) =>
EFfiApp ("Basis", "urlifyChar_w", [e])
-
+
| EFfiApp ("Basis", "urlifyBool", [((ECon (Enum, PConFfi {con = "True", ...}, NONE), _), _)]) =>
EPrim (Prim.String (Prim.Normal, "1"))
| EFfiApp ("Basis", "urlifyBool", [((ECon (Enum, PConFfi {con = "False", ...}, NONE), _), _)]) =>