X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcompute.c;h=6556e8becac0041d63303556817f6f203f4fd09d;hb=3caec9acde088184ec125733b3bdfd7e1cd019a8;hp=9c20e0ee781f1999922790eaa421807d01115b72;hpb=37597beca4a11edba50b847932fdfeca3a648fa2;p=pspp diff --git a/src/compute.c b/src/compute.c index 9c20e0ee78..6556e8beca 100644 --- a/src/compute.c +++ b/src/compute.c @@ -18,10 +18,12 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" +#include "case.h" #include "command.h" +#include "dictionary.h" #include "error.h" #include "expr.h" #include "lexer.h" @@ -75,8 +77,6 @@ cmd_compute (void) struct lvalue *lvalue = NULL; struct compute_trns *compute = NULL; - lex_match_id ("COMPUTE"); - lvalue = lvalue_parse (); if (lvalue == NULL) goto fail; @@ -114,7 +114,8 @@ compute_num (struct trns_header *compute_, struct ccase *c, if (compute->test == NULL || expr_evaluate (compute->test, c, case_num, NULL) == 1.0) { - expr_evaluate (compute->rvalue, c, case_num, &c->data[compute->fv]); + expr_evaluate (compute->rvalue, c, case_num, + case_data_rw (c, compute->fv)); } return -1; @@ -151,7 +152,7 @@ compute_num_vec (struct trns_header *compute_, struct ccase *c, return -1; } expr_evaluate (compute->rvalue, c, case_num, - &c->data[compute->vector->var[rindx - 1]->fv]); + case_data_rw (c, compute->vector->var[rindx - 1]->fv)); } return -1; @@ -171,8 +172,8 @@ compute_str (struct trns_header *compute_, struct ccase *c, union value v; expr_evaluate (compute->rvalue, c, case_num, &v); - st_bare_pad_len_copy (c->data[compute->fv].s, &v.c[1], compute->width, - v.c[0]); + st_bare_pad_len_copy (case_data_rw (c, compute->fv)->s, + &v.c[1], compute->width, v.c[0]); } return -1; @@ -218,7 +219,8 @@ compute_str_vec (struct trns_header *compute_, struct ccase *c, expr_evaluate (compute->rvalue, c, case_num, &v); vr = compute->vector->var[rindx - 1]; - st_bare_pad_len_copy (c->data[vr->fv].s, &v.c[1], vr->width, v.c[0]); + st_bare_pad_len_copy (case_data_rw (c, vr->fv)->s, + &v.c[1], vr->width, v.c[0]); } return -1; @@ -232,11 +234,10 @@ cmd_if (void) struct compute_trns *compute = NULL; struct lvalue *lvalue = NULL; - lex_match_id ("IF"); compute = compute_trns_create (); /* Test expression. */ - compute->test = expr_parse (PXP_BOOLEAN); + compute->test = expr_parse (EXPR_BOOLEAN); if (compute->test == NULL) goto fail; @@ -279,7 +280,7 @@ parse_rvalue_expression (struct compute_trns *compute, assert (type == NUMERIC || type == ALPHA); - compute->rvalue = expr_parse (type == ALPHA ? PXP_STRING : PXP_NUMERIC); + compute->rvalue = expr_parse (type == ALPHA ? EXPR_STRING : EXPR_NUMERIC); if (compute->rvalue == NULL) return 0; @@ -360,7 +361,7 @@ lvalue_parse (void) lex_get (); if (!lex_force_match ('(')) goto lossage; - lvalue->element = expr_parse (PXP_NUMERIC); + lvalue->element = expr_parse (EXPR_NUMERIC); if (lvalue->element == NULL) goto lossage; if (!lex_force_match (')')) @@ -442,25 +443,3 @@ lvalue_destroy (struct lvalue *lvalue) expr_free (lvalue->element); free (lvalue); } - -/* EVALUATE. */ - -int -cmd_evaluate (void) -{ - struct expression *expr; - - lex_match_id ("EVALUATE"); - expr = expr_parse (PXP_DUMP); - if (!expr) - return CMD_FAILURE; - - expr_free (expr); - if (token != '.') - { - msg (SE, _("Extra characters after expression.")); - return CMD_FAILURE; - } - - return CMD_SUCCESS; -}