projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Revert "added a description how to update linux distributions"
[pspp]
/
src
/
language
/
stats
/
t-test-parser.c
diff --git
a/src/language/stats/t-test-parser.c
b/src/language/stats/t-test-parser.c
index 089d0dd8a691db2d76c636afe91969ca95c16ce2..26fc7ba56cb7307fc37c32b226fdbc12550c8cb0 100644
(file)
--- a/
src/language/stats/t-test-parser.c
+++ b/
src/language/stats/t-test-parser.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2011 Free Software Foundation, Inc.
+ Copyright (C) 2011
, 2015
Free Software Foundation, Inc.
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
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
@@
-44,10
+44,10
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
/* Variables pertaining to the paired mode */
const struct variable **v1 = NULL;
/* Variables pertaining to the paired mode */
const struct variable **v1 = NULL;
- size_t n_v1;
+ size_t n_v1
= 0
;
const struct variable **v2 = NULL;
const struct variable **v2 = NULL;
- size_t n_v2;
-
+ size_t n_v2
= 0
;
+
size_t n_pairs = 0;
vp *pairs = NULL;
size_t n_pairs = 0;
vp *pairs = NULL;
@@
-80,7
+80,8
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
mode_count++;
tt.mode = MODE_SINGLE;
lex_match (lexer, T_EQUALS);
mode_count++;
tt.mode = MODE_SINGLE;
lex_match (lexer, T_EQUALS);
- lex_force_num (lexer);
+ if (!lex_force_num (lexer))
+ goto parse_failed;
testval = lex_number (lexer);
lex_get (lexer);
}
testval = lex_number (lexer);
lex_get (lexer);
}
@@
-93,21
+94,23
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
if (NULL == (gvar = parse_variable (lexer, dict)))
goto parse_failed;
if (NULL == (gvar = parse_variable (lexer, dict)))
goto parse_failed;
-
+
if (lex_match (lexer, T_LPAREN))
{
value_init (&gval0, var_get_width (gvar));
parse_value (lexer, &gval0, gvar);
cut = true;
if (lex_match (lexer, T_LPAREN))
{
value_init (&gval0, var_get_width (gvar));
parse_value (lexer, &gval0, gvar);
cut = true;
- if (lex_
match (lexer, T_COMMA)
)
+ if (lex_
token (lexer) != T_RPAREN
)
{
{
+ lex_match (lexer, T_COMMA);
value_init (&gval1, var_get_width (gvar));
parse_value (lexer, &gval1, gvar);
cut = false;
}
value_init (&gval1, var_get_width (gvar));
parse_value (lexer, &gval1, gvar);
cut = false;
}
- lex_force_match (lexer, T_RPAREN);
+ if (! lex_force_match (lexer, T_RPAREN))
+ goto parse_failed;
}
else
{
}
else
{
@@
-120,8
+123,8
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
if ( cut == true && var_is_alpha (gvar))
{
if ( cut == true && var_is_alpha (gvar))
{
- msg (SE, _("When applying
GROUPS
to a string variable, two "
- "values must be specified."));
+ msg (SE, _("When applying
%s
to a string variable, two "
+ "values must be specified.")
, "GROUPS"
);
goto parse_failed;
}
}
goto parse_failed;
}
}
@@
-132,7
+135,7
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
if (tt.n_vars > 0)
{
if (tt.n_vars > 0)
{
- msg (SE, _("
VARIABLES subcommand may not be used with PAIRS.")
);
+ msg (SE, _("
%s subcommand may not be used with %s."), "VARIABLES", "PAIRS"
);
goto parse_failed;
}
goto parse_failed;
}
@@
-177,7
+180,7
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
n_pairs = n_v1;
else
n_pairs = n_v1 * n_v2;
n_pairs = n_v1;
else
n_pairs = n_v1 * n_v2;
-
+
pairs = xcalloc (n_pairs, sizeof *pairs);
if ( with)
pairs = xcalloc (n_pairs, sizeof *pairs);
if ( with)
@@
-190,7
+193,7
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
vp *pair = &pairs[i];
(*pair)[0] = v1[i];
(*pair)[1] = v2[i];
vp *pair = &pairs[i];
(*pair)[0] = v1[i];
(*pair)[1] = v2[i];
- }
+ }
}
else
{
}
else
{
@@
-228,7
+231,7
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
{
if ( tt.mode == MODE_PAIRED)
{
{
if ( tt.mode == MODE_PAIRED)
{
- msg (SE, _("
VARIABLES subcommand may not be used with PAIRS.")
);
+ msg (SE, _("
%s subcommand may not be used with %s."), "VARIABLES", "PAIRS"
);
goto parse_failed;
}
goto parse_failed;
}
@@
-272,16
+275,18
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
else if (lex_match_id (lexer, "CRITERIA"))
{
lex_match (lexer, T_EQUALS);
else if (lex_match_id (lexer, "CRITERIA"))
{
lex_match (lexer, T_EQUALS);
- if ( lex_
force_match_id (lexer, "CIN
"))
+ if ( lex_
match_id (lexer, "CIN") || lex_force_match_id (lexer, "CI
"))
if ( lex_force_match (lexer, T_LPAREN))
{
if ( lex_force_match (lexer, T_LPAREN))
{
- lex_force_num (lexer);
+ if (!lex_force_num (lexer))
+ goto parse_failed;
tt.confidence = lex_number (lexer);
lex_get (lexer);
tt.confidence = lex_number (lexer);
lex_get (lexer);
- lex_force_match (lexer, T_RPAREN);
+ if (! lex_force_match (lexer, T_RPAREN))
+ goto parse_failed;
}
}
}
}
- else
+ else
{
lex_error (lexer, NULL);
goto parse_failed;
{
lex_error (lexer, NULL);
goto parse_failed;
@@
-297,7
+302,7
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
if (tt.n_vars == 0 && tt.mode != MODE_PAIRED)
{
if (tt.n_vars == 0 && tt.mode != MODE_PAIRED)
{
-
msg (SE, _("One or more VARIABLES must be specified.")
);
+
lex_sbc_missing ("VARIABLES"
);
goto parse_failed;
}
goto parse_failed;
}
@@
-362,12
+367,17
@@
cmd_t_test (struct lexer *lexer, struct dataset *ds)
free (pairs);
free (v1);
free (v2);
free (pairs);
free (v1);
free (v2);
-
free (tt.vars);
return ok ? CMD_SUCCESS : CMD_FAILURE;
parse_failed:
free (tt.vars);
return ok ? CMD_SUCCESS : CMD_FAILURE;
parse_failed:
+
+ free (pairs);
+ free (v1);
+ free (v2);
+ free (tt.vars);
+
return CMD_FAILURE;
}
return CMD_FAILURE;
}