Mercurial > urweb
comparison src/compiler.sml @ 1343:0a2b630f2463
Enforce character constraints on source filenames
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 16 Dec 2010 09:59:05 -0500 |
parents | caff0a4d5fc1 |
children | fd34210bc3e5 |
comparison
equal
deleted
inserted
replaced
1342:78fe9841c39d | 1343:0a2b630f2463 |
---|---|
792 let | 792 let |
793 val mrs = !moduleRoots | 793 val mrs = !moduleRoots |
794 | 794 |
795 val anyErrors = ref false | 795 val anyErrors = ref false |
796 fun checkErrors () = anyErrors := (!anyErrors orelse ErrorMsg.anyErrors ()) | 796 fun checkErrors () = anyErrors := (!anyErrors orelse ErrorMsg.anyErrors ()) |
797 fun nameOf fname = capitalize (OS.Path.file fname) | 797 fun nameOf fname = |
798 let | |
799 val fname = OS.Path.file fname | |
800 val fst = if size fname = 0 then #"!" else String.sub (fname, 0) | |
801 in | |
802 if not (Char.isAlpha fst) then | |
803 ErrorMsg.error ("Filename doesn't start with letter: " ^ fname) | |
804 else if CharVector.exists (fn ch => not (Char.isAlphaNum ch) andalso ch <> #"_") fname then | |
805 ErrorMsg.error ("Filename contains a character that isn't alphanumeric or underscore: " ^ fname) | |
806 else | |
807 (); | |
808 capitalize fname | |
809 end | |
798 | 810 |
799 fun parseFfi fname = | 811 fun parseFfi fname = |
800 let | 812 let |
801 val mname = nameOf fname | 813 val mname = nameOf fname |
802 val urs = OS.Path.joinBaseExt {base = fname, ext = SOME "urs"} | 814 val urs = OS.Path.joinBaseExt {base = fname, ext = SOME "urs"} |