Skip to content

Commit 4809662

Browse files
author
jan
committed
#1184 fully uppercase the environment variables used
1 parent a468631 commit 4809662

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

io.sloeber.core/src/io/sloeber/core/tools/Helpers.java

+18-6
Original file line numberDiff line numberDiff line change
@@ -984,19 +984,31 @@ private static void setHookBuildEnvironmentVariable(IContributedEnvironment cont
984984
*/
985985
public static String MakeEnvironmentString(String inputString, String keyPrefix, boolean touppercase) {
986986
try {
987-
String ret = inputString.replaceAll("\\{(?!\\{)", "\\${" + keyPrefix);
987+
988+
988989
if (!touppercase) {
989-
return ret;
990+
return inputString.replace("{", "${" + keyPrefix);
990991
}
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);
993999
Pattern p = Pattern.compile(regex); // Create the pattern.
9941000
Matcher matcher = p.matcher(sb); // Create the matcher.
9951001
while (matcher.find()) {
996-
String buf = sb.substring(matcher.start(), matcher.end()).toUpperCase();
1002+
String buf = beginMarker+matcher.group(2).toUpperCase()+endMarker;
9971003
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;
9981011
}
999-
return sb.toString();}
10001012
catch (Exception e){
10011013
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID,
10021014
"Failed to parse environment var "+inputString, e));

0 commit comments

Comments
 (0)