[m-rev.] for review: config file variable substition fix

Peter Ross pro at missioncriticalit.com
Fri May 2 21:35:46 AEST 2003


Hi,

For stayl to review.

===================================================================


Estimated hours taken: 5
Branches: main

Fix a bug where the config file was being incorrectly parsed for
similar fragments to the one following.

MERCURY_C_COMPILER="gcc -no-cpp-precomp"
DEFAULT_MCFLAGS=--cc "$(MERCURY_C_COMPILER)"

The final string to be parsed for the above fragment was
DEFAULT_MCFLAGS=--cc ""gcc -no-cpp-precomp""
which ended up as
  ["-cc", "gcc", "-no-cpp-precomp"]
instead of 
  ["-cc", "gcc -no-cpp-precomp"]

This is because we incorrectly include the \" characters from
MERCURY_C_COMPILER when substituting the value of the variable.

compiler/options_file.m:
	The charlist representing the variable value shouldn't have
	any of the quoting characters in them.

Index: compiler/options_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options_file.m,v
retrieving revision 1.18
diff -u -r1.18 options_file.m
--- compiler/options_file.m	29 Apr 2003 05:25:08 -0000	1.18
+++ compiler/options_file.m	2 May 2003 11:27:30 -0000
@@ -381,12 +381,12 @@
 		{ Value = string__to_char_list(EnvValue) },
 		{ Words = split_into_words(Value) },
 		{ map__set(Variables0, VarName,
-			options_variable_value(string__to_char_list(EnvValue),
-				Words, environment),
+			options_variable_value(words_to_charlist(Words),
+					Words, environment),
 			Variables) }
 	;
 		{ map__search(Variables0, VarName,
-			options_variable_value(OldValue, OldWords, Source)) }
+			options_variable_value(_, OldWords, Source)) }
 	->
 		(
 			{ Source = environment },
@@ -397,20 +397,18 @@
 		;
 			{ Source = options_file },
 			{ AddToValue = yes ->
-				NewValue = OldValue ++ [' ' |  NewValue1],
 				Words = OldWords ++ Words1
 			;
-				NewValue = NewValue1,
 				Words = Words1
 			},
 			{ map__set(Variables0, VarName,
-				options_variable_value(NewValue,
+				options_variable_value(words_to_charlist(Words),
 					Words, options_file),
 				Variables) }
 		)
 	;
 		{ map__set(Variables0, VarName,
-			options_variable_value(NewValue1,
+			options_variable_value(words_to_charlist(Words1),
 				Words1, options_file),
 			Variables) }
 	).
@@ -703,6 +701,10 @@
 			rethrow(TryResult)
 		)
 	).
+
+:- func words_to_charlist(list(string)) = list(char).
+
+words_to_charlist(Words) = string__to_char_list(string__join_list(" ", Words)).
 
 :- func split_into_words(list(char)) = list(string).
 

--------------------------------------------------------------------------
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