Mercurial > urweb
diff 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 |
line wrap: on
line diff
--- a/src/compiler.sml Wed Dec 15 09:42:35 2010 -0500 +++ b/src/compiler.sml Thu Dec 16 09:59:05 2010 -0500 @@ -794,7 +794,19 @@ val anyErrors = ref false fun checkErrors () = anyErrors := (!anyErrors orelse ErrorMsg.anyErrors ()) - fun nameOf fname = capitalize (OS.Path.file fname) + fun nameOf fname = + let + val fname = OS.Path.file fname + val fst = if size fname = 0 then #"!" else String.sub (fname, 0) + in + if not (Char.isAlpha fst) then + ErrorMsg.error ("Filename doesn't start with letter: " ^ fname) + else if CharVector.exists (fn ch => not (Char.isAlphaNum ch) andalso ch <> #"_") fname then + ErrorMsg.error ("Filename contains a character that isn't alphanumeric or underscore: " ^ fname) + else + (); + capitalize fname + end fun parseFfi fname = let