X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fsel-if.c;h=10d1030f004f70eb4419c2a1a060482e2519bebf;hb=6950df40513e606e6be42fa83a36a281f654d553;hp=6f6f2d0279269083acb9e072e6648d9c9bf73285;hpb=97d6c6f6b1922621ca013668eba9a9a9f71d60fe;p=pspp-builds.git diff --git a/src/sel-if.c b/src/sel-if.c index 6f6f2d02..10d1030f 100644 --- a/src/sel-if.c +++ b/src/sel-if.c @@ -14,22 +14,26 @@ 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 #include "alloc.h" #include "command.h" +#include "dictionary.h" #include "error.h" -#include "expr.h" +#include "expressions/public.h" #include "lexer.h" #include "str.h" #include "var.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* SELECT IF transformation. */ struct select_if_trns { - struct trns_header h; struct expression *e; /* Test expression. */ }; @@ -43,7 +47,7 @@ cmd_select_if (void) struct expression *e; struct select_if_trns *t; - e = expr_parse (EXPR_BOOLEAN); + e = expr_parse (default_dict, EXPR_BOOLEAN); if (!e) return CMD_FAILURE; @@ -55,28 +59,28 @@ cmd_select_if (void) } t = xmalloc (sizeof *t); - t->h.proc = select_if_proc; - t->h.free = select_if_free; t->e = e; - add_transformation ((struct trns_header *) t); + add_transformation (select_if_proc, select_if_free, t); return CMD_SUCCESS; } /* Performs the SELECT IF transformation T on case C. */ static int -select_if_proc (struct trns_header * t, struct ccase * c, +select_if_proc (void *t_, struct ccase *c, int case_num) { - return (expr_evaluate (((struct select_if_trns *) t)->e, c, - case_num, NULL) == 1.0) - 2; + struct select_if_trns *t = t_; + return expr_evaluate_num (t->e, c, case_num) == 1.0 ? -1 : -2; } /* Frees SELECT IF transformation T. */ static void -select_if_free (struct trns_header * t) +select_if_free (void *t_) { - expr_free (((struct select_if_trns *) t)->e); + struct select_if_trns *t = t_; + expr_free (t->e); + free (t); } /* Parses the FILTER command. */ @@ -120,7 +124,7 @@ cmd_process_if (void) { struct expression *e; - e = expr_parse (EXPR_BOOLEAN); + e = expr_parse (default_dict, EXPR_BOOLEAN); if (!e) return CMD_FAILURE;