X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Ftests%2Fmoments-test.c;h=e62a34322b0f78e1359115688c4d973dc4b2c9d6;hb=59d14e5581317e3d1e37c8b92b535ba197984776;hp=533b558ff003409d43bd0557f6cf852ec7aef8c1;hpb=244ade48f9c233532cc535d3233fdef53bf9266b;p=pspp diff --git a/src/language/tests/moments-test.c b/src/language/tests/moments-test.c index 533b558ff0..e62a34322b 100644 --- a/src/language/tests/moments-test.c +++ b/src/language/tests/moments-test.c @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -31,27 +30,27 @@ #define _(msgid) gettext (msgid) static bool -read_values (double **values, double **weights, size_t *cnt) +read_values (struct lexer *lexer, double **values, double **weights, size_t *cnt) { size_t cap = 0; *values = NULL; *weights = NULL; *cnt = 0; - while (lex_is_number ()) + while (lex_is_number (lexer)) { - double value = tokval; + double value = lex_tokval (lexer); double weight = 1.; - lex_get (); - if (lex_match ('*')) + lex_get (lexer); + if (lex_match (lexer, '*')) { - if (!lex_is_number ()) + if (!lex_is_number (lexer)) { - lex_error (_("expecting weight value")); + lex_error (lexer, _("expecting weight value")); return false; } - weight = tokval; - lex_get (); + weight = lex_tokval (lexer); + lex_get (lexer); } if (*cnt >= cap) @@ -70,7 +69,7 @@ read_values (double **values, double **weights, size_t *cnt) } int -cmd_debug_moments (struct dataset *ds UNUSED) +cmd_debug_moments (struct lexer *lexer, struct dataset *ds UNUSED) { int retval = CMD_FAILURE; double *values = NULL; @@ -80,22 +79,22 @@ cmd_debug_moments (struct dataset *ds UNUSED) size_t cnt; size_t i; - if (lex_match_id ("ONEPASS")) + if (lex_match_id (lexer, "ONEPASS")) two_pass = 0; - if (token != '/') + if (lex_token (lexer) != '/') { - lex_force_match ('/'); + lex_force_match (lexer, '/'); goto done; } - fprintf (stderr, "%s => ", lex_rest_of_line (NULL)); - lex_get (); + fprintf (stderr, "%s => ", lex_rest_of_line (lexer, NULL)); + lex_get (lexer); if (two_pass) { struct moments *m = NULL; m = moments_create (MOMENT_KURTOSIS); - if (!read_values (&values, &weights, &cnt)) + if (!read_values (lexer, &values, &weights, &cnt)) { moments_destroy (m); goto done; @@ -112,7 +111,7 @@ cmd_debug_moments (struct dataset *ds UNUSED) struct moments1 *m = NULL; m = moments1_create (MOMENT_KURTOSIS); - if (!read_values (&values, &weights, &cnt)) + if (!read_values (lexer, &values, &weights, &cnt)) { moments1_destroy (m); goto done; @@ -126,7 +125,7 @@ cmd_debug_moments (struct dataset *ds UNUSED) fprintf (stderr, "W=%.3f", weight); for (i = 0; i < 4; i++) { - fprintf (stderr, " M%d=", i + 1); + fprintf (stderr, " M%d=", (int) i + 1); if (M[i] == SYSMIS) fprintf (stderr, "sysmis"); else if (fabs (M[i]) <= 0.0005) @@ -136,7 +135,7 @@ cmd_debug_moments (struct dataset *ds UNUSED) } fprintf (stderr, "\n"); - retval = lex_end_of_command (); + retval = lex_end_of_command (lexer); done: free (values);