projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
QUICK CLUSTER: Fix infinite loop on bad command name.
[pspp]
/
src
/
language
/
stats
/
quick-cluster.c
diff --git
a/src/language/stats/quick-cluster.c
b/src/language/stats/quick-cluster.c
index bc66cce795caf06932ed3da6269b306bd0a6cd52..0c871c8bf2d54849e19d4bbbd0c262b371ff666a 100644
(file)
--- a/
src/language/stats/quick-cluster.c
+++ b/
src/language/stats/quick-cluster.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2011, 2012 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012
, 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
@@
-432,14
+432,14
@@
quick_cluster_show_centers (struct Kmeans *kmeans, bool initial, const struct qc
tab_double (t, i + 1, j + 4, TAB_CENTER,
gsl_matrix_get (kmeans->centers,
kmeans->group_order->data[i], j),
tab_double (t, i + 1, j + 4, TAB_CENTER,
gsl_matrix_get (kmeans->centers,
kmeans->group_order->data[i], j),
- var_get_print_format (qc->vars[j]));
+ var_get_print_format (qc->vars[j])
, RC_OTHER
);
}
else
{
tab_double (t, i + 1, j + 4, TAB_CENTER,
gsl_matrix_get (kmeans->initial_centers,
kmeans->group_order->data[i], j),
}
else
{
tab_double (t, i + 1, j + 4, TAB_CENTER,
gsl_matrix_get (kmeans->initial_centers,
kmeans->group_order->data[i], j),
- var_get_print_format (qc->vars[j]));
+ var_get_print_format (qc->vars[j])
, RC_OTHER
);
}
}
}
}
}
}
@@
-548,6
+548,11
@@
cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
{
lex_force_int (lexer);
qc.ngroups = lex_integer (lexer);
{
lex_force_int (lexer);
qc.ngroups = lex_integer (lexer);
+ if (qc.ngroups <= 0)
+ {
+ lex_error (lexer, _("The number of clusters must be positive"));
+ goto error;
+ }
lex_get (lexer);
lex_force_match (lexer, T_RPAREN);
}
lex_get (lexer);
lex_force_match (lexer, T_RPAREN);
}
@@
-558,6
+563,11
@@
cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
{
lex_force_int (lexer);
qc.maxiter = lex_integer (lexer);
{
lex_force_int (lexer);
qc.maxiter = lex_integer (lexer);
+ if (qc.maxiter <= 0)
+ {
+ lex_error (lexer, _("The number of iterations must be positive"));
+ goto error;
+ }
lex_get (lexer);
lex_force_match (lexer, T_RPAREN);
}
lex_get (lexer);
lex_force_match (lexer, T_RPAREN);
}
@@
-566,6
+576,11
@@
cmd_quick_cluster (struct lexer *lexer, struct dataset *ds)
goto error;
}
}
goto error;
}
}
+ else
+ {
+ lex_error (lexer, NULL);
+ goto error;
+ }
}
qc.wv = dict_get_weight (dict);
}
qc.wv = dict_get_weight (dict);