summaryrefslogtreecommitdiff
path: root/src/compiler.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-02-06 15:34:41 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-02-06 15:34:41 -0500
commita978113ec89492e3c612e2409b8dfd0f3c9682cb (patch)
tree030689d7f60d1b5a580b8c638f1c297899b068d7 /src/compiler.sml
parent0771f5711f1bfcd0b958049957f91289622e5f85 (diff)
Allow .urp files without initial blank lines
Diffstat (limited to 'src/compiler.sml')
-rw-r--r--src/compiler.sml25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index e72d8b4b..ab3ec10a 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -282,7 +282,25 @@ fun parseUrp' accLibs fname =
fun pu filename =
let
val dir = OS.Path.dir filename
- val inf = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"})
+ fun opener () = TextIO.openIn (OS.Path.joinBaseExt {base = filename, ext = SOME "urp"})
+
+ val inf = opener ()
+
+ fun hasAnyLine () =
+ case TextIO.inputLine inf of
+ NONE => false
+ | SOME "\n" => false
+ | _ => true
+
+ fun hasBlankLine () =
+ case TextIO.inputLine inf of
+ NONE => false
+ | SOME "\n" => hasAnyLine ()
+ | _ => hasBlankLine ()
+
+ val hasBlankLine = hasBlankLine ()
+
+ val inf = (TextIO.closeIn inf; opener ())
fun pathify fname =
if size fname > 0 andalso String.sub (fname, 0) = #"$" then
@@ -591,7 +609,10 @@ fun parseUrp' accLibs fname =
read ()
end
- val job = read ()
+ val job = if hasBlankLine then
+ read ()
+ else
+ finish (readSources [])
in
TextIO.closeIn inf;
Settings.setUrlPrefix (#prefix job);