1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3 Written by Ben Pfaff <blp@gnu.org>.
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 #include "command-line.h"
28 #include "read-line.h"
30 #include <data/dictionary.h>
31 #include <data/file-handle-def.h>
32 #include <data/file-name.h>
33 #include <data/procedure.h>
34 #include <data/settings.h>
35 #include <data/variable.h>
36 #include <gsl/gsl_errno.h>
37 #include <language/command.h>
38 #include <language/lexer/lexer.h>
39 #include <language/line-buffer.h>
40 #include <libpspp/compiler.h>
41 #include <libpspp/message.h>
42 #include <libpspp/version.h>
43 #include <math/random.h>
44 #include <output/output.h>
46 #if HAVE_FPU_CONTROL_H
47 #include <fpu_control.h>
59 #define _(msgid) gettext (msgid)
63 static void i18n_init (void);
64 static void fpu_init (void);
65 static void terminate (bool success) NO_RETURN;
67 /* If a segfault happens, issue a message to that effect and halt */
68 void bug_handler(int sig);
70 /* Handle quit/term/int signals */
71 void interrupt_handler(int sig);
74 /* Program entry point. */
76 main (int argc, char **argv)
78 signal (SIGSEGV, bug_handler);
79 signal (SIGFPE, bug_handler);
80 signal (SIGINT, interrupt_handler);
82 set_program_name ("pspp");
85 gsl_set_error_handler_off ();
97 if (parse_command_line (argc, argv))
104 int result = cmd_parse (proc_has_source ()
105 ? CMD_STATE_DATA : CMD_STATE_INITIAL);
106 if (result == CMD_EOF || result == CMD_FINISH)
108 if (result == CMD_CASCADING_FAILURE && !getl_is_interactive ())
110 msg (SE, _("Stopping syntax file processing here to avoid "
111 "a cascade of dependent command failures."));
112 getl_abort_noninteractive ();
119 terminate (!any_errors ());
127 setlocale (LC_MESSAGES, "");
129 setlocale (LC_MONETARY, "");
130 bindtextdomain (PACKAGE, locale_dir);
131 textdomain (PACKAGE);
132 #endif /* ENABLE_NLS */
138 #if HAVE_FEHOLDEXCEPT
141 #elif HAVE___SETFPUCW && defined(_FPU_IEEE)
142 __setfpucw (_FPU_IEEE);
146 /* If a segfault happens, issue a message to that effect and halt */
153 request_bug_report_and_abort("Floating Point Exception");
156 request_bug_report_and_abort("Segmentation Violation");
159 request_bug_report_and_abort("");
165 interrupt_handler(int sig UNUSED)
171 /* Terminate PSPP. SUCCESS should be true to exit successfully,
172 false to exit as a failure. */
174 terminate (bool success)
176 static bool terminating = false;
187 getl_uninitialize ();
188 readln_uninitialize ();
193 exit (success ? EXIT_SUCCESS : EXIT_FAILURE);