aboutsummaryrefslogtreecommitdiffstats
path: root/driver/Driveraux.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-07-21 14:39:00 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-07-21 14:39:00 +0200
commit0a38e7727f3c38742704907e0c4dc60da6b99743 (patch)
treec77e9cc64adb350459f71d8937d0895555b93772 /driver/Driveraux.ml
parentf22c32dcda0e8b546e85e8ad95d0ad655e365d38 (diff)
downloadcompcert-kvx-0a38e7727f3c38742704907e0c4dc60da6b99743.tar.gz
compcert-kvx-0a38e7727f3c38742704907e0c4dc60da6b99743.zip
Added support for quoting for diab backend.
The diab data compiler has different quoting conventions compared to the gnu tools. Bug 18308.
Diffstat (limited to 'driver/Driveraux.ml')
-rw-r--r--driver/Driveraux.ml18
1 files changed, 17 insertions, 1 deletions
diff --git a/driver/Driveraux.ml b/driver/Driveraux.ml
index 6bd48344..1ee39e8e 100644
--- a/driver/Driveraux.ml
+++ b/driver/Driveraux.ml
@@ -69,14 +69,30 @@ let gnu_quote arg =
Buffer.add_char buf c) arg;
Buffer.contents buf
+let re_whitespace = Str.regexp ".*[ \t\n\r]"
+
+let diab_quote arg =
+ let buf = Buffer.create ((String.length arg) + 8) in
+ let doublequote = Str.string_match re_whitespace arg 0 in
+ if doublequote then Buffer.add_char buf '"';
+ String.iter (fun c ->
+ if c = '"' then Buffer.add_char buf '\\';
+ Buffer.add_char buf c) arg;
+ if doublequote then Buffer.add_char buf '"';
+ Buffer.contents buf
+
let command ?stdout args =
let resp = Sys.win32 && Configuration.response_file_style <> Configuration.Unsupported in
if resp && List.fold_left (fun len arg -> len + String.length arg + 1) 0 args > 7000 then
+ let quote = match Configuration.response_file_style with
+ | Configuration.Unsupported -> assert false
+ | Configuration.Gnu -> gnu_quote
+ | Configuration.Diab -> diab_quote in
let file,oc = Filename.open_temp_file "compcert" "" in
let cmd,args = match args with
| cmd::args -> cmd,args
| [] -> assert false (* Should never happen *) in
- List.iter (fun a -> Printf.fprintf oc "%s " (gnu_quote a)) args;
+ List.iter (fun a -> Printf.fprintf oc "%s " (quote a)) args;
close_out oc;
let arg = if gnu_system then "@"^file else "-@"^file in
let ret = command stdout [cmd;arg] in