Fixed bug in command line parser
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 11 Aug 2013 06:53:52 +0000 (08:53 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 11 Aug 2013 06:53:52 +0000 (08:53 +0200)
src/libpspp/argv-parser.c
tests/ui/terminal/main.at

index c72c250394864091bb8bcd3458cb8bfae413c2c1..97ec02834a43d02baf4598c9b5c05d8832960c8b 100644 (file)
@@ -162,7 +162,7 @@ argv_parser_run (struct argv_parser *ap, int argc, char **argv)
           retval = false;
           break;
         }
-      else if (c >= LONGOPT_VAL_BASE && c < LONGOPT_VAL_BASE + n_longopts)
+      else if (c >= LONGOPT_VAL_BASE && c < LONGOPT_VAL_BASE + n_longopts + 1)
         {
           struct argv_option_plus *aop = &ap->options[c - LONGOPT_VAL_BASE];
           aop->cb (aop->base.id, aop->aux);
index 38a88eca14a779174d838d8218ad836f2690c36e..2f682e8d2d6b4ed245096da4e8d651914bbc5571 100644 (file)
@@ -36,3 +36,16 @@ proximate cause:     Segmentation Violation
 ])
 AT_CHECK([sed '/proximate/q' < stderr], [0], [expout])
 AT_CLEANUP
+
+
+dnl This tests for a crash which was observed with --syntax
+AT_SETUP([argument parsing])
+
+AT_DATA([main.sps], [dnl
+ECHO 'This is a test'.
+FINISH.
+])
+
+AT_CHECK([pspp --syntax=enhanced main.sps], [0], [ignore])
+
+AT_CLEANUP