[rkward] packages/rkwarddev/R: don't freak out over empty brackets
m.eik michalke
meik.michalke at uni-duesseldorf.de
Sun Nov 8 20:33:47 UTC 2015
Git commit 19a3fac67e155f3a6a39c7527b6c74256b920be4 by m.eik michalke.
Committed on 08/11/2015 at 18:08.
Pushed by meikm into branch 'master'.
don't freak out over empty brackets
- ignore empty brackets in if conditions
M +15 -10 packages/rkwarddev/R/rk-internal.R
http://commits.kde.org/rkward/19a3fac67e155f3a6a39c7527b6c74256b920be4
diff --git a/packages/rkwarddev/R/rk-internal.R b/packages/rkwarddev/R/rk-internal.R
index 01fe483..dae01a8 100644
--- a/packages/rkwarddev/R/rk-internal.R
+++ b/packages/rkwarddev/R/rk-internal.R
@@ -1511,17 +1511,22 @@ replaceJSOperators <- function(..., call="id"){
uncurl <- function(cond, level=1){
if(!is.null(cond)){
cond.list <- as.list(cond)
- # NOTE: is it better to check for the bracket or lenght > 1?
+ # first check for the bracket
if(identical(as.character(cond[[1]]), "{")){
- cond <- paste0(
- sapply(
- 2:length(cond.list),
- function(this.cond.num){
- do.call("js", args=list(cond[[this.cond.num]], level=level))
- }
- ),
- collapse=paste0("\n", paste0(rep("\t", level-1), collapse=""))
- )
+ # now make sure the bracket isn't empty
+ if(length(cond) > 1){
+ cond <- paste0(
+ sapply(
+ 2:length(cond.list),
+ function(this.cond.num){
+ do.call("js", args=list(cond[[this.cond.num]], level=level))
+ }
+ ),
+ collapse=paste0("\n", paste0(rep("\t", level-1), collapse=""))
+ )
+ } else {
+ cond <- ""
+ }
} else {
cond <- do.call("js", args=list(cond, level=level))
}
More information about the rkward-tracker
mailing list