Skip to content
Snippets Groups Projects
Commit 4d5e9f38 authored by Mick Jordan's avatar Mick Jordan
Browse files

fix regression in file.path

parent 2427f5a1
Branches
No related tags found
No related merge requests found
......@@ -335,14 +335,26 @@ public class FileFunctions {
return new RNode[]{null, ConstantNode.create(File.separator)};
}
@Specialization(guards = "simpleArgs")
@SuppressWarnings("unused")
@Specialization(order = 0, guards = "lengthZero")
public RStringVector doFilePathZero(RAbstractStringVector vec, String fsep) {
return RDataFactory.createEmptyStringVector();
}
@Specialization(order = 1, guards = "!lengthZero")
public RStringVector doFilePath(RAbstractStringVector vec, String fsep) {
return doFilePath(new Object[]{vec}, fsep);
}
@Specialization(order = 2, guards = "simpleArgs")
public RStringVector doFilePath(Object[] args, String fsep) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < args.length; i++) {
Object elem = args[i];
String elemAsString;
if (elem instanceof RStringVector) {
elemAsString = ((RStringVector) elem).getDataAt(0);
RStringVector svec = (RStringVector) elem;
elemAsString = svec.getLength() == 0 ? "" : svec.getDataAt(0);
} else if (elem instanceof Object[]) {
Object[] elemArray = (Object[]) elem;
for (int j = 0; j < elemArray.length - 1; j++) {
......@@ -363,10 +375,14 @@ public class FileFunctions {
return RDataFactory.createStringVectorFromScalar(sb.toString());
}
public static boolean lengthZero(RAbstractStringVector vec, @SuppressWarnings("unused") String fsep) {
return vec.getLength() == 0;
}
public static boolean simpleArgs(Object[] args, String fsep) {
for (Object arg : args) {
if (arg instanceof RStringVector) {
if (((RStringVector) arg).getLength() != 1) {
if (((RStringVector) arg).getLength() > 1) {
return false;
}
} else {
......
......@@ -108,17 +108,17 @@ R.version.string <- R.version$version.string
#invisible(.libPaths(c(unlist(strsplit(Sys.getenv("R_LIBS"), ":")),
# unlist(strsplit(Sys.getenv("R_LIBS_USER"), ":")
# ))))
##local({
## popath <- Sys.getenv("R_TRANSLATIONS", "")
## if(!nzchar(popath)) {
## paths <- file.path(.libPaths(), "translations", "DESCRIPTION")
## popath <- dirname(paths[file.exists(paths)][1])
## } else {
## }
local({
popath <- Sys.getenv("R_TRANSLATIONS", "")
if(!nzchar(popath)) {
paths <- file.path(.libPaths(), "translations", "DESCRIPTION")
popath <- dirname(paths[file.exists(paths)][1])
} else {
}
# bindtextdomain("R", popath)
# bindtextdomain("R-base", popath)
## assign(".popath", popath, .BaseNamespaceEnv)
##})
assign(".popath", popath, .BaseNamespaceEnv)
})
#local({
### we distinguish between R_PAPERSIZE as set by the user and by configure
#papersize <- Sys.getenv("R_PAPERSIZE_USER")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment