From 205ac3afa4c2b19c85819d8695abf3975bb11807 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 21 Mar 2004 08:41:19 +0000 Subject: [PATCH] Added custom assert(); Fixed bugs in T-TEST and VALUE LABELS --- po/en_GB.po | 38 +++++++++++++++++++---- po/pspp.pot | 38 +++++++++++++++++++---- src/ChangeLog | 11 +++++++ src/aggregate.c | 2 +- src/algorithm.c | 2 +- src/alloc.c | 2 +- src/ascii.c | 2 +- src/autorecode.c | 2 +- src/cmdline.c | 2 +- src/command.c | 2 +- src/compute.c | 2 +- src/count.c | 2 +- src/crosstabs.q | 2 +- src/data-in.c | 2 +- src/data-list.c | 2 +- src/data-out.c | 2 +- src/descript.q | 2 +- src/devind.c | 2 +- src/dfm.c | 2 +- src/dictionary.c | 2 +- src/do-if.c | 2 +- src/error.c | 53 +++++++++++++++++++++++++++++++- src/error.h | 14 +++++++++ src/expr-evl.c | 2 +- src/expr-opt.c | 2 +- src/expr-prs.c | 2 +- src/file-handle.q | 2 +- src/file-type.c | 2 +- src/filename.c | 2 +- src/flip.c | 2 +- src/format.c | 2 +- src/frequencies.q | 2 +- src/get.c | 2 +- src/getline.c | 2 +- src/glob.c | 2 +- src/groff-font.c | 2 +- src/hash.c | 4 +-- src/html.c | 2 +- src/inpt-pgm.c | 2 +- src/levene.c | 2 +- src/lexer.c | 2 +- src/list.q | 2 +- src/loop.c | 2 +- src/main.c | 35 +-------------------- src/matrix-data.c | 2 +- src/matrix.c | 2 +- src/means.q | 2 +- src/mis-val.c | 2 +- src/modify-vars.c | 2 +- src/numeric.c | 2 +- src/output.c | 2 +- src/pfm-read.c | 2 +- src/pfm-write.c | 2 +- src/pool.c | 2 +- src/postscript.c | 2 +- src/print.c | 2 +- src/q2c.c | 1 - src/random.c | 2 +- src/recode.c | 2 +- src/rename-vars.c | 2 +- src/repeat.c | 2 +- src/set.q | 2 +- src/sfm-read.c | 2 +- src/sfm-write.c | 2 +- src/som.c | 2 +- src/sort.c | 2 +- src/str.c | 2 +- src/sysfile-info.c | 2 +- src/t-test.q | 26 +++++----------- src/tab.c | 2 +- src/temporary.c | 2 +- src/val-labs.c | 11 +++++-- src/value-labels.c | 2 +- src/vars-atr.c | 2 +- src/vars-prs.c | 1 - src/vector.c | 2 +- src/vfm.c | 2 +- src/weight.c | 2 +- tests/Makefile.am | 4 ++- tests/bugs/t-test.sh | 70 ++++++++++++++++++++++++++++++++++++++++++ tests/bugs/val-labs.sh | 70 ++++++++++++++++++++++++++++++++++++++++++ 81 files changed, 370 insertions(+), 140 deletions(-) create mode 100755 tests/bugs/t-test.sh create mode 100755 tests/bugs/val-labs.sh diff --git a/po/en_GB.po b/po/en_GB.po index 80e9967b..fb025f4e 100644 --- a/po/en_GB.po +++ b/po/en_GB.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.3.1\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2004-03-20 00:30+0800\n" +"POT-Creation-Date: 2004-03-21 10:15+0800\n" "PO-Revision-Date: 2004-01-23 13:04+0800\n" "Last-Translator: John Darrington \n" "Language-Team: John Darrington \n" @@ -2105,11 +2105,11 @@ msgstr "" msgid "expecting %s" msgstr "" -#: src/lexer.c:524 src/val-labs.c:148 +#: src/lexer.c:524 src/val-labs.c:155 msgid "expecting string" msgstr "" -#: src/lexer.c:538 src/val-labs.c:157 +#: src/lexer.c:538 src/val-labs.c:164 msgid "expecting integer" msgstr "" @@ -2193,6 +2193,32 @@ msgstr "" msgid "%s without %s." msgstr "" +#: src/main.c:71 +msgid "Error initializing output drivers." +msgstr "" + +#: src/main.c:132 +msgid "This command not executed." +msgstr "" + +#: src/main.c:136 +msgid "" +"Skipping the rest of this command. Part of this command may have been " +"executed." +msgstr "" + +#: src/main.c:141 +msgid "" +"Skipping the rest of this command. This command was fully executed up to " +"this point." +msgstr "" + +#: src/main.c:146 +msgid "" +"Trailing garbage was encountered following this command. The command was " +"fully executed to this point." +msgstr "" + #: src/matrix-data.c:191 msgid "VARIABLES subcommand multiply specified." msgstr "" @@ -3929,19 +3955,19 @@ msgstr "" msgid "Document entered %s %02d:%02d:%02d by %s (%s):" msgstr "" -#: src/val-labs.c:112 +#: src/val-labs.c:119 #, c-format msgid "" "It is not possible to assign value labels to long string variables such as %" "s." msgstr "" -#: src/val-labs.c:161 +#: src/val-labs.c:168 #, c-format msgid "Value label `%g' is not integer." msgstr "" -#: src/val-labs.c:171 +#: src/val-labs.c:178 msgid "Truncating value label to 60 characters." msgstr "" diff --git a/po/pspp.pot b/po/pspp.pot index 90b5cffc..07102dc2 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2004-03-20 00:30+0800\n" +"POT-Creation-Date: 2004-03-21 10:15+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2106,11 +2106,11 @@ msgstr "" msgid "expecting %s" msgstr "" -#: src/lexer.c:524 src/val-labs.c:148 +#: src/lexer.c:524 src/val-labs.c:155 msgid "expecting string" msgstr "" -#: src/lexer.c:538 src/val-labs.c:157 +#: src/lexer.c:538 src/val-labs.c:164 msgid "expecting integer" msgstr "" @@ -2194,6 +2194,32 @@ msgstr "" msgid "%s without %s." msgstr "" +#: src/main.c:71 +msgid "Error initializing output drivers." +msgstr "" + +#: src/main.c:132 +msgid "This command not executed." +msgstr "" + +#: src/main.c:136 +msgid "" +"Skipping the rest of this command. Part of this command may have been " +"executed." +msgstr "" + +#: src/main.c:141 +msgid "" +"Skipping the rest of this command. This command was fully executed up to " +"this point." +msgstr "" + +#: src/main.c:146 +msgid "" +"Trailing garbage was encountered following this command. The command was " +"fully executed to this point." +msgstr "" + #: src/matrix-data.c:191 msgid "VARIABLES subcommand multiply specified." msgstr "" @@ -3930,19 +3956,19 @@ msgstr "" msgid "Document entered %s %02d:%02d:%02d by %s (%s):" msgstr "" -#: src/val-labs.c:112 +#: src/val-labs.c:119 #, c-format msgid "" "It is not possible to assign value labels to long string variables such as %" "s." msgstr "" -#: src/val-labs.c:161 +#: src/val-labs.c:168 #, c-format msgid "Value label `%g' is not integer." msgstr "" -#: src/val-labs.c:171 +#: src/val-labs.c:178 msgid "Truncating value label to 60 characters." msgstr "" diff --git a/src/ChangeLog b/src/ChangeLog index 14de8621..edc5c34d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +Sun Mar 21 10:11:14 WST 2004 John Darrington + + * val-labs.c: Fixed a bug where PSPP would crash, if VALUE LABELS was + used with incorrect syntax. + + * error.c, error.h et al: Overridden definition of assert for a + custom one. + + * test-q.c: Fixed a buglet where it would crash if no /VARIABLES + subcommand was given when it ought to have been. + Sat Mar 20 22:19:08 2004 Ben Pfaff * tab.c: (tab_vline) Fix assertions to respect row_ofs and diff --git a/src/aggregate.c b/src/aggregate.c index 19312508..3821de78 100644 --- a/src/aggregate.c +++ b/src/aggregate.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/algorithm.c b/src/algorithm.c index aaa2b846..f294887b 100644 --- a/src/algorithm.c +++ b/src/algorithm.c @@ -102,7 +102,7 @@ #if __OPTIMIZE__ #define NDEBUG #endif -#include +#include "error.h" /* Finds an element in ARRAY, which contains COUNT elements of SIZE bytes each, using COMPARE for comparisons. Returns the diff --git a/src/alloc.c b/src/alloc.c index 267bf2ba..0da8f744 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -19,7 +19,7 @@ #include #include "alloc.h" -#include +#include "error.h" #include #include #include "str.h" diff --git a/src/ascii.c b/src/ascii.c index d1818aad..72e536b1 100644 --- a/src/ascii.c +++ b/src/ascii.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include diff --git a/src/autorecode.c b/src/autorecode.c index 52104e7a..9a9b3a07 100644 --- a/src/autorecode.c +++ b/src/autorecode.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/cmdline.c b/src/cmdline.c index fd4e6c45..b72f545b 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -19,7 +19,7 @@ #include #include "cmdline.h" -#include +#include "error.h" #include #include #include diff --git a/src/command.c b/src/command.c index b6a0babe..37608055 100644 --- a/src/command.c +++ b/src/command.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include "command.h" #include #include diff --git a/src/compute.c b/src/compute.c index b08e76fe..7ef93858 100644 --- a/src/compute.c +++ b/src/compute.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/count.c b/src/count.c index 0fc7370b..058d60d5 100644 --- a/src/count.c +++ b/src/count.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/crosstabs.q b/src/crosstabs.q index b16cb02c..09a7f761 100644 --- a/src/crosstabs.q +++ b/src/crosstabs.q @@ -30,7 +30,7 @@ */ #include -#include +#include "error.h" #include #include #include diff --git a/src/data-in.c b/src/data-in.c index 0c477fa2..3931067d 100644 --- a/src/data-in.c +++ b/src/data-in.c @@ -19,7 +19,7 @@ #include #include "data-in.h" -#include +#include "error.h" #include #include #include diff --git a/src/data-list.c b/src/data-list.c index da75d5d3..044754d2 100644 --- a/src/data-list.c +++ b/src/data-list.c @@ -19,7 +19,7 @@ #include #include "data-list.h" -#include +#include "error.h" #include #include #include diff --git a/src/data-out.c b/src/data-out.c index 1206dd99..de9bfad3 100644 --- a/src/data-out.c +++ b/src/data-out.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include diff --git a/src/descript.q b/src/descript.q index 9ac10325..9ba2b569 100644 --- a/src/descript.q +++ b/src/descript.q @@ -20,7 +20,7 @@ /* FIXME: Many possible optimizations. */ #include -#include +#include "error.h" #include #include #include diff --git a/src/devind.c b/src/devind.c index 4a8da54a..834e96e0 100644 --- a/src/devind.c +++ b/src/devind.c @@ -88,7 +88,7 @@ #include #include "devind.h" -#include +#include "error.h" #include #include #include diff --git a/src/dfm.c b/src/dfm.c index f9aa5741..dd9755ed 100644 --- a/src/dfm.c +++ b/src/dfm.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include "dfm.h" #include #include diff --git a/src/dictionary.c b/src/dictionary.c index 953b5646..6db18670 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "algorithm.h" #include "alloc.h" diff --git a/src/do-if.c b/src/do-if.c index 0dd6466a..5dfc0626 100644 --- a/src/do-if.c +++ b/src/do-if.c @@ -19,7 +19,7 @@ #include #include "do-ifP.h" -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/error.c b/src/error.c index 65a7b0f1..1065fbd7 100644 --- a/src/error.c +++ b/src/error.c @@ -18,7 +18,6 @@ 02111-1307, USA. */ #include -#include #include "error.h" #include #include @@ -32,6 +31,7 @@ #include "settings.h" #include "str.h" #include "var.h" +#include "version.h" int err_error_count; int err_warning_count; @@ -512,3 +512,54 @@ dump_message (char *msg, unsigned indent, void (*func) (const char *), local_free (buf); } + + +void +request_bug_report_and_abort(const char *msg ) +{ + fprintf(stderr, + "******************************************************************\n" + "You have discovered a bug in PSPP.\n\n" + " Please report this, by sending " + "an email to " PACKAGE_BUGREPORT ",\n" + "explaining what you were doing when this happened, and including\n" + "a sample of your input file which caused it.\n"); + + fprintf(stderr, + "Also, please copy the following lines into your bug report:\n\n" + "bare_version: %s\n" + "version: %s\n" + "stat_version: %s\n" + "host_system: %s\n" + "build_system: %s\n" + "default_config_path: %s\n" + "include_path: %s\n" + "groff_font_path: %s\n" + "locale_dir: %s\n", + + bare_version, + version, + stat_version, + host_system, + build_system, + default_config_path, + include_path, + groff_font_path, + locale_dir); + + if ( msg ) + fprintf(stderr,"Diagnosis: %s\n",msg); + + fprintf(stderr, + "******************************************************************\n"); + + abort(); +} + +void +err_assert_fail(const char *expr, const char *file, int line) +{ + const char msg[256]; + snprintf(msg,256,"Assertion failed: %s:%d; (%s)",file,line,expr); + request_bug_report_and_abort( msg ); +} diff --git a/src/error.h b/src/error.h index 60bcbe85..095f7af8 100644 --- a/src/error.h +++ b/src/error.h @@ -87,4 +87,18 @@ void err_check_count (void); void err_hcf (int exit_code) NO_RETURN; void err_vmsg (const struct error *); +/* Used in panic situations only */ +void request_bug_report_and_abort(const char *msg ); + +void err_assert_fail(const char *expr, const char *file, int line); + +#undef __STRING +#define __STRING(x) #x +#undef assert + + +#define assert(expr) ( (void) ( expr ? 0 : \ + err_assert_fail(__STRING(expr), __FILE__, __LINE__)) ) + + #endif /* error.h */ diff --git a/src/expr-evl.c b/src/expr-evl.c index d031eff6..d18971bd 100644 --- a/src/expr-evl.c +++ b/src/expr-evl.c @@ -33,7 +33,7 @@ #include #include "expr.h" #include "exprP.h" -#include +#include "error.h" #include #include #include diff --git a/src/expr-opt.c b/src/expr-opt.c index 4c8fc7e1..2e65b3e3 100644 --- a/src/expr-opt.c +++ b/src/expr-opt.c @@ -20,7 +20,7 @@ #include #include "expr.h" #include "exprP.h" -#include +#include "error.h" #include #include #include diff --git a/src/expr-prs.c b/src/expr-prs.c index 70134789..08bf2d4f 100644 --- a/src/expr-prs.c +++ b/src/expr-prs.c @@ -20,7 +20,7 @@ #include #include "expr.h" #include "exprP.h" -#include +#include "error.h" #include #include #include diff --git a/src/file-handle.q b/src/file-handle.q index dc1e9383..1133fd31 100644 --- a/src/file-handle.q +++ b/src/file-handle.q @@ -19,7 +19,7 @@ #include #include "file-handle.h" -#include +#include "error.h" #include #include #include "alloc.h" diff --git a/src/file-type.c b/src/file-type.c index 89a97938..bc33599d 100644 --- a/src/file-type.c +++ b/src/file-type.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/filename.c b/src/filename.c index f666674b..a5241461 100644 --- a/src/filename.c +++ b/src/filename.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include "filename.h" #include #include diff --git a/src/flip.c b/src/flip.c index 6bd6a243..1349ef1a 100644 --- a/src/flip.c +++ b/src/flip.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include diff --git a/src/format.c b/src/format.c index 4ff96241..44fbff46 100644 --- a/src/format.c +++ b/src/format.c @@ -20,7 +20,7 @@ #include #include "format.h" #include -#include +#include "error.h" #include #include "error.h" #include "lexer.h" diff --git a/src/frequencies.q b/src/frequencies.q index 37862b5a..e7657b64 100644 --- a/src/frequencies.q +++ b/src/frequencies.q @@ -24,7 +24,7 @@ */ #include -#include +#include "error.h" #include #include #include "alloc.h" diff --git a/src/get.c b/src/get.c index 17722ce6..e2b4977e 100644 --- a/src/get.c +++ b/src/get.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/getline.c b/src/getline.c index 2988b078..b9f0a1d5 100644 --- a/src/getline.c +++ b/src/getline.c @@ -19,7 +19,7 @@ #include #include "getline.h" -#include +#include "error.h" #include #include #include diff --git a/src/glob.c b/src/glob.c index 61c70b46..e1d5bba0 100644 --- a/src/glob.c +++ b/src/glob.c @@ -19,7 +19,7 @@ #include #include "glob.h" -#include +#include "error.h" #include #include diff --git a/src/groff-font.c b/src/groff-font.c index 15135aa1..331da33d 100644 --- a/src/groff-font.c +++ b/src/groff-font.c @@ -19,7 +19,7 @@ #include #include "font.h" -#include +#include "error.h" #include #include #include diff --git a/src/hash.c b/src/hash.c index 9961612c..f42901ea 100644 --- a/src/hash.c +++ b/src/hash.c @@ -19,7 +19,7 @@ #include #include "hash.h" -#include +#include "error.h" #include #include #include "algorithm.h" @@ -479,7 +479,7 @@ hsh_count (struct hsh_table *h) #if GLOBAL_DEBUGGING #undef NDEBUG -#include +#include "error.h" #include /* Displays contents of hash table H on stdout. */ diff --git a/src/html.c b/src/html.c index 6f56b47e..49261473 100644 --- a/src/html.c +++ b/src/html.c @@ -22,7 +22,7 @@ #include #include "htmlP.h" -#include +#include "error.h" #include #include #include diff --git a/src/inpt-pgm.c b/src/inpt-pgm.c index ee2fd7cb..3ed20e19 100644 --- a/src/inpt-pgm.c +++ b/src/inpt-pgm.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include "alloc.h" diff --git a/src/levene.c b/src/levene.c index 34abe398..635c6868 100644 --- a/src/levene.c +++ b/src/levene.c @@ -20,7 +20,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include "levene.h" #include "hash.h" #include "str.h" diff --git a/src/lexer.c b/src/lexer.c index 91712bf2..9ad48dfb 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -19,7 +19,7 @@ #include #include "lexer.h" -#include +#include "error.h" #include #include #include diff --git a/src/list.q b/src/list.q index 10d2baad..56f45342 100644 --- a/src/list.q +++ b/src/list.q @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include "alloc.h" diff --git a/src/loop.c b/src/loop.c index 7f8aa875..bfb18e6e 100644 --- a/src/loop.c +++ b/src/loop.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include "alloc.h" #include "command.h" #include "do-ifP.h" diff --git a/src/main.c b/src/main.c index b20f8a24..97fbdf8b 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,6 @@ #include #include "main.h" -#include #include #include "cmdline.h" #include "command.h" @@ -28,7 +27,6 @@ #include "glob.h" #include "lexer.h" #include "output.h" -#include "version.h" #include #include @@ -167,36 +165,5 @@ handle_error (int code) void bug_handler(int sig UNUSED) { - fprintf(stderr, - "******************************************************************\n" - "You have discovered a bug in PSPP.\n\n" - " Please report this, by sending " - "an email to " PACKAGE_BUGREPORT ",\n" - "explaining what you were doing when this happened, and including\n" - "a sample of your input file which caused it.\n"); - - fprintf(stderr, - "Also, please copy the following lines into your bug report:\n\n" - "bare_version: %s\n" - "version: %s\n" - "stat_version: %s\n" - "host_system: %s\n" - "build_system: %s\n" - "default_config_path: %s\n" - "include_path: %s\n" - "groff_font_path: %s\n" - "locale_dir: %s\n" - "******************************************************************\n", - bare_version, - version, - stat_version, - host_system, - build_system, - default_config_path, - include_path, - groff_font_path, - locale_dir); - - exit(-1); + request_bug_report_and_abort("Segmentation Violation"); } - diff --git a/src/matrix-data.c b/src/matrix-data.c index 5835e822..7d8b55f3 100644 --- a/src/matrix-data.c +++ b/src/matrix-data.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include diff --git a/src/matrix.c b/src/matrix.c index 42911f18..4631e7d8 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -19,7 +19,7 @@ #include #include "matrix.h" -#include +#include "error.h" #include #include "alloc.h" diff --git a/src/means.q b/src/means.q index bf7b1976..846448b1 100644 --- a/src/means.q +++ b/src/means.q @@ -20,7 +20,7 @@ #include #include #include -#include +#include "error.h" #include "alloc.h" #include "command.h" #include "hash.h" diff --git a/src/mis-val.c b/src/mis-val.c index 210d2389..66ceb9ce 100644 --- a/src/mis-val.c +++ b/src/mis-val.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "command.h" #include "error.h" diff --git a/src/modify-vars.c b/src/modify-vars.c index f12cb7ed..aab05c6e 100644 --- a/src/modify-vars.c +++ b/src/modify-vars.c @@ -19,7 +19,7 @@ #include #include -#include +#include "error.h" #include "algorithm.h" #include "alloc.h" #include "bitvector.h" diff --git a/src/numeric.c b/src/numeric.c index 8031d65d..2b42d2cf 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "command.h" #include "error.h" diff --git a/src/output.c b/src/output.c index bdbbf30a..c0c4e0b0 100644 --- a/src/output.c +++ b/src/output.c @@ -19,7 +19,7 @@ #include #include "output.h" -#include +#include "error.h" #include #include #include diff --git a/src/pfm-read.c b/src/pfm-read.c index 8f9e9e4e..ab33e700 100644 --- a/src/pfm-read.c +++ b/src/pfm-read.c @@ -19,7 +19,7 @@ #include #include "pfm.h" -#include +#include "error.h" #include #include #include diff --git a/src/pfm-write.c b/src/pfm-write.c index e229072e..1d553ed7 100644 --- a/src/pfm-write.c +++ b/src/pfm-write.c @@ -19,7 +19,7 @@ #include #include "pfm.h" -#include +#include "error.h" #include #include #include diff --git a/src/pool.c b/src/pool.c index 0123a8b9..d3b536b2 100644 --- a/src/pool.c +++ b/src/pool.c @@ -21,7 +21,7 @@ #include #endif #include "pool.h" -#include +#include "error.h" #include #include "alloc.h" #include "str.h" diff --git a/src/postscript.c b/src/postscript.c index 196e7120..2bfc3fd7 100644 --- a/src/postscript.c +++ b/src/postscript.c @@ -23,7 +23,7 @@ #if !NO_POSTSCRIPT #include -#include +#include "error.h" #include #include #include diff --git a/src/print.c b/src/print.c index 7f93f13f..43cff102 100644 --- a/src/print.c +++ b/src/print.c @@ -20,7 +20,7 @@ /* FIXME: seems like a lot of code duplication with data-list.c. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/q2c.c b/src/q2c.c index 13e8013e..aaf34727 100644 --- a/src/q2c.c +++ b/src/q2c.c @@ -2027,7 +2027,6 @@ main (int argc, char *argv[]) { indent = 0; - dump (0, "#include "); dump (0, "#include "); dump (0, "#include \"alloc.h\""); dump (0, "#include \"error.h\""); diff --git a/src/random.c b/src/random.c index 0352b602..e6db94c1 100644 --- a/src/random.c +++ b/src/random.c @@ -19,7 +19,7 @@ #include #include "random.h" -#include +#include "error.h" #include #include #include diff --git a/src/recode.c b/src/recode.c index e2df650f..12f682c8 100644 --- a/src/recode.c +++ b/src/recode.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include diff --git a/src/rename-vars.c b/src/rename-vars.c index 4b81f904..70243468 100644 --- a/src/rename-vars.c +++ b/src/rename-vars.c @@ -19,7 +19,7 @@ #include #include -#include +#include "error.h" #include "alloc.h" #include "command.h" #include "error.h" diff --git a/src/repeat.c b/src/repeat.c index c3236744..401a50ec 100644 --- a/src/repeat.c +++ b/src/repeat.c @@ -19,7 +19,7 @@ #include #include "repeat.h" -#include +#include "error.h" #include #include #include diff --git a/src/set.q b/src/set.q index e9f3dded..2d1a1699 100644 --- a/src/set.q +++ b/src/set.q @@ -60,7 +60,7 @@ #include #include "settings.h" -#include +#include "error.h" #include #include #include diff --git a/src/sfm-read.c b/src/sfm-read.c index 01f6330f..fad27c94 100644 --- a/src/sfm-read.c +++ b/src/sfm-read.c @@ -20,7 +20,7 @@ #include #include "sfm.h" #include "sfmP.h" -#include +#include "error.h" #include #include #include diff --git a/src/sfm-write.c b/src/sfm-write.c index 64d364ab..3cfb1f5c 100644 --- a/src/sfm-write.c +++ b/src/sfm-write.c @@ -20,7 +20,7 @@ #include #include "sfm.h" #include "sfmP.h" -#include +#include "error.h" #include #include #include diff --git a/src/som.c b/src/som.c index f6623e27..c74492bc 100644 --- a/src/som.c +++ b/src/som.c @@ -19,7 +19,7 @@ #include #include "som.h" -#include +#include "error.h" #include #include #include "output.h" diff --git a/src/sort.c b/src/sort.c index cc0a833f..fd636ac8 100644 --- a/src/sort.c +++ b/src/sort.c @@ -19,7 +19,7 @@ #include #include "sort.h" -#include +#include "error.h" #include #include #include diff --git a/src/str.c b/src/str.c index 98a8e52e..e807f36d 100644 --- a/src/str.c +++ b/src/str.c @@ -19,7 +19,7 @@ #include #include "str.h" -#include +#include "error.h" #include #include #include diff --git a/src/sysfile-info.c b/src/sysfile-info.c index c67c184e..5a91fc39 100644 --- a/src/sysfile-info.c +++ b/src/sysfile-info.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include "algorithm.h" diff --git a/src/t-test.q b/src/t-test.q index 8cef9053..f741bd1e 100644 --- a/src/t-test.q +++ b/src/t-test.q @@ -20,7 +20,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include @@ -77,10 +77,8 @@ static enum comparison criteria[2]; static int n_pairs = 0 ; struct pair { -#if 1 /* The variables comprising the pair */ struct variable *v[2]; -#endif /* The number of valid variable pairs */ double n; @@ -280,6 +278,12 @@ cmd_t_test(void) hsh_destroy(hash); } } + else if ( !cmd.sbc_variables) + { + msg(SE, _("One or more VARIABLES must be specified.")); + return CMD_FAILURE; + } + /* If /MISSING=INCLUDE is set, then user missing values are ignored */ if (cmd.incl == TTS_INCLUDE ) @@ -1633,16 +1637,8 @@ paired_calc (struct ccase *c, void *aux UNUSED) pairs[i].ssq[0] += weight * sqr(val0->f); pairs[i].ssq[1] += weight * sqr(val1->f); -#if 0 - pairs[i].correlation += weight * - ( val0->f - pairs[i].v[0]->p.t_t.ugs.mean ) - * - ( val1->f - pairs[i].v[1]->p.t_t.ugs.mean ); -#endif - pairs[i].sum_of_prod += weight * val0->f * val1->f ; - pairs[i].sum_of_diffs += weight * ( val0->f - val1->f ) ; pairs[i].ssq_diffs += weight * sqr(val0->f - val1->f); } @@ -1680,16 +1676,8 @@ paired_postcalc (void *aux UNUSED) pairs[i].correlation /= pairs[i].std_dev[0] * pairs[i].std_dev[1]; pairs[i].correlation *= pairs[i].n / ( pairs[i].n - 1 ); -#if 0 - pairs[i].correlation /= pairs[i].v[0]->p.t_t.ugs.std_dev * - pairs[i].v[1]->p.t_t.ugs.std_dev ; - pairs[i].correlation /= n - 1; -#endif - - pairs[i].mean_diff = pairs[i].sum_of_diffs / n ; - pairs[i].std_dev_diff = sqrt ( n / (n - 1) * ( ( pairs[i].ssq_diffs / n ) - diff --git a/src/tab.c b/src/tab.c index 118a77cd..82df4cd2 100644 --- a/src/tab.c +++ b/src/tab.c @@ -20,10 +20,10 @@ #include #include "tab.h" #include -#include #include #include #include +#include "error.h" #include "alloc.h" #include "command.h" #include "format.h" diff --git a/src/temporary.c b/src/temporary.c index 70d86cab..c04ce764 100644 --- a/src/temporary.c +++ b/src/temporary.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include #include "alloc.h" diff --git a/src/val-labs.c b/src/val-labs.c index 882f26e6..9d05e77f 100644 --- a/src/val-labs.c +++ b/src/val-labs.c @@ -57,12 +57,19 @@ do_value_labels (int erase) { struct variable **vars; /* Variable list. */ int var_cnt; /* Number of variables. */ + int parse_err=0; /* true if error parsing variables */ lex_match ('/'); while (token != '.') { - parse_variables (default_dict, &vars, &var_cnt, PV_SAME_TYPE); + parse_err = !parse_variables (default_dict, &vars, &var_cnt, + PV_SAME_TYPE) ; + if (var_cnt < 1) + { + free(vars); + return CMD_FAILURE; + } if (!verify_val_labs (vars, var_cnt)) goto lossage; if (erase) @@ -85,7 +92,7 @@ do_value_labels (int erase) return CMD_TRAILING_GARBAGE; } - return CMD_SUCCESS; + return parse_err ? CMD_PART_SUCCESS_MAYBE : CMD_SUCCESS; lossage: free (vars); diff --git a/src/value-labels.c b/src/value-labels.c index 9c764086..404f7f68 100644 --- a/src/value-labels.c +++ b/src/value-labels.c @@ -19,7 +19,7 @@ #include #include "value-labels.h" -#include +#include "error.h" #include #include #include "alloc.h" diff --git a/src/vars-atr.c b/src/vars-atr.c index 00453767..c0730022 100644 --- a/src/vars-atr.c +++ b/src/vars-atr.c @@ -19,7 +19,7 @@ #include #include "var.h" -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/vars-prs.c b/src/vars-prs.c index 6f3d7f3e..143ad171 100644 --- a/src/vars-prs.c +++ b/src/vars-prs.c @@ -19,7 +19,6 @@ #include #include "var.h" -#include #include #include #include "alloc.h" diff --git a/src/vector.c b/src/vector.c index 99b3423a..80582f76 100644 --- a/src/vector.c +++ b/src/vector.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "alloc.h" #include "command.h" diff --git a/src/vfm.c b/src/vfm.c index b5d2a8d3..1ea4211e 100644 --- a/src/vfm.c +++ b/src/vfm.c @@ -20,7 +20,7 @@ #include #include "vfm.h" #include "vfmP.h" -#include +#include "error.h" #include #include #include diff --git a/src/weight.c b/src/weight.c index 66b7e615..7fac10cc 100644 --- a/src/weight.c +++ b/src/weight.c @@ -18,7 +18,7 @@ 02111-1307, USA. */ #include -#include +#include "error.h" #include #include "command.h" #include "error.h" diff --git a/tests/Makefile.am b/tests/Makefile.am index 60ffbaeb..9b2feee2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -40,7 +40,9 @@ TESTS = command/aggregate.sh \ bugs/crosstabs.sh \ bugs/data-crash.sh \ bugs/random.sh \ - bugs/temporary.sh + bugs/t-test.sh \ + bugs/temporary.sh \ + bugs/val-labs.sh noinst_PROGRAMS = gengarbage diff --git a/tests/bugs/t-test.sh b/tests/bugs/t-test.sh new file mode 100755 index 00000000..7896b771 --- /dev/null +++ b/tests/bugs/t-test.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# This program tests for a bug which caused T-TEST to +# crash when given invalid syntax + + +TEMPDIR=/tmp/pspp-tst-$$ + +here=`pwd`; + +# ensure that top_srcdir is absolute +cd $top_srcdir; top_srcdir=`pwd` + +export STAT_CONFIG_PATH=$top_srcdir/config + + +cleanup() +{ + rm -rf $TEMPDIR +} + + +fail() +{ + echo $activity + echo FAILED + cleanup; + exit 1; +} + + +no_result() +{ + echo $activity + echo NO RESULT; + cleanup; + exit 2; +} + +pass() +{ + cleanup; + exit 0; +} + +mkdir -p $TEMPDIR + +cd $TEMPDIR + +activity="create program" +cat > $TEMPDIR/rnd.sps < /dev/null +if [ $? -ne 1 ] ; then fail ; fi + +pass; diff --git a/tests/bugs/val-labs.sh b/tests/bugs/val-labs.sh new file mode 100755 index 00000000..fc052b7b --- /dev/null +++ b/tests/bugs/val-labs.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# This program tests for a bug which caused VALUE LABELS to +# crash when given invalid syntax + + +TEMPDIR=/tmp/pspp-tst-$$ + +here=`pwd`; + +# ensure that top_srcdir is absolute +cd $top_srcdir; top_srcdir=`pwd` + +export STAT_CONFIG_PATH=$top_srcdir/config + + +cleanup() +{ + rm -rf $TEMPDIR +} + + +fail() +{ + echo $activity + echo FAILED + cleanup; + exit 1; +} + + +no_result() +{ + echo $activity + echo NO RESULT; + cleanup; + exit 2; +} + +pass() +{ + cleanup; + exit 0; +} + +mkdir -p $TEMPDIR + +cd $TEMPDIR + +activity="create program" +cat > $TEMPDIR/rnd.sps < /dev/null +if [ $? -ne 1 ] ; then fail ; fi + +pass; -- 2.30.2