Skip to content

Commit 87b187d

Browse files
committed
ensure retro comp. following width operator change
1 parent ccf68f8 commit 87b187d

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

R/string_magic_main.R

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,24 @@ sma_char2operator = function(x, .valid_operators){
13511351
sma_operators = function(x, op, options, argument, .check = FALSE, .envir = NULL,
13521352
.data = list(), group_flag = 0, .delim = c("{", "}"),
13531353
.user_funs = NULL, .valid_operators = NULL){
1354+
1355+
1356+
#
1357+
# step 1: retro compatibility ####
1358+
#
1359+
1360+
1361+
# now: >=1.2.0 operator width becomes similar to fill
1362+
# we need take care of not breaking existing code!!!!
1363+
# special case: width is like swidth (old behavior, < 1.2.0)
1364+
if(op == "width" && grepl("sw", argument)){
1365+
op = "swidth"
1366+
}
1367+
1368+
#
1369+
# step 2: user functions ####
1370+
#
1371+
13541372

13551373
# group_flag: 0 nothing
13561374
# 1 keep track of conditional things
@@ -1379,6 +1397,11 @@ sma_operators = function(x, op, options, argument, .check = FALSE, .envir = NULL
13791397
# * check user defined version first
13801398
#
13811399

1400+
#
1401+
# step 3: built in functions ####
1402+
#
1403+
1404+
13821405
if(isTRUE(attr(fun, "simple_ops"))){
13831406
res = apply_simple_operations(x, op, fun, .check, .envir, .data,
13841407
group_flag = group_flag, .delim,
@@ -2246,8 +2269,11 @@ sma_operators = function(x, op, options, argument, .check = FALSE, .envir = NULL
22462269
} else if(op %in% c("fill", "align", "width")){
22472270
# fill, align ####
22482271

2249-
# all are equivalent
2272+
#
2273+
# regular case
2274+
#
22502275

2276+
# all are equivalent
22512277
valid_options = c("left", "right", "center")
22522278
options = check_set_options(options, valid_options, op = op)
22532279

0 commit comments

Comments
 (0)