From 0d5f3ac5d15b5d5312c76a91299cc2e67a375ce2 Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:38:50 +0200 Subject: [PATCH 1/2] Add comma as a splitting token in toTitleCase() --- src/library/tools/R/utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/tools/R/utils.R b/src/library/tools/R/utils.R index e1af33bb9d6..4ddb953153a 100644 --- a/src/library/tools/R/utils.R +++ b/src/library/tools/R/utils.R @@ -2678,7 +2678,7 @@ function(text) else paste0(toupper(x1), tolower(substring(x, 2L))) } if(is.na(x)) return(NA_character_) - xx <- .Call(C_splitString, x, ' -/"()\n\t') + xx <- .Call(C_splitString, x, ' -/"()\n\t,') ## for 'alone' we could insist on that exact capitalization alone <- xx %in% c(alone, either) alone <- alone | grepl("^'.*'$", xx) From b7467c0c2dc06c8a258fb6d0143d937e36be717c Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Fri, 12 Jul 2024 16:42:39 +0200 Subject: [PATCH 2/2] Add regression test --- tests/reg-tests-1e.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/reg-tests-1e.R b/tests/reg-tests-1e.R index 9c7790a829a..eae8c68e433 100644 --- a/tests/reg-tests-1e.R +++ b/tests/reg-tests-1e.R @@ -1399,6 +1399,11 @@ ch0 <- character(0L) stopifnot(identical(ch0, tools::toTitleCase(ch0))) ## was list() in R <= 4.4.0 +## toTitleCase("'PROTECTED',") +stopifnot(identical( + tools::toTitleCase("'SPSS', 'Stata' and 'R' are statistical software"), + "'SPSS', 'Stata' and 'R' are Statistical Software" +)) ## PR#18745 (+ PR#18702) format.data.frame() -> as.data.frame.list() x <- setNames(data.frame(TRUE), NA_character_)