Skip to content

Commit d6042c3

Browse files
author
maechler
committed
using deprecated options(OutDec = "<gt-1-char>") now warns in format()
git-svn-id: https://svn.r-project.org/R/trunk@87426 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent c0f41b1 commit d6042c3

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

doc/NEWS.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,10 @@
415415
call with \code{glyphInfo()} that describes non-existent font
416416
(\PR{18784}). Thanks to \I{Tomek Gieorgijewski}.
417417
418+
\item \code{format()} etc, using \code{decimal.mark = s}, by default
419+
getting \code{s <- getOption("OutDec")}, signals a warning to become
420+
an error in the future, when \code{s} is not a string with exactly
421+
one character.
418422
}
419423
}
420424
}

src/main/paste.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ attribute_hidden SEXP do_format(SEXP call, SEXP op, SEXP args, SEXP env)
515515
my_OutDec = OutDec; // default
516516
else {
517517
static char sdec[11];
518-
// not warning here by default for now
519-
#ifdef _WARN_decimal_mark_non_1
520-
if(R_nchar(STRING_ELT(CAR(args), 0), Chars,
518+
#define _WARN_decimal_mark_non_1 // were *not* warning here by default since 2015-06-19
519+
#ifdef _WARN_decimal_mark_non_1
520+
if(R_nchar(STRING_ELT(CAR(args), 0), Chars,
521521
/* allowNA = */ FALSE, /* keepNA = */ FALSE,
522522
"decimal.mark") != 1) // will become an error
523523
warning(_("'decimal.mark' must be a string of one character"));

tests/reg-tests-1c.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,17 +840,19 @@ unlink(profile)
840840
## failed when a matrix was downgraded to a vector
841841

842842

843+
assertWarnV <- function(...) tools::assertWarning(..., verbose=TRUE)
844+
843845
## option(OutDec = *) -- now gives a warning when not 1 character
844846
op <- options(OutDec = ".", digits = 7, # <- default
845847
warn = 2)# <- (unexpected) warnings become errors
846848
stopifnot(identical("3.141593", fpi <- format(pi)))
847849
options(OutDec = ",")
848850
stopifnot(identical("3,141593", cpi <- format(pi)))
849851
## warnings, but it "works" (for now):
850-
tools::assertWarning(options(OutDec = ".1."), verbose=TRUE)
851-
stopifnot(identical("3.1.141593", format(pi)))
852-
tools::assertWarning(options(OutDec = ""), verbose=TRUE)
853-
tools::assertWarning(stopifnot(identical("3141593", format(pi))))
852+
assertWarnV(options(OutDec = ".1."))
853+
assertWarnV(stopifnot(identical("3.1.141593", format(pi)))) # newly warns (2024-12)
854+
assertWarnV(options(OutDec = ""))
855+
assertWarnV(stopifnot(identical("3141593", format(pi)))) # newly warns
854856
options(op)# back to sanity
855857
## No warnings in R versions <= 3.2.1
856858

@@ -1589,7 +1591,7 @@ doit()
15891591
if(nzchar(Sys.getenv("tar"))) doit(tar = "internal")
15901592
if(nzchar(Sys.which("tar"))) doit(tar = "tar")
15911593
## internal tar silently ignored unused 'files' in R <= 4.0.2
1592-
tools::assertWarning(verbose=TRUE,
1594+
assertWarnV(
15931595
tar(tempfile(fileext=".tar"), files = tempfile(), tar = "internal")
15941596
)
15951597

0 commit comments

Comments
 (0)