@@ -984,19 +984,31 @@ private static void setHookBuildEnvironmentVariable(IContributedEnvironment cont
984
984
*/
985
985
public static String MakeEnvironmentString (String inputString , String keyPrefix , boolean touppercase ) {
986
986
try {
987
- String ret = inputString .replaceAll ("\\ {(?!\\ {)" , "\\ ${" + keyPrefix );
987
+
988
+
988
989
if (!touppercase ) {
989
- return ret ;
990
+ return inputString . replace ( "{" , "${" + keyPrefix ) ;
990
991
}
991
- StringBuilder sb = new StringBuilder (ret );
992
- String regex = "\\ {[^}]*\\ }" ;
992
+ //These 2 markers need to be uppercase to support {compiler.{recipe.c}.cmd}
993
+ final String beginMarker ="--!!BEGINFLAG!!--" ;
994
+ final String endMarker ="--!!ENDFLAG!--" ;
995
+ String regex ="(\\ {([^\\ {]*?)\\ })" ; // \{([^\{]*?)\}
996
+
997
+
998
+ StringBuilder sb = new StringBuilder (inputString );
993
999
Pattern p = Pattern .compile (regex ); // Create the pattern.
994
1000
Matcher matcher = p .matcher (sb ); // Create the matcher.
995
1001
while (matcher .find ()) {
996
- String buf = sb . substring ( matcher . start (), matcher .end ()) .toUpperCase ();
1002
+ String buf = beginMarker + matcher .group ( 2 ) .toUpperCase ()+ endMarker ;
997
1003
sb .replace (matcher .start (), matcher .end (), buf );
1004
+ matcher = p .matcher (sb );
1005
+ }
1006
+
1007
+ String ret = sb .toString ();
1008
+ ret =ret .replace (beginMarker , "${" +keyPrefix );
1009
+ ret =ret .replace (endMarker , "}" );
1010
+ return ret ;
998
1011
}
999
- return sb .toString ();}
1000
1012
catch (Exception e ){
1001
1013
Common .log (new Status (IStatus .ERROR , Const .CORE_PLUGIN_ID ,
1002
1014
"Failed to parse environment var " +inputString , e ));
0 commit comments