changeset 943:e2194a6793ae

Fix JavaScript char literals; don't generate demo links to nonexistent files
author Adam Chlipala <adamc@hcoop.net>
date Tue, 15 Sep 2009 13:07:57 -0400
parents 280f81731426
children da3ec6014d2f
files demo/more/grid.ur demo/more/grid.urs src/demo.sml src/jscomp.sml
diffstat 4 files changed, 32 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/demo/more/grid.ur	Tue Sep 15 12:41:54 2009 -0400
+++ b/demo/more/grid.ur	Tue Sep 15 13:07:57 2009 -0400
@@ -84,7 +84,7 @@
     fun render grid = <xml>
       <table class={tabl}>
         <tr class={tr}>
-          <th/> <th/>
+          <th/> <th/> <th/>
           {foldRX2 [fst] [colMeta M.row] [_]
                    (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest]
                                     data (meta : colMeta M.row p) =>
--- a/demo/more/grid.urs	Tue Sep 15 12:41:54 2009 -0400
+++ b/demo/more/grid.urs	Tue Sep 15 13:07:57 2009 -0400
@@ -47,4 +47,5 @@
     style tr
     style th
     style td
+    style agg
 end
--- a/src/demo.sml	Tue Sep 15 12:41:54 2009 -0400
+++ b/src/demo.sml	Tue Sep 15 13:07:57 2009 -0400
@@ -197,7 +197,8 @@
                                                                         ext = SOME s}
                                          val src' = OS.Path.file src
                                      in
-                                         if OS.FileSys.access (src, []) then
+                                         if String.isPrefix (OS.Path.mkCanonical dirname) src
+                                            andalso OS.FileSys.access (src, []) then
                                              (TextIO.output (out, " | <a target=\"showcase\" href=\"");
                                               TextIO.output (out, src');
                                               TextIO.output (out, ".html\"><tt>");
--- a/src/jscomp.sml	Tue Sep 15 12:41:54 2009 -0400
+++ b/src/jscomp.sml	Tue Sep 15 13:07:57 2009 -0400
@@ -537,34 +537,34 @@
                         val strcat = strcat loc
 
                         fun jsPrim p =
-                            case p of
-                                Prim.String s =>
-                                str ("\""
-                                     ^ String.translate (fn #"'" =>
-                                                            if mode = Attribute then
-                                                                "\\047"
-                                                            else
-                                                                "'"
-                                                          | #"\"" => "\\\""
-                                                          | #"<" =>
-                                                            (*if mode = Script then
-                                                                "<"
-                                                            else*)
-                                                                "\\074"
-                                                          | #"\\" => "\\\\"
-                                                          | #"\n" => "\\n"
-                                                          | #"\r" => "\\r"
-                                                          | #"\t" => "\\t"
-                                                          | ch =>
-                                                            if Char.isPrint ch then
-                                                                String.str ch
-                                                            else
-                                                                "\\" ^ padWith (#"0",
-                                                                                Int.fmt StringCvt.OCT (ord ch),
-                                                                                3)) s
-                                     ^ "\"")
-                              | Prim.Char ch => str ("'" ^ String.str ch ^ "'")
-                              | _ => str (Prim.toString p)
+                            let
+                                fun jsChar ch =
+                                    case ch of
+                                        #"'" =>
+                                        if mode = Attribute then
+                                            "\\047"
+                                        else
+                                            "'"
+                                      | #"\"" => "\\\""
+                                      | #"<" => "\\074"
+                                      | #"\\" => "\\\\"
+                                      | #"\n" => "\\n"
+                                      | #"\r" => "\\r"
+                                      | #"\t" => "\\t"
+                                      | ch =>
+                                        if Char.isPrint ch then
+                                            String.str ch
+                                        else
+                                            "\\" ^ padWith (#"0",
+                                                            Int.fmt StringCvt.OCT (ord ch),
+                                                            3)
+                            in
+                                case p of
+                                    Prim.String s =>
+                                    str ("\"" ^ String.translate jsChar s ^ "\"")
+                                  | Prim.Char ch => str ("'" ^ jsChar ch ^ "'")
+                                  | _ => str (Prim.toString p)
+                            end
 
                         fun jsPat depth inner (p, _) succ fail =
                             case p of