diff src/compiler.sml @ 1473:d40066b38710

Handle spaces in filenames passed to GCC (caught by Zachary Tatlock)
author Adam Chlipala <adam@chlipala.net>
date Wed, 15 Jun 2011 09:52:06 -0400
parents 2f5fd248588d
children 3d0cc841cafd
line wrap: on
line diff
--- a/src/compiler.sml	Tue Jun 14 08:54:45 2011 -0400
+++ b/src/compiler.sml	Wed Jun 15 09:52:06 2011 -0400
@@ -1307,6 +1307,8 @@
 
 val toSqlify = transform sqlify "sqlify" o toMono_opt2
 
+val escapeFilename = String.translate (fn #" " => "\\ " | #"\"" => "\\\"" | #"'" => "\\'" | ch => str ch)
+
 fun compileC {cname, oname, ename, libs, profile, debug, link = link'} =
     let
         val proto = Settings.currentProtocol ()
@@ -1318,10 +1320,10 @@
 
         val compile = "gcc " ^ Config.gccArgs ^ " -Wimplicit -Werror -O3 -fno-inline -I " ^ Config.includ
                       ^ " " ^ #compile proto
-                      ^ " -c " ^ cname ^ " -o " ^ oname
+                      ^ " -c " ^ escapeFilename cname ^ " -o " ^ escapeFilename oname
 
-        val link = "gcc -Werror -O3 -lm -pthread " ^ Config.gccArgs ^ " " ^ lib ^ " " ^ Config.openssl ^ " " ^ oname
-                   ^ " -o " ^ ename ^ " " ^ libs
+        val link = "gcc -Werror -O3 -lm -pthread " ^ Config.gccArgs ^ " " ^ lib ^ " " ^ Config.openssl ^ " " ^ escapeFilename oname
+                   ^ " -o " ^ escapeFilename ename ^ " " ^ libs
 
         val (compile, link) =
             if profile then