X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fxforms%2Fcompute.c;h=442c15a4964d7118bf5d125bb6a640053c722d6d;hb=55e6e7ba37a30570f5a31e2d78c22dfa7b61a36f;hp=9f65491ef50afdd1485d74e7faf84d49e635704d;hpb=8af88c0b7ea2fe75df7e45497988ed0371006a86;p=pspp-builds.git diff --git a/src/language/xforms/compute.c b/src/language/xforms/compute.c index 9f65491e..442c15a4 100644 --- a/src/language/xforms/compute.c +++ b/src/language/xforms/compute.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2009, 2010 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 @@ -90,7 +90,7 @@ cmd_compute (struct lexer *lexer, struct dataset *ds) if (lvalue == NULL) goto fail; - if (!lex_force_match (lexer, '=')) + if (!lex_force_match (lexer, T_EQUALS)) goto fail; compute->rvalue = parse_rvalue (lexer, lvalue, ds); if (compute->rvalue == NULL) @@ -173,10 +173,11 @@ compute_str (void *compute_, struct ccase **c, casenumber case_num) if (compute->test == NULL || expr_evaluate_num (compute->test, *c, case_num) == 1.0) { + char *s; + *c = case_unshare (*c); - expr_evaluate_str (compute->rvalue, *c, case_num, - case_data_rw (*c, compute->variable)->s, - compute->width); + s = CHAR_CAST_BUG (char *, case_str_rw (*c, compute->variable)); + expr_evaluate_str (compute->rvalue, *c, case_num, s, compute->width); } return TRNS_CONTINUE; @@ -216,7 +217,7 @@ compute_str_vec (void *compute_, struct ccase **c, casenumber case_num) vr = vector_get_var (compute->vector, rindx - 1); *c = case_unshare (*c); expr_evaluate_str (compute->rvalue, *c, case_num, - case_data_rw (*c, vr)->s, + CHAR_CAST_BUG (char *, case_str_rw (*c, vr)), var_get_width (vr)); } @@ -245,7 +246,7 @@ cmd_if (struct lexer *lexer, struct dataset *ds) goto fail; /* Rvalue expression. */ - if (!lex_force_match (lexer, '=')) + if (!lex_force_match (lexer, T_EQUALS)) goto fail; compute->rvalue = parse_rvalue (lexer, lvalue, ds); if (compute->rvalue == NULL) @@ -345,30 +346,30 @@ lvalue_parse (struct lexer *lexer, struct dataset *ds) if (!lex_force_id (lexer)) goto lossage; - if (lex_look_ahead (lexer) == '(') + if (lex_look_ahead (lexer) == T_LPAREN) { /* Vector. */ - lvalue->vector = dict_lookup_vector (dict, lex_tokid (lexer)); + lvalue->vector = dict_lookup_vector (dict, lex_tokcstr (lexer)); if (lvalue->vector == NULL) { - msg (SE, _("There is no vector named %s."), lex_tokid (lexer)); + msg (SE, _("There is no vector named %s."), lex_tokcstr (lexer)); goto lossage; } /* Vector element. */ lex_get (lexer); - if (!lex_force_match (lexer, '(')) + if (!lex_force_match (lexer, T_LPAREN)) goto lossage; lvalue->element = expr_parse (lexer, ds, EXPR_NUMBER); if (lvalue->element == NULL) goto lossage; - if (!lex_force_match (lexer, ')')) + if (!lex_force_match (lexer, T_RPAREN)) goto lossage; } else { /* Variable name. */ - const char *var_name = lex_tokid (lexer); + const char *var_name = lex_tokcstr (lexer); lvalue->variable = dict_lookup_var (dict, var_name); if (lvalue->variable == NULL) {