[m-rev.] for post commit review: fix mmc --split-c-files

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Apr 1 14:48:06 AEST 2004


For review by Fergus.

compiler/compile_target_code.m:
	Fix a bug that prevented a single invocation of mmc from compiling
	a program with --split-c-files. The problem was the quoting of a word
	containing a wildcard in a shell command, preventing it from expanding
	to multiple words.

Zoltan.

Index: compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.57
diff -u -b -r1.57 compile_target_code.m
--- compile_target_code.m	19 Mar 2004 14:23:02 -0000	1.57
+++ compile_target_code.m	31 Mar 2004 04:34:55 -0000
@@ -850,7 +850,7 @@
 			SplitLibFileName, !IO),
 		string__append(".dir/*", Obj, DirObj),
 		join_module_list(Modules, DirObj, ObjectList, !IO),
-		create_archive(OutputStream, SplitLibFileName,
+		create_archive(OutputStream, SplitLibFileName, no,
 			ObjectList, MakeLibCmdOK, !IO),
 		ObjectsList = [SplitLibFileName]
 	;
@@ -1063,7 +1063,7 @@
 		Ext = LibExt,
 		module_name_to_lib_file_name("lib", ModuleName, LibExt, yes,
 			OutputFileName, !IO),
-		create_archive(ErrorStream, OutputFileName, ObjectsList,
+		create_archive(ErrorStream, OutputFileName, yes, ObjectsList,
 			LinkSucceeded, !IO)
 	; LinkTargetType = java_archive ->
 		Ext = ".jar",
@@ -1538,10 +1538,10 @@
 		LinkerOpt = "-l" ++ LibName
 	).
 
-:- pred create_archive(io__output_stream::in, file_name::in,
+:- pred create_archive(io__output_stream::in, file_name::in, bool::in,
 	list(file_name)::in, bool::out, io::di, io::uo) is det.
 
-create_archive(ErrorStream, LibFileName, ObjectList, Succeeded, !IO) :-
+create_archive(ErrorStream, LibFileName, Quote, ObjectList, Succeeded, !IO) :-
 	globals__io_lookup_string_option(create_archive_command, ArCmd, !IO),
 	globals__io_lookup_accumulating_option(
 		create_archive_command_flags, ArFlagsList, !IO),
@@ -1549,7 +1549,16 @@
 	globals__io_lookup_string_option(
 		create_archive_command_output_flag, ArOutputFlag, !IO),
 	globals__io_lookup_string_option(ranlib_command, RanLib, !IO),
-	join_quoted_string_list(ObjectList, "", "", " ", Objects),
+	(
+		Quote = yes,
+		join_quoted_string_list(ObjectList, "", "", " ", Objects)
+	;
+		Quote = no,
+		% Elements of ObjectList may contain shell wildcards, which
+		% are intended to cause the element to expand to several words.
+		% Quoting would prevent that.
+		join_string_list(ObjectList, "", "", " ", Objects)
+	),
 	MakeLibCmd = string__append_list([
 		ArCmd, " ", ArFlags, " ", ArOutputFlag, " ",
 		LibFileName, " ", Objects]),
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list