Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / src / ui / terminal / command-line.c
index 39e17e325d8e6ec3b4f89b1f04fe6ef960928bc3..95b22cebf8bea93995e87833ed3fec52bf64f044 100644 (file)
@@ -1,56 +1,55 @@
-/* PSPP - computes sample statistics.
-   Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
+/* PSPP - a program for statistical analysis.
+   Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA. */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
 #include "command-line.h"
-#include "message.h"
+#include "msg-ui.h"
+#include <libpspp/message.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <getopt.h>
 #include <stdlib.h>
-#include "alloc.h"
-#include "copyleft.h"
-#include "message.h"
-#include "line-buffer.h"
+#include <libpspp/assertion.h>
+#include <libpspp/copyleft.h>
+#include <libpspp/message.h>
+#include <language/syntax-file.h>
 #include "progname.h"
-#include "settings.h"
+#include <data/settings.h>
+#include <output/output.h>
+#include <data/file-name.h>
+#include <libpspp/getl.h>
+#include <libpspp/str.h>
+#include <libpspp/version.h>
+#include <libpspp/verbose-msg.h>
 #include "read-line.h"
-#include "output.h"
-#include "filename.h"
-#include "str.h"
-#include "version.h"
+
+#include "xalloc.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
-void welcome (void);
 static void usage (void);
 
-char *subst_vars (char *);
-
 /* Parses the command line specified by ARGC and ARGV as received by
    main().  Returns true if normal execution should proceed,
    false if the command-line indicates that PSPP should exit. */
 bool
-parse_command_line (int argc, char **argv)
+parse_command_line (int argc, char **argv, struct source_stream *ss)
 {
   static struct option long_options[] =
   {
@@ -60,6 +59,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'},
@@ -87,7 +87,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;
 
@@ -96,9 +96,9 @@ parse_command_line (int argc, char **argv)
          /* Compatibility options */
         case 'a':
          if ( 0 == strcmp(optarg,"compatible") )
-             set_algorithm(COMPATIBLE);
+             settings_set_algorithm(COMPATIBLE);
          else if ( 0 == strcmp(optarg,"enhanced"))
-             set_algorithm(ENHANCED);
+             settings_set_algorithm(ENHANCED);
          else
            {
              usage ();
@@ -106,18 +106,20 @@ parse_command_line (int argc, char **argv)
            }
          break;
 
-       case 'x':         
+       case 'x':
          if ( 0 == strcmp(optarg,"compatible") )
-           set_syntax(COMPATIBLE);
+           settings_set_syntax (COMPATIBLE);
          else if ( 0 == strcmp(optarg,"enhanced"))
-           set_syntax(ENHANCED);
+           settings_set_syntax (ENHANCED);
          else
            {
              usage ();
               return false;
            }
          break;
-
+       case 'e':
+         msg_ui_set_error_file (optarg);
+         break;
        case 'B':
          config_path = optarg;
          break;
@@ -133,9 +135,9 @@ parse_command_line (int argc, char **argv)
          break;
        case 'I':
          if (optarg == NULL || !strcmp (optarg, "-"))
-           getl_clear_include_path ();
+           getl_clear_include_path (ss);
          else
-           getl_add_include_dir (optarg);
+           getl_add_include_dir (ss, optarg);
          break;
        case 'l':
          outp_list_classes ();
@@ -160,18 +162,17 @@ parse_command_line (int argc, char **argv)
          process_statrc = false;
          break;
        case 's':
-         set_safer_mode ();
+         settings_set_safer_mode ();
          break;
        case 'v':
-         err_verbosity++;
+         verbose_increment_level ();
          break;
        case 'V':
          puts (version);
          puts (legal);
          return false;
         case 'T':
-          force_long_view ();
-          set_testing_mode (true);
+          settings_set_testing_mode (true);
           break;
        case '?':
          usage ();
@@ -179,31 +180,47 @@ parse_command_line (int argc, char **argv)
        case 0:
          break;
        default:
-         assert (0);
+         NOT_REACHED ();
        }
     }
 
   if (process_statrc)
     {
-      char *pspprc_fn = fn_search_path ("rc", config_path, NULL);
-      if (pspprc_fn != NULL) 
+      char *pspprc_fn = fn_search_path ("rc", config_path);
+      if (pspprc_fn != NULL)
         {
-          getl_append_syntax_file (pspprc_fn);
-          free (pspprc_fn); 
+         getl_append_source (ss,
+                             create_syntax_file_source (pspprc_fn),
+                             GETL_BATCH,
+                             ERRMODE_CONTINUE
+                             );
+
+          free (pspprc_fn);
         }
     }
 
   for (i = optind; i < argc; i++)
     if (strchr (argv[i], '='))
       outp_configure_macro (argv[i]);
-    else 
+    else
       {
-        getl_append_syntax_file (argv[i]);
+       getl_append_source (ss,
+                           create_syntax_file_source (argv[i]),
+                           GETL_BATCH,
+                           ERRMODE_CONTINUE
+                           );
         syntax_files++;
       }
 
   if (!syntax_files || interactive_mode)
-    getl_append_interactive (readln_read);
+    {
+      getl_append_source (ss, create_readln_source (),
+                         GETL_INTERACTIVE,
+                         ERRMODE_CONTINUE
+                         );
+      if (!cleared_device_defaults)
+        outp_configure_add ("interactive");
+    }
 
   return true;
 }
@@ -220,15 +237,14 @@ N_("PSPP, a program for statistical analysis of sample data.\n"
 "                            calculated from broken algorithms\n"
 "  -B, --config-dir=DIR      set configuration directory to DIR\n"
 "  -o, --device=DEVICE       select output driver DEVICE and disable defaults\n"
-"  -d, --define=VAR[=VALUE]  set environment variable VAR to VALUE, or empty\n"
-"  -u, --undef=VAR           undefine environment variable VAR\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"
+"  -p, --pipe                read syntax from stdin, send output to stdout\n"
 "  -I-, --no-include         clear include path\n"
 "  -I, --include=DIR         append DIR to include path\n"
 "\nLanguage modifiers:\n"
-"  -i, --interactive         interpret scripts in interactive mode\n"
+"  -i, --interactive         interpret syntax in interactive mode\n"
 "  -n, --edit                just check syntax; don't actually run the code\n"
 "  -r, --no-statrc           disable execution of .pspp/rc at startup\n"
 "  -s, --safer               don't allow some unsafe operations\n"