From fa6b82c558275824321b919e8ef835adf1666281 Mon Sep 17 00:00:00 2001 From: Mick Jordan <mick.jordan@oracle.com> Date: Tue, 1 Nov 2016 08:46:17 -0700 Subject: [PATCH] remove quotes on default values in Renviron files --- .../src/com/oracle/truffle/r/runtime/REnvVars.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java index fdbb17d704..1992cc31b8 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/REnvVars.java @@ -220,7 +220,6 @@ public final class REnvVars implements RContext.ContextState { } String var = line.substring(0, ix); String value = expandParameters(line.substring(ix + 1)).trim(); - // GnuR does not seem to remove quotes, although the spec says it should envVars.put(var, value); } } @@ -243,7 +242,7 @@ public final class REnvVars implements RContext.ContextState { } String paramValue = envVars.get(paramName); if (paramValue == null || paramValue.length() == 0) { - paramValue = paramDefault; + paramValue = stripQuotes(paramDefault); } result.append(paramValue); x = paramEnd + 1; @@ -253,6 +252,17 @@ public final class REnvVars implements RContext.ContextState { return result.toString(); } + private static String stripQuotes(String s) { + if (s.length() == 0) { + return s; + } + if (s.charAt(0) == '\'') { + return s.substring(1, s.length() - 1); + } else { + return s; + } + } + @TruffleBoundary private static IOException invalid(String path, String line) throws IOException { throw new IOException(" File " + path + " contains invalid line(s)\n " + line + "\n They were ignored\n"); -- GitLab