ext/histogram.c in rb-gsl-1.15.3.1 vs ext/histogram.c in rb-gsl-1.15.3.2

- old
+ new

@@ -116,11 +116,12 @@ double upper; strcpy(filename, STR2CHARPTR(name)); sprintf(buf, "wc %s", filename); fp = popen(buf, "r"); if (fp == NULL) rb_raise(rb_eIOError, "popen failed."); - fgets(buf, 1024, fp); + if (fgets(buf, 1024, fp) == NULL) + rb_sys_fail(0); pclose(fp); sscanf(buf, "%d", &nn); n = (size_t) nn; /* vector length */ fp = fopen(filename, "r"); if (fp == NULL) rb_raise(rb_eIOError, "cannot open file %s.", filename); @@ -353,11 +354,11 @@ break; } Data_Get_Struct(obj, gsl_histogram, h); if (TYPE(argv[0]) == T_ARRAY) { // for (i = 0; i < RARRAY(argv[0])->len; i++) - for (i = 0; i < RARRAY_LEN(argv[0]); i++) + for (i = 0; (int) i < RARRAY_LEN(argv[0]); i++) gsl_histogram_accumulate(h, NUM2DBL(rb_ary_entry(argv[0], i)), weight); } else if (VECTOR_P(argv[0])) { Data_Get_Struct(argv[0], gsl_vector, v); for (i = 0; i < v->size; i++) gsl_histogram_accumulate(h, gsl_vector_get(v, i), weight); @@ -1554,17 +1555,17 @@ void mygsl_histogram_integrate(const gsl_histogram *h, gsl_histogram *hi, size_t istart, size_t iend) { size_t i; if (iend >= istart) { - if (istart < 0) istart = 0; + //if (istart < 0) istart = 0; if (iend >= h->n) iend = h->n-1; hi->bin[istart] = h->bin[istart]; for (i = istart+1; i <= iend; i++) hi->bin[i] = hi->bin[i-1] + h->bin[i]; } else { if (istart >= h->n) istart = h->n-1; - if (iend < 0) iend = 0; + //if (iend < 0) iend = 0; hi->bin[istart] = h->bin[istart]; for (i = istart-1; i >= iend; i--) { hi->bin[i] = hi->bin[i+1] + h->bin[i]; if (i == 0) break; } @@ -1767,11 +1768,11 @@ * is found. */ static double histogram_percentile(const gsl_histogram *h, double f) { double sum = gsl_histogram_sum(h), sf; - double val, s = 0, x; + double val = 0, s = 0, x; double ri, ri1; size_t i; sf = sum * f; for (i = 0; i < h->n; i++) { val = gsl_histogram_get(h, i); @@ -1804,10 +1805,10 @@ } static double histogram_percentile_inv(const gsl_histogram *h, double x) { double sum = gsl_histogram_sum(h); - double val, s = 0; + double val = 0, s = 0; double ri, ri1, q; size_t i; for (i = 0; i < h->n; i++) { val = gsl_histogram_get(h, i);