aboutsummaryrefslogtreecommitdiffstats
path: root/driver/Driveraux.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-07-20 13:20:19 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-07-20 13:20:19 +0200
commitf22c32dcda0e8b546e85e8ad95d0ad655e365d38 (patch)
tree4a6c997c3a0692d10beed8d8b59488c962189148 /driver/Driveraux.ml
parent2129fe8f2e19c4dd91955e5300e76d924e0a3e6d (diff)
downloadcompcert-kvx-f22c32dcda0e8b546e85e8ad95d0ad655e365d38.tar.gz
compcert-kvx-f22c32dcda0e8b546e85e8ad95d0ad655e365d38.zip
Added simplified reader and printer for gnu @files
The functions expandargv and writeargv resemble the functions from the libiberity that are used by the gnu tools. Additionaly a new configuration is added in order to determine which kind of response files are supported for calls to other tools. Bug 18308
Diffstat (limited to 'driver/Driveraux.ml')
-rw-r--r--driver/Driveraux.ml21
1 files changed, 13 insertions, 8 deletions
diff --git a/driver/Driveraux.ml b/driver/Driveraux.ml
index 2c03c65c..6bd48344 100644
--- a/driver/Driveraux.ml
+++ b/driver/Driveraux.ml
@@ -58,20 +58,25 @@ let command stdout args =
argv.(0) fn (Unix.error_message err) param;
-1
-let quote arg =
- let whitespace = Str.regexp "[ \t\r\n]" in
- if Str.string_match whitespace arg 0 then
- Filename.quote arg (* We need to quote arguments containing whitespaces *)
- else
- arg
+(* This function reimplements quoting of writeargv from libiberty *)
+let gnu_quote arg =
+ let len = String.length arg in
+ let buf = Buffer.create len in
+ String.iter (fun c -> match c with
+ | ' ' | '\t' | '\r' | '\n' | '\\' | '\'' | '"' ->
+ Buffer.add_char buf '\\'
+ | _ -> ();
+ Buffer.add_char buf c) arg;
+ Buffer.contents buf
let command ?stdout args =
- if Sys.win32 && List.fold_left (fun len arg -> len + String.length arg + 1) 0 args > 7000 then
+ 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 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 " (quote a)) args;
+ List.iter (fun a -> Printf.fprintf oc "%s " (gnu_quote a)) args;
close_out oc;
let arg = if gnu_system then "@"^file else "-@"^file in
let ret = command stdout [cmd;arg] in