Skip to content

Commit d5c3109

Browse files
author
maechler
committed
getOption("quiet") accessing C R_Quiet
git-svn-id: https://svn.r-project.org/R/trunk@88384 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 96c3f26 commit d5c3109

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

doc/NEWS.Rd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@
5454
\item \code{extSoftVersion()[["zstd"]]} now reports the version of
5555
the \command{zstd} compression library if available, thanks to
5656
\I{Trevor Davis}' patch proposal in \PR{18914}.
57+
58+
\item New logical \code{option()} \code{quiet}, defaulting to
59+
false, set to \code{TRUE} by \R's command-line option
60+
\option{--quiet} (and similar), now can be switched during an \R
61+
session. Prompted by \I{Dirk Eddelbuettel}'s proposal in \PR{18913}.
5762
}
5863
}
5964

@@ -917,7 +922,7 @@
917922
signal an error instead of invalidating ops relying on a finite
918923
integer value. Values outside the range -9 .. 9999 are now warned
919924
about and set to a boundary or to the default \code{0}, e.g., in
920-
case of an \code{NA}.
925+
case of an \code{NA}. This also fixes \PR{16322}.
921926

922927
\item \code{cbind()} could segfault with \code{NULL} inputs.
923928
(Seen when \R was built with \command{gcc-14}, \abbr{LTO} and C99

src/library/base/man/options.Rd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ getOption(x, default = NULL)
394394
\item{\code{show.error.locations}:}{Should source locations of
395395
errors be printed? If set to \code{TRUE} or \code{"top"}, the
396396
source location that is highest on the stack (the most recent
397-
code with source information) will be printed.
397+
code with source information) will be printed.
398398
}
399399

400400
\item{\code{show.error.messages}:}{a logical. Should error messages
@@ -444,6 +444,11 @@ getOption(x, default = NULL)
444444
on progress? Set to \code{TRUE} by the command-line option
445445
\option{--verbose}.}
446446

447+
\item{\code{quiet}:}{logical. Should \R be (more) \dQuote{quiet},
448+
notably on startup report? Set to \code{TRUE} by the command-line
449+
option \option{--quiet}. \code{quiet} and \code{verbose} cannot both
450+
be true.}
451+
447452
\item{\code{warn}:}{integer value to set the handling of warning
448453
messages by the default warning handler. If
449454
\code{warn} is negative all warnings are ignored. If \code{warn}
@@ -520,6 +525,7 @@ getOption(x, default = NULL)
520525
\code{scipen} \tab \code{0} \cr
521526
\code{show.error.messages} \tab \code{TRUE}\cr
522527
\code{timeout} \tab \code{60}\cr
528+
\code{quiet} \tab \code{FALSE}\cr
523529
\code{verbose} \tab \code{FALSE}\cr
524530
\code{warn} \tab \code{0}\cr
525531
\code{warning.length} \tab \code{1000}\cr

src/main/options.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
* "width"
5353
* "digits"
5454
* "echo"
55+
* "quiet"
5556
* "verbose"
5657
* "keep.source"
5758
* "keep.source.pkgs"
@@ -308,9 +309,9 @@ attribute_hidden void InitOptions(void)
308309

309310
/* options set here should be included into mandatory[] in do_options */
310311
#ifdef HAVE_RL_COMPLETION_MATCHES
311-
PROTECT(v = val = allocList(30));
312+
PROTECT(v = val = allocList(31));
312313
#else
313-
PROTECT(v = val = allocList(29));
314+
PROTECT(v = val = allocList(30));
314315
#endif
315316

316317
SET_TAG(v, install("prompt"));
@@ -341,6 +342,10 @@ attribute_hidden void InitOptions(void)
341342
SETCAR(v, ScalarLogical(!R_NoEcho));
342343
v = CDR(v);
343344

345+
SET_TAG(v, install("quiet"));
346+
SETCAR(v, ScalarLogical(R_Quiet));
347+
v = CDR(v);
348+
344349
SET_TAG(v, install("verbose"));
345350
SETCAR(v, ScalarLogical(R_Verbose));
346351
v = CDR(v);
@@ -587,7 +592,7 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho)
587592
at startup, because otherwise one could not reliably restore
588593
previously saved options (see also PR#18372).*/
589594
const char *mandatory[] = {"prompt", "continue", "expressions",
590-
"width", "deparse.cutoff", "digits", "echo", "verbose",
595+
"width", "deparse.cutoff", "digits", "echo", "quiet", "verbose",
591596
"check.bounds", "keep.source", "keep.source.pkgs",
592597
"keep.parse.data", "keep.parse.data.pkgs", "warning.length",
593598
"nwarnings", "OutDec", "CBoundsCheck",
@@ -891,10 +896,21 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho)
891896
SET_VECTOR_ELT(value, i,
892897
SetOption(tag, ScalarLogical(strings_as_fact)));
893898
}
899+
else if (streql(CHAR(namei), "quiet")) {
900+
if (TYPEOF(argi) != LGLSXP || LENGTH(argi) != 1)
901+
error(_("invalid value for '%s'"), CHAR(namei));
902+
Rboolean k = asRbool(argi, call);
903+
if(k && R_Verbose)
904+
error(_("cannot set both options 'quiet' and 'verbose' to TRUE"));
905+
R_Quiet = k;
906+
SET_VECTOR_ELT(value, i, SetOption(tag, ScalarLogical(k)));
907+
}
894908
else if (streql(CHAR(namei), "verbose")) {
895909
if (TYPEOF(argi) != LGLSXP || LENGTH(argi) != 1)
896910
error(_("invalid value for '%s'"), CHAR(namei));
897911
Rboolean k = asRbool(argi, call);
912+
if(k && R_Quiet)
913+
error(_("cannot set both options 'quiet' and 'verbose' to TRUE"));
898914
R_Verbose = k;
899915
SET_VECTOR_ELT(value, i, SetOption(tag, ScalarLogical(k)));
900916
}

0 commit comments

Comments
 (0)