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
32 /*#define DEBUGGING 1*/
33 #include "debug-print.h"
35 static void parse_script (void) __attribute__ ((noreturn));
36 static void handle_error (int code);
37 static int execute_command (void);
39 /* argv[0] with stripped leading directories. */
42 /* Whether FINISH. has been executed. */
45 /* The current date in the form DD MMM YYYY. */
48 /* Whether we're dropping down to interactive mode immediately because
49 we hit end-of-file unexpectedly (or whatever). */
50 int start_interactive;
52 /* Program entry point. */
54 main (int argc, char **argv)
56 void init_glob (int, char **); /* Exported by glob.c. */
57 void parse_command_line (int, char **); /* Exported by cmdline.c */
62 init_glob (argc, argv);
63 parse_command_line (argc, argv);
64 if (!outp_read_devices ())
65 msg (FE, _("Error initializing output drivers."));
73 /* Should never be reached */
77 /* Parses the entire script. */
84 handle_error (execute_command ());
87 err_hcf (err_error_count==0);
90 /* Parse and execute a command, returning its return code. */
92 execute_command (void)
94 /* Read the command's first token.
95 We may hit end of file.
96 If so, give the line reader a chance to proceed to the next file.
97 End of file is not handled transparently since the user may want
98 the dictionary cleared between files. */
99 getl_prompt = GETL_PRPT_STANDARD;
106 if (!getl_perform_delayed_reset ())
107 err_hcf (err_error_count==0);
110 /* Parse the command. */
111 getl_prompt = GETL_PRPT_CONTINUATION;
115 /* Print an error message corresponding to the command return code
118 handle_error (int code)
126 msg (SW, _("This command not executed."));
129 case CMD_PART_SUCCESS_MAYBE:
130 msg (SW, _("Skipping the rest of this command. Part of "
131 "this command may have been executed."));
134 case CMD_PART_SUCCESS:
135 msg (SW, _("Skipping the rest of this command. This "
136 "command was fully executed up to this point."));
139 case CMD_TRAILING_GARBAGE:
140 msg (SW, _("Trailing garbage was encountered following "
141 "this command. The command was fully executed "
149 if (getl_reading_script)
152 while (token != T_STOP && token != '.')