diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-09-15 13:07:57 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-09-15 13:07:57 -0400 |
commit | 8e944e62818045b820f45776a396bc1b66ab3056 (patch) | |
tree | 2790236bfd930177b19eec97fc9ac1d47e9dd7d4 /src | |
parent | 69bdeb0e79c7b33260111c6c6eae332d37d28d0e (diff) |
Fix JavaScript char literals; don't generate demo links to nonexistent files
Diffstat (limited to 'src')
-rw-r--r-- | src/demo.sml | 3 | ||||
-rw-r--r-- | src/jscomp.sml | 56 |
2 files changed, 30 insertions, 29 deletions
diff --git a/src/demo.sml b/src/demo.sml index ebdf4e40..4e2caa99 100644 --- a/src/demo.sml +++ b/src/demo.sml @@ -197,7 +197,8 @@ fun make {prefix, dirname, guided} = 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>"); diff --git a/src/jscomp.sml b/src/jscomp.sml index 178591b5..ca4f047b 100644 --- a/src/jscomp.sml +++ b/src/jscomp.sml @@ -537,34 +537,34 @@ fun process file = 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 |