From: John Darrington Date: Sun, 11 Aug 2013 06:53:52 +0000 (+0200) Subject: Fixed bug in command line parser X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=300b8be9a0ce46e5dae3895b99bc8d54eaf6edfb;p=pspp Fixed bug in command line parser --- diff --git a/src/libpspp/argv-parser.c b/src/libpspp/argv-parser.c index c72c250394..97ec02834a 100644 --- a/src/libpspp/argv-parser.c +++ b/src/libpspp/argv-parser.c @@ -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); diff --git a/tests/ui/terminal/main.at b/tests/ui/terminal/main.at index 38a88eca14..2f682e8d2d 100644 --- a/tests/ui/terminal/main.at +++ b/tests/ui/terminal/main.at @@ -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