From 0d0a1817d64e813276c1ae9f10f6c28fbd52ff2e Mon Sep 17 00:00:00 2001 From: maechler Date: Tue, 15 Oct 2024 10:46:07 +0000 Subject: [PATCH] modularize to new "statsErr.h" git-svn-id: https://svn.r-project.org/R/trunk@87237 00db46b3-68df-0310-9c12-caf00c1e9a41 --- src/library/stats/src/approx.c | 9 +-------- src/library/stats/src/bandwidths.c | 8 +------- src/library/stats/src/complete_cases.c | 9 ++------- src/library/stats/src/cov.c | 8 +------- src/library/stats/src/deriv.c | 8 +------- src/library/stats/src/distn.c | 8 +------- src/library/stats/src/fourier.c | 10 +--------- src/library/stats/src/integrate.c | 7 +------ src/library/stats/src/ksmooth.c | 8 +------- src/library/stats/src/lm.c | 8 +------- src/library/stats/src/loglin.c | 7 +------ src/library/stats/src/lowess.c | 9 ++------- src/library/stats/src/model.c | 8 +------- src/library/stats/src/modreg.h | 7 +------ src/library/stats/src/nls.c | 1 + src/library/stats/src/nls.h | 7 ------- src/library/stats/src/optim.c | 8 +------- src/library/stats/src/optimize.c | 9 +-------- src/library/stats/src/port.h | 8 +------- src/library/stats/src/rcont.c | 8 +------- src/library/stats/src/smooth.c | 8 +------- src/library/stats/src/stats.h | 11 ++--------- src/library/stats/src/statsErr.h | 8 ++++++++ 23 files changed, 32 insertions(+), 150 deletions(-) create mode 100644 src/library/stats/src/statsErr.h diff --git a/src/library/stats/src/approx.c b/src/library/stats/src/approx.c index 8ab2f072306..640eae74e43 100644 --- a/src/library/stats/src/approx.c +++ b/src/library/stats/src/approx.c @@ -23,20 +23,13 @@ #endif #include -#include #include #include // for R_xlen_t +#include "statsErr.h" #ifdef DEBUG_approx # include #endif -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - /* Linear and Step Function Interpolation */ /* Assumes that ordinates are in ascending order diff --git a/src/library/stats/src/bandwidths.c b/src/library/stats/src/bandwidths.c index 527ef165157..13327194010 100644 --- a/src/library/stats/src/bandwidths.c +++ b/src/library/stats/src/bandwidths.c @@ -23,13 +23,7 @@ #include // M_* constants #include -// or include "stats.h" -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" #define DELMAX 1000 /* Avoid slow and possibly error-producing underflows by cutting off at diff --git a/src/library/stats/src/complete_cases.c b/src/library/stats/src/complete_cases.c index d6ffb2c1ba5..aa8b1943657 100644 --- a/src/library/stats/src/complete_cases.c +++ b/src/library/stats/src/complete_cases.c @@ -23,15 +23,10 @@ #endif #include +#include "statsErr.h" + #define R_MSG_type _("invalid 'type' (%s) of argument") -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif /* Formerly in src/main/summary.c */ diff --git a/src/library/stats/src/cov.c b/src/library/stats/src/cov.c index 1dd243e7639..736f3b639c8 100644 --- a/src/library/stats/src/cov.c +++ b/src/library/stats/src/cov.c @@ -32,13 +32,7 @@ #include #include "statsR.h" -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" static SEXP corcov(SEXP x, SEXP y, SEXP na_method, SEXP kendall, Rboolean cor); diff --git a/src/library/stats/src/deriv.c b/src/library/stats/src/deriv.c index 1d117ec630b..a92ce5e25ec 100644 --- a/src/library/stats/src/deriv.c +++ b/src/library/stats/src/deriv.c @@ -27,13 +27,7 @@ #endif #include "Defn.h" -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" static SEXP ParenSymbol; static SEXP PlusSymbol; diff --git a/src/library/stats/src/distn.c b/src/library/stats/src/distn.c index f8e1f6f6d74..aa6d1bf27c2 100644 --- a/src/library/stats/src/distn.c +++ b/src/library/stats/src/distn.c @@ -32,14 +32,8 @@ #include #include #include "statsR.h" +#include "statsErr.h" -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif /* interval at which to check interrupts */ //#define NINTERRUPT 1000000 diff --git a/src/library/stats/src/fourier.c b/src/library/stats/src/fourier.c index 31166be10ba..de2f99a98fc 100644 --- a/src/library/stats/src/fourier.c +++ b/src/library/stats/src/fourier.c @@ -29,15 +29,7 @@ #endif #include - -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - +#include "statsErr.h" // workhorse routines from fft.c void fft_factor(int n, int *pmaxf, int *pmaxp); diff --git a/src/library/stats/src/integrate.c b/src/library/stats/src/integrate.c index d6bba02d839..15af136453c 100644 --- a/src/library/stats/src/integrate.c +++ b/src/library/stats/src/integrate.c @@ -24,13 +24,8 @@ #include // for isfinite #include #include +#include "statsErr.h" -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif /* called via .External(.) :*/ SEXP call_dqags(SEXP args); diff --git a/src/library/stats/src/ksmooth.c b/src/library/stats/src/ksmooth.c index 8a7a3d54928..3160047e3eb 100644 --- a/src/library/stats/src/ksmooth.c +++ b/src/library/stats/src/ksmooth.c @@ -20,13 +20,7 @@ #include #include /* for NA_REAL, includes math.h */ #include - -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" static double dokern(double x, int kern) { diff --git a/src/library/stats/src/lm.c b/src/library/stats/src/lm.c index 0de7d962213..c6699edc40b 100644 --- a/src/library/stats/src/lm.c +++ b/src/library/stats/src/lm.c @@ -22,13 +22,7 @@ #include #include "statsR.h" - -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" /* A wrapper to replace diff --git a/src/library/stats/src/loglin.c b/src/library/stats/src/loglin.c index d713b9e18e8..9318c4f89ca 100644 --- a/src/library/stats/src/loglin.c +++ b/src/library/stats/src/loglin.c @@ -337,12 +337,7 @@ void adjust(int nvar, double *x, double *y, double *z, int *locz, #include #include #include "statsR.h" -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" SEXP LogLin(SEXP dtab, SEXP conf, SEXP table, SEXP start, SEXP snmar, SEXP eps, SEXP iter) diff --git a/src/library/stats/src/lowess.c b/src/library/stats/src/lowess.c index 0b2fc249ed1..32185e4f75c 100644 --- a/src/library/stats/src/lowess.c +++ b/src/library/stats/src/lowess.c @@ -22,18 +22,13 @@ # include #endif -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - #include #include /* fmax2, imin2, imax2 */ #include /* prototypes for lowess and clowess */ #include #include /* rPsort() */ +#include "statsErr.h" + #ifdef DEBUG_lowess # include #endif diff --git a/src/library/stats/src/model.c b/src/library/stats/src/model.c index 47a72b57d0a..5c3a79b8722 100644 --- a/src/library/stats/src/model.c +++ b/src/library/stats/src/model.c @@ -25,13 +25,7 @@ #include #include "statsR.h" -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" /* inline-able versions, used just once! */ static R_INLINE Rboolean isUnordered_int(SEXP s) diff --git a/src/library/stats/src/modreg.h b/src/library/stats/src/modreg.h index a0b26201018..3cdef8268ea 100644 --- a/src/library/stats/src/modreg.h +++ b/src/library/stats/src/modreg.h @@ -23,12 +23,7 @@ #include #include -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" SEXP isoreg(SEXP y); diff --git a/src/library/stats/src/nls.c b/src/library/stats/src/nls.c index 4428856f34c..76d26ffdf82 100644 --- a/src/library/stats/src/nls.c +++ b/src/library/stats/src/nls.c @@ -30,6 +30,7 @@ #include #include #include +#include "statsErr.h" #include "nls.h" #ifndef MIN diff --git a/src/library/stats/src/nls.h b/src/library/stats/src/nls.h index a0e9284716b..3f78ed7fb16 100644 --- a/src/library/stats/src/nls.h +++ b/src/library/stats/src/nls.h @@ -17,13 +17,6 @@ * https://www.R-project.org/Licenses/ */ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - SEXP nls_iter(SEXP m, SEXP control, SEXP doTraceArg); SEXP numeric_deriv(SEXP expr, SEXP theta, SEXP rho, SEXP dir, SEXP eps_, SEXP centr); diff --git a/src/library/stats/src/optim.c b/src/library/stats/src/optim.c index 6b122311858..28489a75cbe 100644 --- a/src/library/stats/src/optim.c +++ b/src/library/stats/src/optim.c @@ -25,13 +25,7 @@ #include #include "statsR.h" -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" SEXP getListElement(SEXP list, char *str) { diff --git a/src/library/stats/src/optimize.c b/src/library/stats/src/optimize.c index 507e51cbaec..0ba794915c0 100644 --- a/src/library/stats/src/optimize.c +++ b/src/library/stats/src/optimize.c @@ -31,14 +31,7 @@ #include "statsR.h" #include "stats.h" // R_zeroin2 - -#undef _ -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" /* Formerly in src/appl/fmim.c */ diff --git a/src/library/stats/src/port.h b/src/library/stats/src/port.h index 3206cbbb74b..b3c9d93d2cb 100644 --- a/src/library/stats/src/port.h +++ b/src/library/stats/src/port.h @@ -31,13 +31,7 @@ #include // for memmove, memcpy, strcmp #include #include - -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif +#include "statsErr.h" /* PORT interface functions - reverse communication */ diff --git a/src/library/stats/src/rcont.c b/src/library/stats/src/rcont.c index 30fb7fa8932..4535cccb3cb 100644 --- a/src/library/stats/src/rcont.c +++ b/src/library/stats/src/rcont.c @@ -11,13 +11,6 @@ #include #endif -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - #include #include @@ -26,6 +19,7 @@ #include #include #include +#include "statsErr.h" #ifdef DEBUG_rcont2 # include #endif diff --git a/src/library/stats/src/smooth.c b/src/library/stats/src/smooth.c index cec481f0e97..a7399df770f 100644 --- a/src/library/stats/src/smooth.c +++ b/src/library/stats/src/smooth.c @@ -27,18 +27,12 @@ #include #include /* Arith.h, Boolean.h, Error.h, Memory.h .. */ +#include "statsErr.h" typedef enum { sm_NO_ENDRULE, sm_COPY_ENDRULE, sm_TUKEY_ENDRULE } R_SM_ENDRULE; -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - static double med3(double u, double v, double w) { /* Median(u,v,w): */ diff --git a/src/library/stats/src/stats.h b/src/library/stats/src/stats.h index 9b4e220d7c3..7eb8768068c 100644 --- a/src/library/stats/src/stats.h +++ b/src/library/stats/src/stats.h @@ -1,6 +1,6 @@ /* * R : A Computer Language for Statistical Data Analysis - * Copyright (C) 2005-2020 The R Core Team + * Copyright (C) 2005-2024 The R Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,15 +21,8 @@ #define R_STATS_H /* definitions not involving SEXPs, including those for .Fortran. */ - -#ifdef ENABLE_NLS -#include -#define _(String) dgettext ("stats", String) -#else -#define _(String) (String) -#endif - #include +#include "statsErr.h" /* A starting point to extract such prototypes for .Fortran calls is diff --git a/src/library/stats/src/statsErr.h b/src/library/stats/src/statsErr.h new file mode 100644 index 00000000000..f17a1719bbf --- /dev/null +++ b/src/library/stats/src/statsErr.h @@ -0,0 +1,8 @@ +#include +#undef _ +#ifdef ENABLE_NLS +#include +#define _(String) dgettext ("stats", String) +#else +#define _(String) (String) +#endif