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., 59 Temple Place - Suite 330, Boston, MA
36 #include "debug-print.h"
38 static void parse_script (void) NO_RETURN;
39 static void handle_error (int code);
40 static int execute_command (void);
42 /* argv[0] with stripped leading directories. */
45 /* Whether FINISH. has been executed. */
48 /* The current date in the form DD MMM YYYY. */
52 /* If a segfault happens, issue a message to that effect and halt */
53 void bug_handler(int sig);
55 /* Whether we're dropping down to interactive mode immediately because
56 we hit end-of-file unexpectedly (or whatever). */
57 int start_interactive;
59 /* Program entry point. */
61 main (int argc, char **argv)
63 signal (SIGSEGV, bug_handler);
68 init_glob (argc, argv);
69 parse_command_line (argc, argv);
70 if (!outp_read_devices ())
71 msg (FE, _("Error initializing output drivers."));
79 /* Should never be reached */
83 /* Parses the entire script. */
90 handle_error (execute_command ());
93 err_hcf (err_error_count==0);
96 /* Parse and execute a command, returning its return code. */
98 execute_command (void)
100 /* Read the command's first token.
101 We may hit end of file.
102 If so, give the line reader a chance to proceed to the next file.
103 End of file is not handled transparently since the user may want
104 the dictionary cleared between files. */
105 getl_prompt = GETL_PRPT_STANDARD;
112 if (!getl_perform_delayed_reset ())
113 err_hcf (err_error_count==0);
116 /* Parse the command. */
117 getl_prompt = GETL_PRPT_CONTINUATION;
121 /* Print an error message corresponding to the command return code
124 handle_error (int code)
132 msg (SW, _("This command not executed."));
135 case CMD_PART_SUCCESS_MAYBE:
136 msg (SW, _("Skipping the rest of this command. Part of "
137 "this command may have been executed."));
140 case CMD_PART_SUCCESS:
141 msg (SW, _("Skipping the rest of this command. This "
142 "command was fully executed up to this point."));
145 case CMD_TRAILING_GARBAGE:
146 msg (SW, _("Trailing garbage was encountered following "
147 "this command. The command was fully executed "
155 if (getl_reading_script)
158 while (token != T_STOP && token != '.')
167 /* If a segfault happens, issue a message to that effect and halt */
169 bug_handler(int sig UNUSED)
172 "******************************************************************\n"
173 "You have discovered a bug in PSPP.\n\n"
174 " Please report this, by sending "
175 "an email to " PACKAGE_BUGREPORT ",\n"
176 "explaining what you were doing when this happened, and including\n"
177 "a sample of your input file which caused it.\n");
180 "Also, please copy the following lines into your bug report:\n\n"
186 "default_config_path: %s\n"
188 "groff_font_path: %s\n"
190 "******************************************************************\n",