Fixed by where pspp would crash if ELSE appeared without a DO IF.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 31 Mar 2016 07:19:35 +0000 (09:19 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 31 Mar 2016 17:38:22 +0000 (19:38 +0200)
Found by zzuf.

src/language/control/do-if.c
tests/language/control/do-if.at

index 6b6dc16d4de600362035e9d39c35afa1f0e5e456..83de0e39a31a73574bfe0fa0b781dafc96eafbf0 100644 (file)
@@ -124,9 +124,12 @@ int
 cmd_else (struct lexer *lexer UNUSED, struct dataset *ds)
 {
   struct do_if_trns *do_if = ctl_stack_top (&do_if_class);
-  assert (ds == do_if->ds);
+
   if (do_if == NULL || !must_not_have_else (do_if))
     return CMD_CASCADING_FAILURE;
+
+  assert (ds == do_if->ds);
+
   add_else (do_if);
   return CMD_SUCCESS;
 }
index 2136c9b5668f0c48afd329d09505a267f4c9b0e9..c4f9f0e483735951f844886df5a869889b5b5ca3 100644 (file)
@@ -58,3 +58,25 @@ AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
 do-if.sps:2: error: END IF: This command cannot appear outside DO IF...END IF.
 ])
 AT_CLEANUP
+
+
+
+AT_SETUP([ELSE without DO IF])
+AT_DATA([do-if.sps], [dnl
+DATA lIST NOTABLE LIST /QUA BRA *.
+BEGIN DATA
+4  1
+6  3
+END DATA
+
+ELSE QUA 'A string'.
+
+EXECUTE.
+])
+AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
+do-if.sps:7: error: ELSE: This command cannot appear outside DO IF...END IF.
+
+do-if.sps:9: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
+])
+AT_CLEANUP
+