diff options
author | 2010-12-16 09:59:05 -0500 | |
---|---|---|
committer | 2010-12-16 09:59:05 -0500 | |
commit | 6219b399b733fd772fbcc25bd52c4f7e50060728 (patch) | |
tree | 3246a73484143c37254ad608c0fc7df8deeb78fa | |
parent | edea99a45b84ac6ecf30f8de295d82926462e044 (diff) |
Enforce character constraints on source filenames
-rw-r--r-- | src/compiler.sml | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler.sml b/src/compiler.sml index 9a25902a..67c94d91 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -794,7 +794,19 @@ val parse = { 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 |