Skip to content

Commit c41bd1d

Browse files
committed
change more occurances of error() to Rf_error()
1 parent f9796eb commit c41bd1d

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/binners.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ SEXP binYonX(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize,
7272
base_value = REAL(baseValue)[0];
7373

7474
if (from_idx < 0 || to_idx < 0)
75-
error("'fromIdx' and 'toIdx' have to be >= 0!");
75+
Rf_error("'fromIdx' and 'toIdx' have to be >= 0!");
7676
if (from_idx > to_idx)
77-
error("'fromIdx' has to be smaller than 'toIdx'!");
77+
Rf_error("'fromIdx' has to be smaller than 'toIdx'!");
7878
if (to_idx >= LENGTH(x))
79-
error("'toIdx' can not be larger than length(x)!");
79+
Rf_error("'toIdx' can not be larger than length(x)!");
8080

8181
/* Define from_x and to_x */
8282
if (ISNA(REAL(fromX)[0])) {
@@ -95,12 +95,12 @@ SEXP binYonX(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize,
9595
n_bin = (LENGTH(breaks) - 1);
9696
p_brks = REAL(breaks);
9797
if (n_bin < 1)
98-
error("Not enough breaks defined!");
98+
Rf_error("Not enough breaks defined!");
9999
} else if (INTEGER(nBins)[0] != NA_INTEGER) {
100100
/* Calculating breaks based on the number of bins. */
101101
n_bin = asInteger(nBins);
102102
if (n_bin <= 0)
103-
error("'nBins' must be larger 1!");
103+
Rf_error("'nBins' must be larger 1!");
104104
PROTECT(brks = allocVector(REALSXP, n_bin + 1));
105105
count_protect++;
106106
/* Calculate the breaks */
@@ -110,7 +110,7 @@ SEXP binYonX(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize,
110110
/* Calculating breaks based on bin size. */
111111
bin_size = REAL(binSize)[0];
112112
if (bin_size < 0)
113-
error("'binSize' has to be > 0!");
113+
Rf_error("'binSize' has to be > 0!");
114114
if (shift_by_half_bin_size > 0) {
115115
from_x = from_x - (bin_size / 2);
116116
to_x = to_x + (bin_size / 2);
@@ -224,7 +224,7 @@ SEXP binYonX_multi(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize,
224224
SEXP res, from_idx, to_idx, current_res;
225225
int n_subsets, *p_subset_from_idx, *p_subset_to_idx;
226226
if (LENGTH(subsetFromIdx) != LENGTH(subsetToIdx)) {
227-
error("Arguments 'subsetFromIdx' and 'subsetToIdx' have to have the same length!");
227+
Rf_error("Arguments 'subsetFromIdx' and 'subsetToIdx' have to have the same length!");
228228
}
229229
n_subsets = LENGTH(subsetFromIdx);
230230
p_subset_from_idx = INTEGER(subsetFromIdx);

src/fastMatch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SEXP fastMatch(SEXP x, SEXP y, SEXP xidx, SEXP yidx, SEXP xolength, SEXP tol) {
2929

3030
struct idxStruct * pidxS = (struct idxStruct *) calloc(nx, sizeof(struct idxStruct));
3131
if (pidxS == NULL)
32-
error("fastMatch/calloc: memory could not be allocated ! (%lu bytes)\n", nx * sizeof(struct idxStruct) );
32+
Rf_error("fastMatch/calloc: memory could not be allocated ! (%lu bytes)\n", nx * sizeof(struct idxStruct) );
3333
for (xi=0;xi < nx;xi++)
3434
pidxS[xi].from = ny+1;
3535

src/massifquant/nmath.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ double gamma_cody(double);
4646
#ifndef MATHLIB_STANDALONE
4747

4848
#include <R_ext/Error.h>
49-
# define MATHLIB_ERROR(fmt,x) error(fmt,x);
49+
# define MATHLIB_ERROR(fmt,x) Rf_error(fmt,x);
5050
# define MATHLIB_WARNING(fmt,x) warning(fmt,x)
5151
# define MATHLIB_WARNING2(fmt,x,x2) warning(fmt,x,x2)
5252
# define MATHLIB_WARNING3(fmt,x,x2,x3) warning(fmt,x,x2,x3)

src/mzROI.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct mzROIStruct * checkmzROIBufSize(struct mzROIStruct *mzROI, const unsigned
7676

7777
mzROI = (struct mzROIStruct *) realloc(mzROI, newLength * sizeof(struct mzROIStruct));
7878
if (mzROI == NULL)
79-
error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct) );
79+
Rf_error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct) );
8080

8181
mzLength->mzROITotal = newLength;
8282
}
@@ -99,7 +99,7 @@ struct mzROIStruct * checkmzvalBufSize(struct mzROIStruct *mzval, const unsigned
9999

100100
mzval = (struct mzROIStruct *) realloc(mzval, newLength * sizeof(struct mzROIStruct));
101101
if (mzval == NULL)
102-
error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct));
102+
Rf_error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct));
103103

