diff options
author | Adam Chlipala <adam@chlipala.net> | 2010-12-16 09:59:05 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2010-12-16 09:59:05 -0500 |
commit | 2f3feff2f4a07142cad598e853a63ac11e33aad0 (patch) | |
tree | 3246a73484143c37254ad608c0fc7df8deeb78fa | |
parent | 298faea77aa1fee68084f30dc385b08bb103f3eb (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 |