X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmoments.c;h=3c5e3840207b1f76d5bf15dbc5c5715c4221f9d2;hb=f3cf52b51e6d89e94190de22b1fa813e8d3746f7;hp=c993f7ae0a6d3c65e3c67f8fa891e5fa12b60771;hpb=bf6d99567a762b20bee4bb71147b6387c986bb90;p=pspp diff --git a/src/moments.c b/src/moments.c index c993f7ae0a..3c5e384020 100644 --- a/src/moments.c +++ b/src/moments.c @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "moments.h" @@ -25,6 +25,9 @@ #include "alloc.h" #include "misc.h" #include "val.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) /* Calculates variance, skewness, and kurtosis into *VARIANCE, *SKEWNESS, and *KURTOSIS if they are non-null and not greater @@ -62,9 +65,9 @@ calc_moments (enum moment max_moment, } if (max_moment >= MOMENT_KURTOSIS && kurtosis != NULL && w > 3.) { - double g2 = ((w * (w + 1.) * d4 - - 3. * pow2 (d2) * (w - 1.)) - / ((w - 1.) * (w - 2.) * (w - 3.) * pow2 (s2))); + double den = (w - 2.) * (w - 3.) * pow2 (s2); + double g2 = (w * (w + 1) * d4 / (w - 1.) / den + - 3. * pow2 (d2) / den); if (finite (g2)) *kurtosis = g2; } @@ -501,14 +504,14 @@ read_values (double **values, double **weights, size_t *cnt) *values = NULL; *weights = NULL; *cnt = 0; - while (token == T_NUM) + while (lex_is_number ()) { double value = tokval; double weight = 1.; lex_get (); if (lex_match ('*')) { - if (token != T_NUM) + if (!lex_is_number ()) { lex_error (_("expecting weight value")); return 0; @@ -520,8 +523,8 @@ read_values (double **values, double **weights, size_t *cnt) if (*cnt >= cap) { cap = 2 * (cap + 8); - *values = xrealloc (*values, sizeof **values * cap); - *weights = xrealloc (*weights, sizeof **weights * cap); + *values = xnrealloc (*values, cap, sizeof **values); + *weights = xnrealloc (*weights, cap, sizeof **weights); } (*values)[*cnt] = value;