X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdo-if.c;h=fa12f6852ae7833fafab4a725f2bebd45abf22ee;hb=6d7e2826ba9c863f6261e9718e0e822e0ca60aa0;hp=b0014484f0b6d04ee0c0d9ae78942844863dc5c3;hpb=7b98b3a4f58f6dc5a8e9cbc188b627966d5e652d;p=pspp diff --git a/src/do-if.c b/src/do-if.c index b0014484f0..fa12f6852a 100644 --- a/src/do-if.c +++ b/src/do-if.c @@ -14,27 +14,23 @@ 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 "do-ifP.h" -#include +#include "error.h" #include #include "alloc.h" #include "command.h" #include "error.h" -#include "expr.h" +#include "expressions/public.h" #include "lexer.h" #include "str.h" #include "var.h" #include "debug-print.h" -#if DEBUGGING -#include -#endif - /* *INDENT-OFF* */ /* Description of DO IF transformations: @@ -76,9 +72,8 @@ static struct do_if_trns *parse_do_if (void); static void add_ELSE_IF (struct do_if_trns *); -static int goto_trns_proc (struct trns_header *, struct ccase *); -static int do_if_trns_proc (struct trns_header *, struct ccase *); -static void do_if_trns_free (struct trns_header *); +static trns_proc_func goto_trns_proc, do_if_trns_proc; +static trns_free_func do_if_trns_free; /* Parse DO IF. */ int @@ -156,8 +151,6 @@ cmd_else (void) { struct do_if_trns *t; - lex_match_id ("ELSE"); - /* Check that we're in a pleasing situation. */ if (!ctl_stack || ctl_stack->type != CST_DO_IF) { @@ -199,8 +192,6 @@ cmd_end_if (void) /* List iterator. */ struct do_if_trns *iter; - lex_match_id ("IF"); - /* Check that we're in a pleasing situation. */ if (!ctl_stack || ctl_stack->type != CST_DO_IF) { @@ -253,9 +244,7 @@ parse_do_if (void) struct do_if_trns *t; struct expression *e; - lex_match_id ("IF"); - - e = expr_parse (PXP_BOOLEAN); + e = expr_parse (default_dict, EXPR_BOOLEAN); if (!e) return NULL; if (token != '.') @@ -276,24 +265,26 @@ parse_do_if (void) /* Executes a goto transformation. */ static int -goto_trns_proc (struct trns_header * t, struct ccase * c UNUSED) +goto_trns_proc (struct trns_header * t, struct ccase * c UNUSED, + int case_num UNUSED) { return ((struct goto_trns *) t)->dest; } static int -do_if_trns_proc (struct trns_header * trns, struct ccase * c) +do_if_trns_proc (struct trns_header * trns, struct ccase * c, + int case_num UNUSED) { struct do_if_trns *t = (struct do_if_trns *) trns; - union value bool; + double boolean; - expr_evaluate (t->cond, c, &bool); - if (bool.f == 1.0) + boolean = expr_evaluate_num (t->cond, c, case_num); + if (boolean == 1.0) { debug_printf ((_("DO IF %d: true\n"), t->h.index)); return -1; } - else if (bool.f == 0.0) + else if (boolean == 0.0) { debug_printf ((_("DO IF %d: false\n"), t->h.index)); return t->false_jump;