From: John Darrington Date: Tue, 7 Nov 2006 12:59:59 +0000 (+0000) Subject: Committed patch #5524, which allows the message destination to be X-Git-Tag: v0.6.0~700 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5574c6264163859a8eb94ab1e33bcc1b61fce5f;p=pspp-builds.git Committed patch #5524, which allows the message destination to be set on the command line. --- diff --git a/src/ui/terminal/ChangeLog b/src/ui/terminal/ChangeLog index db86245e..4bc7b361 100644 --- a/src/ui/terminal/ChangeLog +++ b/src/ui/terminal/ChangeLog @@ -1,3 +1,8 @@ +Tue Nov 7 20:54:32 WST 2006 John Darrington + + * command-line.c msg-ui.c msg-ui.h main.c: Added an -e + option to set the file for error messages. + Sat Nov 4 15:48:04 2006 Ben Pfaff * msg-ui.c (handle_msg): Only write message to terminal if diff --git a/src/ui/terminal/command-line.c b/src/ui/terminal/command-line.c index 8511f290..54e4a7c2 100644 --- a/src/ui/terminal/command-line.c +++ b/src/ui/terminal/command-line.c @@ -19,6 +19,7 @@ #include #include "command-line.h" +#include "msg-ui.h" #include #include #include @@ -62,6 +63,7 @@ parse_command_line (int argc, char **argv) {"device", required_argument, NULL, 'o'}, {"dry-run", no_argument, NULL, 'n'}, {"edit", no_argument, NULL, 'n'}, + {"error-file", required_argument, NULL, 'e'}, {"help", no_argument, NULL, 'h'}, {"include-directory", required_argument, NULL, 'I'}, {"interactive", no_argument, NULL, 'i'}, @@ -89,7 +91,7 @@ parse_command_line (int argc, char **argv) for (;;) { - c = getopt_long (argc, argv, "a:x:B:c:f:hiI:lno:prsvV", long_options, NULL); + c = getopt_long (argc, argv, "a:x:B:c:e:f:hiI:lno:prsvV", long_options, NULL); if (c == -1) break; @@ -119,7 +121,9 @@ parse_command_line (int argc, char **argv) return false; } break; - + case 'e': + msg_ui_set_error_file (optarg); + break; case 'B': config_path = optarg; break; @@ -223,6 +227,7 @@ N_("PSPP, a program for statistical analysis of sample data.\n" " -B, --config-dir=DIR set configuration directory to DIR\n" " -o, --device=DEVICE select output driver DEVICE and disable defaults\n" "\nInput and output:\n" +" -e, --error-file=FILE send error messages to FILE (appended)\n" " -f, --out-file=FILE send output to FILE (overwritten)\n" " -p, --pipe read script from stdin, send output to stdout\n" " -I-, --no-include clear include path\n" diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 6998f773..b52fd941 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -90,7 +90,6 @@ main (int argc, char **argv) fmt_init (); outp_init (); - msg_ui_init (); fn_init (); fh_init (); getl_initialize (); @@ -101,6 +100,7 @@ main (int argc, char **argv) if (parse_command_line (argc, argv)) { + msg_ui_init (); outp_read_devices (); lex_init (do_read_line); diff --git a/src/ui/terminal/msg-ui.c b/src/ui/terminal/msg-ui.c index bcfe1ea6..7d5cf72f 100644 --- a/src/ui/terminal/msg-ui.c +++ b/src/ui/terminal/msg-ui.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "gettext.h" #define _(msgid) gettext (msgid) @@ -35,12 +36,35 @@ /* Number of errors, warnings reported. */ static int error_count; static int warning_count; +static const char *error_file; static void handle_msg (const struct msg *); +static FILE *msg_file; + +void +msg_ui_set_error_file (const char *filename) +{ + error_file = filename; +} + void msg_ui_init (void) { + msg_file = stdout; + + if ( error_file ) + { + msg_file = fopen (error_file, "a"); + if ( NULL == msg_file ) + { + int err = errno; + printf ( _("Cannot open %s (%s). " + "Writing errors to stdout instead.\n"), + error_file, strerror(err) ); + msg_file = stdout; + } + } msg_init (handle_msg, get_msg_location); } @@ -48,6 +72,7 @@ void msg_ui_done (void) { msg_done (); + fclose (msg_file); } @@ -141,8 +166,8 @@ handle_msg (const struct msg *m) ds_put_cstr (&string, m->text); - if (get_error_routing_to_terminal ()) - dump_message (ds_cstr (&string), get_viewwidth (), 8, stdout); + if (msg_file != stdout || get_error_routing_to_terminal ()) + dump_message (ds_cstr (&string), get_viewwidth (), 8, msg_file); ds_destroy (&string); } diff --git a/src/ui/terminal/msg-ui.h b/src/ui/terminal/msg-ui.h index fc9dcd95..4eeec278 100644 --- a/src/ui/terminal/msg-ui.h +++ b/src/ui/terminal/msg-ui.h @@ -22,6 +22,7 @@ #include +void msg_ui_set_error_file (const char *filename); void msg_ui_init (void); void msg_ui_done (void); void check_msg_count (void); diff --git a/tests/bugs/agg_crash.sh b/tests/bugs/agg_crash.sh index ec202db7..469cde7c 100755 --- a/tests/bugs/agg_crash.sh +++ b/tests/bugs/agg_crash.sh @@ -72,7 +72,7 @@ if [ $? -ne 0 ] ; then no_result ; fi # So this will have a non zero error status. # But it shouldn't crash! activity="run_program" -$SUPERVISOR $PSPP $TESTFILE > /dev/null +$SUPERVISOR $PSPP -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/big-input-2.sh b/tests/bugs/big-input-2.sh index 1fe9b60e..32b5bcfd 100755 --- a/tests/bugs/big-input-2.sh +++ b/tests/bugs/big-input-2.sh @@ -79,7 +79,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 0 ] ; then fail ; fi activity="appending to data" @@ -88,7 +88,7 @@ $PERL -e 'for ($i=0; $i<25000; $i++) { print "AB04\nAB12\n" };' >> $TEMPDIR/larg if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 0 ] ; then fail ; fi pass; diff --git a/tests/bugs/big-input.sh b/tests/bugs/big-input.sh index bcafa788..10f31e2f 100755 --- a/tests/bugs/big-input.sh +++ b/tests/bugs/big-input.sh @@ -71,7 +71,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP -o raw-ascii $TEMPDIR/foo.sps > /dev/null +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $TEMPDIR/foo.sps if [ $? -ne 0 ] ; then fail ; fi pass; diff --git a/tests/bugs/curtailed.sh b/tests/bugs/curtailed.sh index 93c45b59..86acddf5 100755 --- a/tests/bugs/curtailed.sh +++ b/tests/bugs/curtailed.sh @@ -70,7 +70,7 @@ if [ $? -ne 0 ] ; then no_result ; fi #This must fail activity="run program" -$SUPERVISOR $PSPP $TESTFILE > /dev/null +$SUPERVISOR $PSPP -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/data-crash.sh b/tests/bugs/data-crash.sh index 31555523..dd865028 100755 --- a/tests/bugs/data-crash.sh +++ b/tests/bugs/data-crash.sh @@ -63,8 +63,7 @@ if [ $? -ne 0 ] ; then no_result ; fi #This must fail activity="run program" -$SUPERVISOR $PSPP $TEMPDIR/ct.stat > /dev/null +$SUPERVISOR $PSPP -e /dev/null $TEMPDIR/ct.stat if [ $? -ne 1 ] ; then fail ; fi - pass; diff --git a/tests/bugs/examine-missing.sh b/tests/bugs/examine-missing.sh index 31164d9b..78b6be5f 100755 --- a/tests/bugs/examine-missing.sh +++ b/tests/bugs/examine-missing.sh @@ -70,7 +70,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP -o raw-ascii $TESTFILE > /dev/null 2>&1 +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $TESTFILE 2> /dev/null if [ $? -ne 0 ] ; then fail ; fi pass; diff --git a/tests/bugs/if_crash.sh b/tests/bugs/if_crash.sh index 4e414eb1..ef059e95 100755 --- a/tests/bugs/if_crash.sh +++ b/tests/bugs/if_crash.sh @@ -76,7 +76,7 @@ if [ $? -ne 0 ] ; then no_result ; fi # So this will have a non zero error status. # But it shouldn't crash! activity="run_program" -$SUPERVISOR $PSPP $TESTFILE > /dev/null +$SUPERVISOR $PSPP -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/input-crash.sh b/tests/bugs/input-crash.sh index 03dd961c..2336c867 100755 --- a/tests/bugs/input-crash.sh +++ b/tests/bugs/input-crash.sh @@ -73,7 +73,7 @@ if [ $? -ne 0 ] ; then no_result ; fi # The above syntax is invalid, so this program should fail to parse activity="run program" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/print-crash.sh b/tests/bugs/print-crash.sh index d362ede1..ba1630f5 100755 --- a/tests/bugs/print-crash.sh +++ b/tests/bugs/print-crash.sh @@ -68,7 +68,7 @@ if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi diff --git a/tests/bugs/t-test.sh b/tests/bugs/t-test.sh index d2c92ecc..9fac7dfc 100755 --- a/tests/bugs/t-test.sh +++ b/tests/bugs/t-test.sh @@ -73,7 +73,7 @@ if [ $? -ne 0 ] ; then no_result ; fi #The syntax was invalid. Therefore pspp must return non zero. activity="run program" -$SUPERVISOR $PSPP -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi pass; diff --git a/tests/bugs/terminate.sh b/tests/bugs/terminate.sh index 669a308d..ee3ffa87 100755 --- a/tests/bugs/terminate.sh +++ b/tests/bugs/terminate.sh @@ -66,7 +66,7 @@ if [ $? -ne 0 ] ; then no_result ; fi activity="run program" # This must exit with non zero status -$SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/foo.sps > /dev/null 2> $TEMPDIR/stderr +$SUPERVISOR $here/../src/pspp -o raw-ascii -e /dev/null $TEMPDIR/foo.sps 2> $TEMPDIR/stderr if [ $? -eq 0 ] ; then fail ; fi activity="compare stderr" diff --git a/tests/bugs/val-labs.sh b/tests/bugs/val-labs.sh index 0e7d3a47..b27683b6 100755 --- a/tests/bugs/val-labs.sh +++ b/tests/bugs/val-labs.sh @@ -73,7 +73,7 @@ if [ $? -ne 0 ] ; then no_result ; fi #Invalid syntax --- return value is non zero. activity="run program" -$SUPERVISOR $PSPP -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 1 ] ; then fail ; fi pass; diff --git a/tests/command/aggregate.sh b/tests/command/aggregate.sh index b85edba3..3cdd84db 100755 --- a/tests/command/aggregate.sh +++ b/tests/command/aggregate.sh @@ -206,7 +206,7 @@ for outfile in scratch active external; do if [ $? -ne 0 ] ; then no_result ; fi activity="run $name.pspp" - $SUPERVISOR $PSPP --testing-mode -o raw-ascii $name.pspp >/dev/null 2>&1 + $SUPERVISOR $PSPP --testing-mode -o raw-ascii -e /dev/null $name.pspp if [ $? -ne 0 ] ; then no_result ; fi activity="check $name output" diff --git a/tests/command/erase.sh b/tests/command/erase.sh index 8b06c42c..bbb094e1 100755 --- a/tests/command/erase.sh +++ b/tests/command/erase.sh @@ -77,7 +77,7 @@ if [ ! -f $TEMPDIR/foobar ] ; then fail ; fi # This command must fail activity="run prog 1" -$SUPERVISOR $PSPP $TESTFILE > /dev/null +$SUPERVISOR $PSPP -e /dev/null $TESTFILE if [ $? -eq 0 ] ; then fail ; fi diff --git a/tests/command/loop.sh b/tests/command/loop.sh index 7c7e493a..e2b42426 100755 --- a/tests/command/loop.sh +++ b/tests/command/loop.sh @@ -73,7 +73,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TEMPDIR/loop.stat > $TEMPDIR/stdout +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e $TEMPDIR/stdout $TEMPDIR/loop.stat if [ $? -ne 0 ] ; then no_result ; fi activity="compare stdout" diff --git a/tests/command/match-files.sh b/tests/command/match-files.sh index 65d0f457..367c6ddc 100755 --- a/tests/command/match-files.sh +++ b/tests/command/match-files.sh @@ -165,7 +165,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run $name.pspp" - $SUPERVISOR $PSPP -o raw-ascii $name.pspp >/dev/null 2>&1 + $SUPERVISOR $PSPP -o raw-ascii -e /dev/null $name.pspp if [ $? -ne 0 ] ; then no_result ; fi activity="check $name output" @@ -190,7 +190,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run $name.pspp" -$SUPERVISOR $PSPP -o raw-ascii $name.pspp >/dev/null 2>&1 +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $name.pspp if [ $? -ne 0 ] ; then no_result ; fi activity="check $name output" @@ -239,7 +239,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run $name.pspp" -$SUPERVISOR $PSPP -o raw-ascii $name.pspp >/dev/null 2>&1 +$SUPERVISOR $PSPP -o raw-ascii -e /dev/null $name.pspp if [ $? -ne 0 ] ; then no_result ; fi activity="check $name output" diff --git a/tests/command/missing-values.sh b/tests/command/missing-values.sh index 56edebec..ecef99df 100755 --- a/tests/command/missing-values.sh +++ b/tests/command/missing-values.sh @@ -109,7 +109,7 @@ if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii --testing-mode $TEMPDIR/missing-values.stat > $TEMPDIR/errs +$SUPERVISOR $PSPP --testing-mode -o raw-ascii --testing-mode --error-file=$TEMPDIR/errs $TEMPDIR/missing-values.stat # Note vv --- there are errors in input. Therefore, the command must FAIL if [ $? -eq 0 ] ; then fail ; fi diff --git a/tests/command/print.sh b/tests/command/print.sh index 44273ece..8d7a6160 100755 --- a/tests/command/print.sh +++ b/tests/command/print.sh @@ -101,7 +101,7 @@ if [ $? -ne 0 ] ; then no_result ; fi activity="run program" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii --testing-mode $TEMPDIR/print.stat > $TEMPDIR/errs +$SUPERVISOR $PSPP --testing-mode -o raw-ascii --testing-mode --error-file=$TEMPDIR/errs $TEMPDIR/print.stat if [ $? -ne 0 ] ; then fail ; fi activity="compare print.out" diff --git a/tests/command/rank.sh b/tests/command/rank.sh index aac20882..c827a520 100755 --- a/tests/command/rank.sh +++ b/tests/command/rank.sh @@ -81,7 +81,7 @@ if [ $? -ne 0 ] ; then no_result ; fi # Check that it properly handles failed transformations. activity="run program 1" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > $TEMPDIR/err +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e $TEMPDIR/err $TESTFILE if [ $? -ne 1 ] ; then fail ; fi activity="diff 1" @@ -135,7 +135,7 @@ if [ $? -ne 0 ] ; then no_result ; fi activity="run program (syntax errors)" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > $TEMPDIR/errs +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e $TEMPDIR/errs $TESTFILE if [ $? -ne 1 ] ; then fail ; fi activity="compare errors" @@ -534,7 +534,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run program 4" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 0 ] ; then fail ; fi diff --git a/tests/command/very-long-strings.sh b/tests/command/very-long-strings.sh index 23bb85f2..020c2ffa 100755 --- a/tests/command/very-long-strings.sh +++ b/tests/command/very-long-strings.sh @@ -71,7 +71,7 @@ EOF if [ $? -ne 0 ] ; then no_result ; fi activity="run program 0" -$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null +$SUPERVISOR $PSPP --testing-mode -o raw-ascii -e /dev/null $TESTFILE if [ $? -ne 0 ] ; then fail ; fi activity="compare variable display 0"