|
44 | 44 | * Either accessing and/or setting a global C variable, |
45 | 45 | * or just accessed by e.g. GetOption1(install("pager")) |
46 | 46 | * |
47 | | - * A (complete?!) list of these (2) {plus some of 1)}: |
| 47 | + * An (incomplete) list of these (2) {plus some of 1)}: |
48 | 48 | * |
49 | 49 | * "prompt" |
50 | 50 | * "continue" |
|
57 | 57 | * "keep.source.pkgs" |
58 | 58 | * "keep.parse.data" |
59 | 59 | * "keep.parse.data.pkgs" |
60 | | - * "browserNLdisabled" |
61 | 60 |
|
62 | 61 | * "de.cellwidth" ../unix/X11/ & ../gnuwin32/dataentry.c |
63 | 62 | * "device" |
|
78 | 77 | * "warning.expression" |
79 | 78 | * "nwarnings" |
80 | 79 |
|
| 80 | + * "browserNLdisabled" |
| 81 | +
|
81 | 82 | * "matprod" |
82 | 83 | * "PCRE_study" |
83 | 84 | * "PCRE_use_JIT" |
@@ -174,6 +175,34 @@ attribute_hidden int GetOptionDigits(void) |
174 | 175 | return FixupDigits(GetOption1(install("digits")), iWARN); |
175 | 176 | } |
176 | 177 |
|
| 178 | +static |
| 179 | +int FixupScipen(SEXP scipen, warn_type warn) |
| 180 | +{ |
| 181 | + if (!isNumeric(scipen) || LENGTH(scipen) != 1) |
| 182 | + error(_("invalid 'scipen'")); |
| 183 | + int d; |
| 184 | + if(TYPEOF(scipen) == REALSXP) { /* preventing warning + error : */ |
| 185 | + int w = 0; |
| 186 | + d = IntegerFromReal(REAL_ELT(scipen, 0), &w); |
| 187 | + if(w && d == NA_INTEGER) |
| 188 | + error(_("setting scipen=%g is out of range"), REAL_ELT(scipen,0)); |
| 189 | + } else |
| 190 | + d = asInteger(scipen); |
| 191 | + if (d == NA_INTEGER || d < R_MIN_SCIPEN_OPT || d > R_MAX_SCIPEN_OPT) { |
| 192 | + int dnew = (d == NA_INTEGER) ? 0 : |
| 193 | + (d < R_MIN_SCIPEN_OPT) ? R_MIN_SCIPEN_OPT : |
| 194 | + /* d > R_MAX_SCIPEN_OPT */ R_MAX_SCIPEN_OPT; |
| 195 | + switch(warn) { |
| 196 | + case iWARN: warning(_("invalid 'scipen' %d, used %d"), d, dnew); |
| 197 | + case iSILENT: |
| 198 | + return dnew; // for SILENT and WARN |
| 199 | + case iERROR: error(_("invalid 'scipen' %d"), d); |
| 200 | + } |
| 201 | + } |
| 202 | + return d; |
| 203 | +} |
| 204 | + |
| 205 | + |
177 | 206 | attribute_hidden |
178 | 207 | int GetOptionCutoff(void) |
179 | 208 | { |
@@ -561,20 +590,21 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho) |
561 | 590 | "width", "deparse.cutoff", "digits", "echo", "verbose", |
562 | 591 | "check.bounds", "keep.source", "keep.source.pkgs", |
563 | 592 | "keep.parse.data", "keep.parse.data.pkgs", "warning.length", |
564 | | - "nwarnings", "OutDec", "browserNLdisabled", "CBoundsCheck", |
| 593 | + "nwarnings", "OutDec", "CBoundsCheck", |
565 | 594 | "matprod", "PCRE_study", "PCRE_use_JIT", |
566 | 595 | "PCRE_limit_recursion", "rl_word_breaks", |
567 | 596 | "max.contour.segments", "warnPartialMatchDollar", |
568 | 597 | "warnPartialMatchArgs", "warnPartialMatchAttr", |
569 | 598 | "showWarnCalls", "showErrorCalls", "showNCalls", |
570 | 599 | "browserNLdisabled", |
571 | 600 | /* ^^^ from InitOptions ^^^ */ |
572 | | - "warn", "max.print", "show.error.messages", |
| 601 | + "warn", "max.print", "show.error.messages", "scipen", |
573 | 602 | /* ^^^ from Common.R ^^^ */ |
574 | 603 | NULL}; |
575 | 604 | for(int j = 0; mandatory[j] != NULL; j++) |
576 | 605 | if (streql(CHAR(namei), mandatory[j])) |
577 | 606 | error(_("option '%s' cannot be deleted"), CHAR(namei)); |
| 607 | + // "else" : |
578 | 608 | SET_VECTOR_ELT(value, i, SetOption(tag, R_NilValue)); |
579 | 609 | } else if (streql(CHAR(namei), "width")) { |
580 | 610 | int k = asInteger(argi); |
@@ -684,6 +714,10 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho) |
684 | 714 | if (k < 1) error(_("invalid value for '%s'"), CHAR(namei)); |
685 | 715 | SET_VECTOR_ELT(value, i, SetOption(tag, ScalarInteger(k))); |
686 | 716 | } |
| 717 | + else if (streql(CHAR(namei), "scipen")) { |
| 718 | + int k = FixupScipen(argi, iWARN); /* to become iERROR in say 2027 */ |
| 719 | + SET_VECTOR_ELT(value, i, SetOption(tag, ScalarInteger(k))); |
| 720 | + } |
687 | 721 | else if (streql(CHAR(namei), "nwarnings")) { |
688 | 722 | int k = asInteger(argi); |
689 | 723 | if (k < 1) error(_("invalid value for '%s'"), CHAR(namei)); |
|
0 commit comments