Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
brodieG committed Dec 19, 2021
1 parent 21fd146 commit f2bc762
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions R/internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ VAL_IN_ENV <- function(
c(
'x', 'warn', 'term.cap', 'ctl', 'normalize', 'carry', 'terminate',
'tab.stops', 'tabs.as.spaces', 'strip.spaces', 'round', 'type',
'start', 'stop', 'keepNA', 'allowNA',
'start', 'stop', 'keepNA', 'allowNA', 'value',

# meta parameters (i.e. internal parameters)
'valid.types' # nchar and substr allow different things
Expand Down Expand Up @@ -153,7 +153,7 @@ VAL_IN_ENV <- function(
if(is.na(carry))
stop2("Argument `carry` may not be NA.")
if('value' %in% argnm && !is.logical(carry))
stop2("Argumetn `carry` must be TRUE or FALSE in replacement mode.")
stop2("Argument `carry` must be TRUE or FALSE in replacement mode.")
if(is.logical(carry)) if(carry) carry <- "" else carry = NA_character_
args[['carry']] <- carry
}
Expand Down
5 changes: 1 addition & 4 deletions R/substr2.R
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,6 @@ substr2_ctl <- function(
carry=getOption('fansi.carry', FALSE),
terminate=getOption('fansi.terminate', TRUE)
) {
# More restrictive carry
if(!is.logical(carry) || length(carry) != 1 || is.na(carry))
stop("Argument `carry` must be TRUE or FALSE.")
# So warning are issued here
start <- as.integer(start)
stop <- as.integer(stop)
Expand All @@ -373,7 +370,7 @@ substr2_ctl <- function(
VAL_IN_ENV(
x=x, warn=warn, term.cap=term.cap, ctl=ctl, normalize=normalize,
tab.stops=tab.stops, tabs.as.spaces=tabs.as.spaces, round=round, start=start,
stop=stop, type=type, carry=carry
stop=stop, type=type, carry=carry, value=value
)
# In replace mode we shouldn't change the encoding
if(!all(enc.diff <- Encoding(x) == Encoding(x0)))
Expand Down
2 changes: 1 addition & 1 deletion src/normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int FANSI_W_normalize(
string = state_int.string + state_int.pos.x;
} else if (*string == 0) {
// We ran out of string (should be impossible if `stop` used correctly)
error("Internal Error: unexpected `stop` value for normalize."); // ncoov
error("Internal Error: unexpected `stop` value for normalize."); // nocov
// if(any_to_exp) {
// FANSI_W_MCOPY(buff, string_last, string - string_last);
// }
Expand Down
4 changes: 3 additions & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,15 @@ static SEXP mkChar_core(
}

// Annoyingly mkCharLenCE accepts int parameter instead of R_len_t, so we need
// to check that too.
// to check that too. Not sure this can actually be triggered realistically.
if(buff.len > FANSI_lim.lim_int.max)
// nocov start
error(
"%s at index [%jd].",
"Attempting to create CHARSXP longer than INT_MAX",
FANSI_ind(i)
);
// nocov end

return mkCharLenCE(buff.buff0, buff.len, enc);

Expand Down

0 comments on commit f2bc762

Please sign in to comment.