Skip to content

Commit

Permalink
modularize to new "statsErr.h"
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87237 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Oct 15, 2024
1 parent 4a56c4d commit 0d0a181
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 150 deletions.
9 changes: 1 addition & 8 deletions src/library/stats/src/approx.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@
#endif

#include <R_ext/Arith.h>
#include <R_ext/Error.h>
#include <R_ext/Applic.h>
#include <Rinternals.h> // for R_xlen_t
#include "statsErr.h"
#ifdef DEBUG_approx
# include <R_ext/Print.h>
#endif

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

/* Linear and Step Function Interpolation */

/* Assumes that ordinates are in ascending order
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/bandwidths.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@
#include <Rmath.h> // M_* constants
#include <Rinternals.h>

// or include "stats.h"
#ifdef ENABLE_NLS
#include <libintl.h>
#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
Expand Down
9 changes: 2 additions & 7 deletions src/library/stats/src/complete_cases.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@
#endif

#include <Defn.h>
#include "statsErr.h"

#define R_MSG_type _("invalid 'type' (%s) of argument")

#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

/* Formerly in src/main/summary.c */

Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/cov.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@
#include <Rmath.h>

#include "statsR.h"
#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#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);

Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/deriv.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@
#endif

#include "Defn.h"
#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"

static SEXP ParenSymbol;
static SEXP PlusSymbol;
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/distn.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@
#include <Defn.h>
#include <Rmath.h>
#include "statsR.h"
#include "statsErr.h"

#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
/* interval at which to check interrupts */
//#define NINTERRUPT 1000000

Expand Down
10 changes: 1 addition & 9 deletions src/library/stats/src/fourier.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@
#endif

#include <Defn.h>

#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#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);
Expand Down
7 changes: 1 addition & 6 deletions src/library/stats/src/integrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@
#include <math.h> // for isfinite
#include <Rinternals.h>
#include <R_ext/Applic.h>
#include "statsErr.h"

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

/* called via .External(.) :*/
SEXP call_dqags(SEXP args);
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/ksmooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
#include <math.h>
#include <R.h> /* for NA_REAL, includes math.h */
#include <Rinternals.h>

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"

static double dokern(double x, int kern)
{
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/lm.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@
#include <R_ext/Applic.h>

#include "statsR.h"

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"

/* A wrapper to replace
Expand Down
7 changes: 1 addition & 6 deletions src/library/stats/src/loglin.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,7 @@ void adjust(int nvar, double *x, double *y, double *z, int *locz,
#include <R.h>
#include <Rinternals.h>
#include "statsR.h"
#ifdef ENABLE_NLS
#include <libintl.h>
#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)
Expand Down
9 changes: 2 additions & 7 deletions src/library/stats/src/lowess.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@
# include <config.h>
#endif

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

#include <math.h>
#include <Rmath.h> /* fmax2, imin2, imax2 */
#include <R_ext/Applic.h> /* prototypes for lowess and clowess */
#include <R_ext/Boolean.h>
#include <R_ext/Utils.h> /* rPsort() */
#include "statsErr.h"

#ifdef DEBUG_lowess
# include <R_ext/Print.h>
#endif
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
#include <Defn.h>

#include "statsR.h"
#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#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)
Expand Down
7 changes: 1 addition & 6 deletions src/library/stats/src/modreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@

#include <R.h>
#include <Rinternals.h>
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"

SEXP isoreg(SEXP y);

Expand Down
1 change: 1 addition & 0 deletions src/library/stats/src/nls.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <float.h>
#include <R.h>
#include <Rinternals.h>
#include "statsErr.h"
#include "nls.h"

#ifndef MIN
Expand Down
7 changes: 0 additions & 7 deletions src/library/stats/src/nls.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
* https://www.R-project.org/Licenses/
*/

#ifdef ENABLE_NLS
#include <libintl.h>
#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);

Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/optim.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@
#include <R_ext/Applic.h>

#include "statsR.h"
#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"

SEXP getListElement(SEXP list, char *str)
{
Expand Down
9 changes: 1 addition & 8 deletions src/library/stats/src/optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@

#include "statsR.h"
#include "stats.h" // R_zeroin2

#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"


/* Formerly in src/appl/fmim.c */
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@
#include <string.h> // for memmove, memcpy, strcmp
#include <Rinternals.h>
#include <R_ext/RS.h>

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif
#include "statsErr.h"

/* PORT interface functions - reverse communication */

Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/rcont.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
#include <config.h>
#endif

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

#include <math.h>

#include <R_ext/Random.h>
Expand All @@ -26,6 +19,7 @@
#include <R_ext/Error.h>
#include <R_ext/Print.h>
#include <R_ext/Utils.h>
#include "statsErr.h"
#ifdef DEBUG_rcont2
# include <limits.h>
#endif
Expand Down
8 changes: 1 addition & 7 deletions src/library/stats/src/smooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,12 @@
#include <math.h>

#include <Rinternals.h> /* 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 <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

static double med3(double u, double v, double w)
{
/* Median(u,v,w): */
Expand Down
11 changes: 2 additions & 9 deletions src/library/stats/src/stats.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,15 +21,8 @@
#define R_STATS_H

/* definitions not involving SEXPs, including those for .Fortran. */

#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

#include <R_ext/RS.h>
#include "statsErr.h"

/* A starting point to extract such prototypes for .Fortran calls is
Expand Down
8 changes: 8 additions & 0 deletions src/library/stats/src/statsErr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <R_ext/Error.h>
#undef _
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext ("stats", String)
#else
#define _(String) (String)
#endif

0 comments on commit 0d0a181

Please sign in to comment.