From: John Darrington Date: Sun, 19 Jul 2009 11:35:35 +0000 (+0200) Subject: Fix cleanup of ROC command. X-Git-Tag: build37~50^2~5 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b08a64f11b282cff537da3d8e8e2992103a3e916;p=pspp-builds.git Fix cleanup of ROC command. Properly deallocate variables, and use correct symbols for parser return values. Also, delete roc.h which is unnecessary. Thanks to Ben Pfaff for pointing out these problems. --- diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index 1e8ac4e0..e7dec56b 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -16,10 +16,10 @@ #include -#include "roc.h" #include #include #include +#include #include #include @@ -98,18 +98,18 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars, PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC)) - return 2; + goto error;; if ( ! lex_force_match (lexer, T_BY)) { - return 2; + goto error;; } roc.state_var = parse_variable (lexer, dict); if ( !lex_force_match (lexer, '(')) { - return 2; + goto error;; } parse_value (lexer, &roc.state_value, var_get_width (roc.state_var)); @@ -117,7 +117,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if ( !lex_force_match (lexer, ')')) { - return 2; + goto error;; } @@ -140,7 +140,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } } } @@ -164,7 +164,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } } else if (lex_match_id (lexer, "PRINT")) @@ -183,7 +183,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } } } @@ -206,7 +206,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } lex_force_match (lexer, ')'); } @@ -224,7 +224,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } lex_force_match (lexer, ')'); } @@ -250,14 +250,14 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } lex_force_match (lexer, ')'); } else { lex_error (lexer, NULL); - return 2; + goto error;; } } } @@ -268,9 +268,14 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) } } - run_roc (ds, &roc); + if ( ! run_roc (ds, &roc)) + goto error;; - return 1; + return CMD_SUCCESS; + + error: + free (roc.vars); + return CMD_FAILURE; } diff --git a/src/language/stats/roc.h b/src/language/stats/roc.h deleted file mode 100644 index 54028d58..00000000 --- a/src/language/stats/roc.h +++ /dev/null @@ -1,24 +0,0 @@ -/* PSPP - a program for statistical analysis. - Copyright (C) 2009 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 - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -#ifndef ROC_H -#define ROC_H - -struct dataset; -struct lexer; -int cmd_roc (struct lexer *lexer, struct dataset *ds); - -#endif