104104
mzLength->mzvalTotal = newLength;
105105
}
@@ -202,7 +202,7 @@ struct mzROIStruct * insertpeak(const double fMass, const double fInten,
202202

203203
if (ddiff <= ddev)
204204
{ // match (smaller than defined ppm) -> extend this ROI
205-
if ( (i > hpos) || (i<lpos) ) error("! scan: %d \n",scan);
205+
if ( (i > hpos) || (i<lpos) ) Rf_error("! scan: %d \n",scan);
206206
wasfound = TRUE;
207207
//recursive m/z mean update
208208
mzval[i].mz = ((mzval[i].length * mzval[i].mz) + fMass) / (mzval[i].length + 1);
@@ -311,7 +311,7 @@ int i,p,del=0;
311311
}
312312
if (entries > ctScan) {
313313
#ifdef DEBUG
314-
error("Warning : entries > ctScan (is this centroid data ?) i: %d m: %3.4f %d entries, lastscan %d (ctScan=%d)\n",i,mzval[i].mz,mzval[i].length,lastscan,ctScan);
314+
Rf_error("Warning : entries > ctScan (is this centroid data ?) i: %d m: %3.4f %d entries, lastscan %d (ctScan=%d)\n",i,mzval[i].mz,mzval[i].length,lastscan,ctScan);
315315
#endif
316316
(*scerr)++;
317317
}
@@ -328,7 +328,7 @@ int i,p,del=0;
328328
p=0;
329329
struct mzROIStruct * tmp = (struct mzROIStruct *) calloc(mzLength->mzval - del, sizeof(struct mzROIStruct));
330330
if (tmp == NULL)
331-
error("findmzROI/cleanup: buffer memory could not be allocated ! (%lu bytes)\n", (mzLength->mzval - del) * sizeof(struct mzROIStruct));
331+
Rf_error("findmzROI/cleanup: buffer memory could not be allocated ! (%lu bytes)\n", (mzLength->mzval - del) * sizeof(struct mzROIStruct));
332332
for (i=0; i < mzLength->mzval; i++) {
333333
if (mzval[i].deleteMe == FALSE) {
334334
tmp[p].mz = mzval[i].mz;
@@ -379,7 +379,7 @@ struct scanBuf * getScan(int scan, double *pmz, double *pintensity, int *pscanin
379379
scanbuf->thisScan= (struct scanStruct *) calloc(N, sizeof(struct scanStruct));
380380
// scanbuf->thisScan= (struct scanStruct *) malloc(N * sizeof(struct scanStruct));
381381
if (scanbuf->thisScan == NULL)
382-
error("findmzROI/getThisScan: Memory could not be allocated!\n");
382+
Rf_error("findmzROI/getThisScan: Memory could not be allocated!\n");
383383

384384
scanbuf->thisScanLength=N;
385385

@@ -411,7 +411,7 @@ struct scanBuf * getScan(int scan, double *pmz, double *pintensity, int *pscanin
411411
if (N > 0) {
412412
scanbuf->nextScan= (double *) calloc(N, sizeof(double));
413413
if (scanbuf->nextScan == NULL)
414-
error("findmzROI/getNextScan: Memory could not be allocated!\n");
414+
Rf_error("findmzROI/getNextScan: Memory could not be allocated!\n");
415415
scanbuf->nextScanLength=N;
416416

417417
for (idx=idx1;idx <= idx2; idx++)
@@ -463,7 +463,7 @@ SEXP getEIC(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, SEXP scanrang
463463
scanrangeFrom = INTEGER(scanrange)[0];
464464
scanrangeTo = INTEGER(scanrange)[1];
465465
if ((scanrangeFrom < firstScan) || (scanrangeFrom > ilastScan) || (scanrangeTo < firstScan) || (scanrangeTo > ilastScan))
466-
error("Error in scanrange \n");
466+
Rf_error("Error in scanrange \n");
467467
char *names[2] = {"scan", "intensity"};
468468
PROTECT(list_names = allocVector(STRSXP, 2));
469469
for(i = 0; i < 2; i++)
@@ -508,7 +508,7 @@ SEXP getMZ(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, SEXP scanrange
508508
scanrangeFrom = INTEGER(scanrange)[0];
509509
scanrangeTo = INTEGER(scanrange)[1];
510510
if ((scanrangeFrom < firstScan) || (scanrangeFrom > ilastScan) || (scanrangeTo < firstScan) || (scanrangeTo > ilastScan))
511-
error("Error in scanrange \n");
511+
Rf_error("Error in scanrange \n");
512512

513513
buflength = scanrangeTo - scanrangeFrom +1;
514514
PROTECT(res = NEW_NUMERIC(buflength));
@@ -563,7 +563,7 @@ SEXP getWeightedMZ(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange,
563563
scanrangeTo = INTEGER(scanrange)[1];
564564
if ((scanrangeFrom < firstScan) || (scanrangeFrom > ilastScan) ||
565565
(scanrangeTo < firstScan) || (scanrangeTo > ilastScan))
566-
error("Error in scanrange \n");
566+
Rf_error("Error in scanrange \n");
567567

568568
buflength = scanrangeTo - scanrangeFrom +1;
569569
PROTECT(res = NEW_NUMERIC(buflength));
@@ -626,11 +626,11 @@ SEXP findmzROI(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange,
626626

627627
struct mzROIStruct * mzROI = (struct mzROIStruct *) calloc(ROI_INIT_LENGTH, sizeof(struct mzROIStruct));
628628
if (mzROI == NULL)
629-
error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",ROI_INIT_LENGTH * sizeof(struct mzROIStruct) );
629+
Rf_error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",ROI_INIT_LENGTH * sizeof(struct mzROIStruct) );
630630

631631
struct mzROIStruct * mzval = (struct mzROIStruct *) calloc(MZVAL_INIT_LENGTH, sizeof(struct mzROIStruct));
632632
if (mzval == NULL)
633-
error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",MZVAL_INIT_LENGTH * sizeof(struct mzROIStruct) );
633+
Rf_error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",MZVAL_INIT_LENGTH * sizeof(struct mzROIStruct) );
634634

635635
mzLength.mzvalTotal = MZVAL_INIT_LENGTH;
636636
mzLength.mzROITotal = ROI_INIT_LENGTH;
@@ -678,7 +678,7 @@ SEXP findmzROI(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange,
678678
fInten = scanbuf->thisScan[p].intensity;
679679

680680
if (fMass < lastMass)
681-
error("m/z sort assumption violated ! (scan %d, p %d, current %2.4f (I=%2.2f), last %2.4f) \n",ctScan,p,fMass,fInten,lastMass);
681+
Rf_error("m/z sort assumption violated ! (scan %d, p %d, current %2.4f (I=%2.2f), last %2.4f) \n",ctScan,p,fMass,fInten,lastMass);
682682
lastMass = fMass;
683683

684684
if (fInten > inoise)

0 commit comments

Comments
 (0)