Remove vestigial log infrastructure.
Minor related cleanups.
+Tue Dec 13 22:34:42 2005 Ben Pfaff <blp@gnu.org>
+
+ Move global initialization and cleanup code into main.c.
+ Remove vestigial log infrastructure.
+ Minor related cleanups.
+
+ * command.c: (shell) When execl() fails, use _exit(), not
+ err_hcf().
+
+ * error.c: (err_hcf) Move into main.c, rename terminate(). All
+ callers updated.
+ (err_done) New function with just the error.c-specific code for
+ err_hcf(). Called by terminate().
+
+ * glob.c: Removed all Borland C, DJGPP cruft.
+ (init_glob) Merged into main().
+ (done_glob) Merged into terminate().
+ (get_date) Removed.
+ (get_start_date) New function. All users of curdate updated to call
+ this function instead.
+
+ * lexer.c: (lex_init) Moved initialization of tokstr here, from
+ init_glob().
+ (lex_done) Moved destruction of tokstr here, from done_glob().
+
+ * main.c: (global var pgmname) Removed. Changed all references to
+ program_name, which is defined by gnulib.
+ (global var curdate) Removed.
+ (main) Moved init_glob() code here. Merged parse_script() in
+ here.
+ (parse_script) Removed.
+ (terminate) Moved err_hcf() here from error.c and renamed
+ terminate(). Merged done_glob() code in here. Call err_done().
+ All callers updated.
+ (i18n_init) New function.
+ (fpu_init) New function.
+
+ * output.c: (outp_init) Make void.
+ (init_default_drivers) New function.
+ (outp_read_devices) If no drivers are initialized successfully,
+ call init_default_drivers() to initialize a default driver.
+ (outp_done) Make void.
+ (static var prog) Make const.
+ (parse_options) Make parameter const.
+ (colon_tokenize) Make return value const.
+ (configure_driver) Change prototype to take a broken-down driver
+ configuration instead of a line of text.
+ (configure_driver_line) New function that does what
+ configure_driver() did before.
+
+ * q2c.c: (global var pgmname) Rename program_name.
+
+ * settings.c: (settings_init) Renamed from init_settings().
+ (settings_done) Renamed from done_settings().
+
+ * vfm.c: (global var last_vfm_invocation) Make static.
+ (vfm_last_invocation) New function. All references to
+ last_vfm_invocation update to call this.
+ (procedure) Call update_last_vfm_invocation().
+ (internal_procedure) Ditto.
+ (update_last_vfm_invocation) New function.
+
Sat Dec 10 23:30:19 2005 Ben Pfaff <blp@gnu.org>
Separate random numbers from other settings because of GSL
levene.h \
linked-list.c \
linked-list.h \
- log.h \
loop.c \
magic.c \
magic.h \
#include "alloc.h"
#include "error.h"
#include "filename.h"
+#include "glob.h"
#include "main.h"
#include "misc.h"
#include "output.h"
{
char temp[40];
- snprintf (temp, 80, _("%s - Page %d"), curdate, x->page_number);
+ snprintf (temp, 80, _("%s - Page %d"), get_start_date (),
+ x->page_number);
memcpy (&s[x->w - strlen (temp)], temp, strlen (temp));
}
#include <getopt.h>
#include <stdlib.h>
#include "alloc.h"
+#include "copyleft.h"
#include "error.h"
#include "filename.h"
#include "getl.h"
+#include "glob.h"
#include "main.h"
#include "output.h"
+#include "progname.h"
#include "settings.h"
#include "str.h"
#include "var.h"
#include "version.h"
-#include "copyleft.h"
-#include "glob.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
break;
case 'l':
outp_list_classes ();
- err_hcf (1);
+ terminate (true);
case 'n':
printf (_("%s is not yet implemented."),"-n");
putchar('\n');
case 'V':
puts (version);
puts (legal);
- err_hcf (1);
+ terminate (true);
case 'T':
force_long_view ();
set_testing_mode (true);
static void
usage (void)
{
- printf (gettext (pre_syntax_message), pgmname);
+ printf (gettext (pre_syntax_message), program_name);
outp_list_classes ();
- printf (gettext (post_syntax_message),PACKAGE_BUGREPORT);
+ printf (gettext (post_syntax_message), PACKAGE_BUGREPORT);
- err_hcf (1);
+ terminate (true);
}
execl (shell_fn, shell_process, NULL);
- err_hcf (1);
+ _exit (1);
}
case -1:
#include "lexer.h"
#include "main.h"
#include "output.h"
+#include "progname.h"
#include "settings.h"
#include "str.h"
#include "var.h"
fflush (stdout);
fflush (stderr);
- fprintf (stderr, "%s: %s\n", pgmname,
+ fprintf (stderr, "%s: %s\n", program_name,
_("Terminating NOW due to a fatal error!"));
- err_hcf (0);
+ terminate (false);
}
/* Terminate unless we're interactive or will go interactive when the
#define EXIT_FAILURE 1
#endif
-static int terminating;
+static void puts_stdout (const char *s);
+static void dump_message (char *errbuf, unsigned indent,
+ void (*func) (const char *), unsigned width);
-/* Halt-catch-fire. SUCCESS should be nonzero if exiting successfully
- or zero if not. Despite the name, this is the usual way to finish,
- successfully or not. */
void
-err_hcf (int success)
+err_done (void)
{
- terminating = 1;
-
- lex_done();
- getl_uninitialize ();
-
- free(file_loc);
+ free (file_loc);
file_loc = NULL;
nfile_loc = mfile_loc = 0;
-
- outp_done ();
- done_glob();
-
- exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
}
-static void puts_stdout (const char *s);
-static void dump_message (char *errbuf, unsigned indent,
- void (*func) (const char *), unsigned width);
-
void
err_vmsg (const struct error *e, const char *format, va_list args)
{
ds_destroy (&msg);
- if (e->class == FE && !terminating)
- err_hcf (0);
+ if (e->class == FE)
+ terminate (0);
}
\f
/* Private functions. */
void err_location (struct file_locator *);
/* Obscure functions. */
+void err_done (void);
void err_break (void);
void err_check_count (void);
-void err_hcf (int exit_code) NO_RETURN;
void err_vmsg (const struct error *, const char *, va_list);
/* Used in panic situations only */
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC",
};
+ time_t last_vfm_invocation = vfm_last_invocation ();
struct tm *time;
char temp_buf[10];
return expr_allocate_number (e, SYSMIS);
else if (lex_match_id ("$JDATE"))
{
- struct tm *time = localtime (&last_vfm_invocation);
- return expr_allocate_number (e, expr_ymd_to_ofs (time->tm_year + 1900,
- time->tm_mon + 1,
- time->tm_mday));
+ time_t time = vfm_last_invocation ();
+ struct tm *tm = localtime (&time);
+ return expr_allocate_number (e, expr_ymd_to_ofs (tm->tm_year + 1900,
+ tm->tm_mon + 1,
+ tm->tm_mday));
}
else if (lex_match_id ("$TIME"))
{
- struct tm *time = localtime (&last_vfm_invocation);
+ time_t time = vfm_last_invocation ();
+ struct tm *tm = localtime (&time);
return expr_allocate_number (e,
- expr_ymd_to_date (time->tm_year + 1900,
- time->tm_mon + 1,
- time->tm_mday)
- + time->tm_hour * 60 * 60.
- + time->tm_min * 60.
- + time->tm_sec);
+ expr_ymd_to_date (tm->tm_year + 1900,
+ tm->tm_mon + 1,
+ tm->tm_mday)
+ + tm->tm_hour * 60 * 60.
+ + tm->tm_min * 60.
+ + tm->tm_sec);
}
else if (lex_match_id ("$LENGTH"))
return expr_allocate_number (e, get_viewlength ());
#include <config.h>
#include "glob.h"
-#include "error.h"
-#include "progname.h"
-#include <stdlib.h>
-#include <stdio.h>
#include <time.h>
-
-#if HAVE_LIBHISTORY
-#if HAVE_READLINE_HISTORY_H
-#include <readline/history.h>
-#else /* no readline/history.h */
-extern void using_history ();
-extern int read_history ();
-extern void stifle_history ();
-#endif /* no readline/history.h */
-#endif /* -lhistory */
-
-#if HAVE_FPU_CONTROL_H
-#include <fpu_control.h>
-#elif __BORLANDC__
-#include <float.h>
-#include <math.h>
-#endif
-
-#if __DJGPP__
-#include <conio.h>
-#elif defined (__WIN32__) && defined (__BORLANDC__)
-#undef gettext
-#include <conio.h>
-#define gettext(STRING) \
- STRING
-#endif
-
-#if HAVE_LOCALE_H
-#include <locale.h>
-#endif
-
-#if HAVE_FENV_H
-#include <fenv.h>
-#endif
-
-#include "alloc.h"
-#include "calendar.h"
-#include "command.h"
-#include "dictionary.h"
-#include "error.h"
-#include "file-handle.h"
-#include "filename.h"
-#include "getl.h"
-#include "hash.h"
-#include "lexer.h"
-#include "magic.h"
-#include "main.h"
-#include "random.h"
-#include "settings.h"
#include "str.h"
-#include "var.h"
-#include "version.h"
-#include "vfm.h"
-
-#include "gettext.h"
+#include "strftime.h"
/* var.h */
struct dictionary *default_dict;
int FILTER_before_TEMPORARY;
struct file_handle *default_handle;
-
-/* log.h */
-char *logfn;
-FILE *logfile;
-int logging;
\f
/* Functions. */
-static void get_date (void);
-
-
-void
-init_glob (int argc UNUSED, char **argv)
-{
- set_program_name (argv[0]);
-
- /* FIXME: Allow i18n of other locale items (besides LC_MESSAGES). */
-#if ENABLE_NLS
-#if HAVE_LC_MESSAGES
- setlocale (LC_MESSAGES, "");
-#endif
- setlocale (LC_MONETARY, "");
- bindtextdomain (PACKAGE, locale_dir);
- textdomain (PACKAGE);
-#endif /* ENABLE_NLS */
-
- fn_init ();
- fh_init ();
- getl_initialize ();
-
- /* PORTME: If your system/OS has the nasty tendency to halt with a
- SIGFPE whenever there's a floating-point overflow (or other
- exception), be sure to mask off those bits in the FPU here.
- PSPP wants a guarantee that, no matter what boneheaded
- floating-point operation it performs, the process will not halt. */
-#if HAVE_FEHOLDEXCEPT
- {
- fenv_t foo;
-
- feholdexcept (&foo);
- }
-#elif HAVE___SETFPUCW && defined(_FPU_IEEE)
- __setfpucw (_FPU_IEEE);
-#elif __BORLANDC__
- _control87 (0xffff, 0x137f);
-#endif
-
- /* var.h */
- default_dict = dict_create ();
-
- last_vfm_invocation = time (NULL);
-
- /* lexer.h */
- ds_init (&tokstr, 64);
-
- /* common.h */
- {
- char *cp;
-
- pgmname = argv[0];
- for (;;)
- {
- cp = strchr (pgmname, DIR_SEPARATOR);
- if (!cp)
- break;
- pgmname = &cp[1];
- }
- cur_proc = NULL;
- }
-
-
- init_settings ();
- random_init ();
-
- /* log.h */
- logging = 1;
- logfn = xstrdup ("pspp.log");
- logfile = NULL;
-
- get_date ();
-}
-
-void
-done_glob(void)
-{
- cancel_transformations ();
- dict_destroy (default_dict);
- free (logfn);
- random_done ();
- done_settings ();
- ds_destroy (&tokstr);
-
- fh_done();
-}
-
static void
-get_date (void)
+get_cur_date (char cur_date[12])
{
+ time_t now = time (NULL);
- time_t t;
- struct tm *tmp;
-
- if ((time_t) -1 == time (&t))
+ if (now != (time_t) -1)
{
- strcpy (curdate, "?? ??? 2???");
- return;
+ struct tm *tm = localtime (&now);
+ if (tm != NULL)
+ {
+ strftime (cur_date, 12, "%d %b %Y", tm);
+ return;
+ }
}
- tmp = localtime (&t);
-
- strftime (curdate, 12, "%d %b %Y",tmp);
+ strcpy (cur_date, "?? ??? 2???");
}
-#if __BORLANDC__
-int
-_RTLENTRY _EXPFUNC _matherr (struct exception _FAR *__e)
+const char *
+get_start_date (void)
{
- return 1;
-}
+ static char start_date[12];
-int
-_RTLENTRY _EXPFUNC _matherrl (struct _exceptionl _FAR *__e)
-{
- return 1;
+ if (start_date[0] == '\0')
+ get_cur_date (start_date);
+ return start_date;
}
-#endif
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-#if !INCLUDED_GLOB_H
-#define INCLUDED_GLOB_H 1
+#if !GLOB_H
+#define GLOB_H 1
-void init_glob (int argc UNUSED, char **argv);
-void done_glob (void);
+const char *get_start_date (void);
#endif /* glob.h */
void
lex_init (void)
{
+ ds_init (&tokstr, 64);
ds_init (&put_tokstr, 64);
if (!lex_get_line ())
unexpected_eof ();
void
lex_done (void)
{
- ds_destroy(&put_tokstr);
+ ds_destroy (&put_tokstr);
+ ds_destroy (&tokstr);
}
\f
+++ /dev/null
-/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
-
- 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 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. */
-
-#if !log_h
-#define log_h 1
-
-#include <stdio.h>
-
-/* Whether logging is on. */
-extern int logging;
-
-/* The name of the log file. */
-extern char *logfn;
-
-/* The log file stream. */
-extern FILE *logfile;
-
-/* Log file management. */
-void open_logfile (void);
-void close_logfile (void);
-
-#endif /* !log_h */
02110-1301, USA. */
#include <config.h>
-#include <stdio.h>
-#include <gsl/gsl_errno.h>
#include "main.h"
+#include <gsl/gsl_errno.h>
+#include <signal.h>
+#include <stdio.h>
#include "cmdline.h"
#include "command.h"
#include "dictionary.h"
#include "error.h"
+#include "file-handle.h"
+#include "filename.h"
#include "getl.h"
#include "glob.h"
#include "lexer.h"
#include "output.h"
+#include "progname.h"
+#include "random.h"
#include "settings.h"
#include "var.h"
-#include <signal.h>
+#include "version.h"
+
+#if HAVE_FPU_CONTROL_H
+#include <fpu_control.h>
+#endif
+
+#if HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#if HAVE_FENV_H
+#include <fenv.h>
+#endif
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "debug-print.h"
-static void parse_script (void) NO_RETURN;
+static void i18n_init (void);
+static void fpu_init (void);
static void handle_error (int code);
static int execute_command (void);
-/* argv[0] with stripped leading directories. */
-char *pgmname;
-
/* Whether FINISH. has been executed. */
int finished;
-/* The current date in the form DD MMM YYYY. */
-char curdate[12];
-
-
/* If a segfault happens, issue a message to that effect and halt */
void bug_handler(int sig);
we hit end-of-file unexpectedly (or whatever). */
int start_interactive;
-
-
-
-
-
/* Program entry point. */
int
main (int argc, char **argv)
{
-
signal (SIGSEGV, bug_handler);
- signal (SIGFPE, bug_handler);
- signal (SIGINT, interrupt_handler);
+ signal (SIGFPE, bug_handler);
+ signal (SIGINT, interrupt_handler);
- gsl_set_error_handler_off();
+ set_program_name ("pspp");
+ i18n_init ();
+ fpu_init ();
+ gsl_set_error_handler_off ();
- /* Initialization. */
- if (!outp_init ())
- err_hcf (0);
- init_glob (argc, argv);
- parse_command_line (argc, argv);
- if (!outp_read_devices ())
- msg (FE, _("Error initializing output drivers."));
+ outp_init ();
+ fn_init ();
+ fh_init ();
+ getl_initialize ();
+ settings_init ();
+ random_init ();
- lex_init ();
+ default_dict = dict_create ();
- /* Execution. */
- parse_script ();
+ parse_command_line (argc, argv);
+ outp_read_devices ();
- /* Should never be reached */
- return (-1);
-}
+ lex_init ();
-/* Parses the entire script. */
-static void
-parse_script (void)
-{
while (!finished)
{
err_check_count ();
handle_error (execute_command ());
}
- err_hcf (err_error_count==0);
+ terminate (err_error_count == 0);
+ abort ();
+}
+
+/* Terminate PSPP. SUCCESS should be true to exit successfully,
+ false to exit as a failure. */
+void
+terminate (bool success)
+{
+ static bool terminating = false;
+ if (terminating)
+ return;
+ terminating = true;
+
+ err_done ();
+ outp_done ();
+
+ cancel_transformations ();
+ dict_destroy (default_dict);
+
+ random_done ();
+ settings_done ();
+ fh_done ();
+ lex_done ();
+ getl_uninitialize ();
+
+ exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
}
/* Parse and execute a command, returning its return code. */
break;
if (!getl_perform_delayed_reset ())
- err_hcf (err_error_count==0);
+ terminate (err_error_count == 0);
}
/* Parse the command. */
lex_discard_line ();
}
}
+\f
+static void
+i18n_init (void)
+{
+#if ENABLE_NLS
+#if HAVE_LC_MESSAGES
+ setlocale (LC_MESSAGES, "");
+#endif
+ setlocale (LC_MONETARY, "");
+ bindtextdomain (PACKAGE, locale_dir);
+ textdomain (PACKAGE);
+#endif /* ENABLE_NLS */
+}
-
+static void
+fpu_init (void)
+{
+#if HAVE_FEHOLDEXCEPT
+ fenv_t foo;
+ feholdexcept (&foo);
+#elif HAVE___SETFPUCW && defined(_FPU_IEEE)
+ __setfpucw (_FPU_IEEE);
+#endif
+}
/* If a segfault happens, issue a message to that effect and halt */
void
-bug_handler(int sig UNUSED)
+bug_handler(int sig)
{
switch (sig)
{
void
interrupt_handler(int sig UNUSED)
{
- err_hcf(0);
+ terminate (false);
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-#if !main_h
-#define main_h 1
+#if !MAIN_H
+#define MAIN_H 1
+
+#include <stdbool.h>
-extern char *pgmname;
-extern char curdate[];
extern int start_interactive;
extern int finished;
+void terminate (bool success);
+
#endif /* main.h */
static int disabled_devices;
static void destroy_driver (struct outp_driver *);
-static void configure_driver (char *);
+static void configure_driver_line (char *);
+static void configure_driver (const char *, const char *,
+ const char *, const char *);
#if GLOBAL_DEBUGGING
/* This mechanism attempts to catch reentrant use of outp_driver_list. */
}
/* Initializes global variables. */
-int
+void
outp_init (void)
{
extern struct outp_class ascii_class;
extern struct outp_class postscript_class;
extern struct outp_class epsf_class;
#endif
+#if !NO_HTML
extern struct outp_class html_class;
+#endif
char def[] = "default";
add_class (&ascii_class);
add_name (def, &def[strlen (def)], OUTP_S_INIT_FILE);
-
- return 1;
}
/* Deletes all the output macros. */
}
}
-/* Reads the initialization file; initializes outp_driver_list. */
-int
+static void
+init_default_drivers (void)
+{
+ msg (MM, _("Using default output driver configuration."));
+ configure_driver ("list-ascii", "ascii", "listing",
+ "length=66 width=79 char-set=ascii "
+ "output-file=\"pspp.list\" "
+ "bold-on=\"\" italic-on=\"\" bold-italic-on=\"\"");
+}
+
+/* Reads the initialization file; initializes
+ outp_driver_list. */
+void
outp_read_devices (void)
{
int result = 0;
struct outp_names *n = search_names (cp, ep);
if (n)
{
- configure_driver (cp);
+ configure_driver_line (cp);
delete_name (n);
}
}
free (init_fn);
ds_destroy (&line);
delete_macros ();
- if (outp_driver_list == NULL)
- msg (MW, _("No output drivers are active."));
- if (result)
- msg (VM (2), _("Device definition file read successfully."));
+ if (result)
+ {
+ msg (VM (2), _("Device definition file read successfully."));
+ if (outp_driver_list == NULL)
+ msg (MW, _("No output drivers are active."));
+ }
else
msg (VM (1), _("Error reading device definition file."));
- return result;
+
+ if (!result || outp_driver_list == NULL)
+ init_default_drivers ();
}
/* Clear the list of drivers to configure. */
}
/* Closes all the output drivers. */
-int
+void
outp_done (void)
{
struct outp_driver_class_list *n = outp_class_list ;
free (outp_subtitle);
outp_subtitle = NULL;
-
- return 1;
}
/* Display on stdout a list of all registered driver classes. */
static int op_token; /* `=', 'a', 0. */
static struct string op_tokstr;
-static char *prog;
+static const char *prog;
/* Parses a token from prog into op_token, op_tokstr. Sets op_token
to '=' on an equals sign, to 'a' on a string or identifier token,
/* Applies the user-specified options in string S to output driver D
(at configuration time). */
static void
-parse_options (char *s, struct outp_driver * d)
+parse_options (const char *s, struct outp_driver * d)
{
prog = s;
op_token = -1;
after all fields have been used up.
FIXME: Should ignore colons inside double quotes. */
-static char *
+static const char *
colon_tokenize (char *s, char **cp)
{
char *token;
Adds a driver to outp_driver_list pursuant to the specification
provided. */
static void
-configure_driver (char *s)
+configure_driver (const char *driver_name, const char *class_name,
+ const char *device_type, const char *options)
{
- char *token, *cp;
struct outp_driver *d = NULL, *iter;
struct outp_driver_class_list *c = NULL;
- s = fn_interp_vars (s, find_defn_value);
-
- /* Driver name. */
- token = colon_tokenize (s, &cp);
- if (!token)
- {
- msg (IS, _("Driver name expected."));
- goto error;
- }
-
d = xmalloc (sizeof *d);
-
d->class = NULL;
- d->name = xstrdup (token);
+ d->name = xstrdup (driver_name);
d->driver_open = 0;
d->page_open = 0;
-
d->next = d->prev = NULL;
-
d->device = OUTP_DEV_NONE;
-
d->ext = NULL;
- /* Class name. */
- token = colon_tokenize (NULL, &cp);
- if (!token)
- {
- msg (IS, _("Class name expected."));
- goto error;
- }
-
for (c = outp_class_list; c; c = c->next)
- if (!strcmp (c->class->name, token))
+ if (!strcmp (c->class->name, class_name))
break;
if (!c)
{
- msg (IS, _("Unknown output driver class `%s'."), token);
+ msg (IS, _("Unknown output driver class `%s'."), class_name);
goto error;
}
}
/* Device types. */
- token = colon_tokenize (NULL, &cp);
- if (token)
+ if (device_type != NULL)
{
+ char *copy = xstrdup (device_type);
char *sp, *type;
- for (type = strtok_r (token, " \t\r\v", &sp); type;
+ for (type = strtok_r (copy, " \t\r\v", &sp); type;
type = strtok_r (NULL, " \t\r\v", &sp))
{
if (!strcmp (type, "listing"))
else
{
msg (IS, _("Unknown device type `%s'."), type);
+ free (copy);
goto error;
}
}
+ free (copy);
}
/* Options. */
- token = colon_tokenize (NULL, &cp);
- if (token)
- parse_options (token, d);
+ if (options != NULL)
+ parse_options (options, d);
if (!d->class->postopen_driver (d))
{
msg (IS, _("Can't complete initialization of output driver `%s' of "
if (outp_driver_list)
outp_driver_list->prev = d;
outp_driver_list = d;
- goto exit;
+ return;
error:
if (d)
destroy_driver (d);
-exit:
- free (s);
+ return;
+}
+
+/* String S is in format:
+ DRIVERNAME:CLASSNAME:DEVICETYPE:OPTIONS
+ Adds a driver to outp_driver_list pursuant to the specification
+ provided. */
+static void
+configure_driver_line (char *s)
+{
+ char *cp;
+ const char *driver_name, *class_name, *device_type, *options;
+
+ s = fn_interp_vars (s, find_defn_value);
+
+ /* Driver name. */
+ driver_name = colon_tokenize (s, &cp);
+ class_name = colon_tokenize (NULL, &cp);
+ device_type = colon_tokenize (NULL, &cp);
+ options = colon_tokenize (NULL, &cp);
+ if (driver_name == NULL || class_name == NULL)
+ {
+ msg (IS, _("Driver definition line contains fewer fields "
+ "than expected"));
+ return;
+ }
+
+ configure_driver (driver_name, class_name, device_type, options);
}
/* Destroys output driver D. */
extern char *outp_title;
extern char *outp_subtitle;
-int outp_init (void);
-int outp_read_devices (void);
-int outp_done (void);
+void outp_init (void);
+void outp_read_devices (void);
+void outp_done (void);
void outp_configure_clear (void);
void outp_configure_add (char *);
#include "font.h"
#include "getl.h"
#include "getline.h"
+#include "glob.h"
#include "hash.h"
#include "main.h"
#include "misc.h"
-#include "misc.h"
#include "output.h"
#include "som.h"
#include "version.h"
int rh_width;
char buf[128];
- sprintf (buf, _("%s - Page %d"), curdate, ext->page_number);
+ sprintf (buf, _("%s - Page %d"), get_start_date (), ext->page_number);
rh_width = text_width (this, buf);
out_text_plain (this, buf, this->width - this->prop_em_width - rh_width,
#define MAX_TOK_LEN 1024
/* argv[0]. */
-char *pgmname;
+char *program_name;
/* Have the input and output files been opened yet? */
int is_open;
fclose (in);
fclose (out);
if (remove (ofn) == -1)
- fprintf (stderr, "%s: %s: remove: %s\n", pgmname, ofn, strerror (errno));
+ fprintf (stderr, "%s: %s: remove: %s\n", program_name, ofn, strerror (errno));
}
void hcf (void) NO_RETURN;
va_list args;
va_start (args, format);
- fprintf (stderr, "%s: ", pgmname);
+ fprintf (stderr, "%s: ", program_name);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
va_end (args);
int
main (int argc, char *argv[])
{
- pgmname = argv[0];
+ program_name = argv[0];
if (argc != 3)
fail ("Syntax: q2c input.q output.c");
#include "lexer.h"
#include "error.h"
#include "magic.h"
-#include "log.h"
#include "output.h"
#include "random.h"
#include "var.h"
static void init_viewport (void);
void
-done_settings (void)
+settings_init (void)
{
- free (prompt);
- free (cprompt);
- free (dprompt);
+ init_viewport ();
}
void
-init_settings (void)
+settings_done (void)
{
- init_viewport ();
+ free (prompt);
+ free (cprompt);
+ free (dprompt);
}
/* Screen length in lines. */
SET_ROUTE_DISABLE = 010 /* Disable output--overrides all other bits. */
};
-void init_settings (void);
-void done_settings (void);
+void settings_init (void);
+void settings_done (void);
void force_long_view (void);
int get_viewlength (void);
#include "command.h"
#include "dictionary.h"
#include "error.h"
+#include "glob.h"
#include "lexer.h"
#include "main.h"
#include "output.h"
/* Add a few header lines for reference. */
{
char buf[256];
- struct tm *tmp = localtime (&last_vfm_invocation);
if (dict_get_documents (default_dict) != NULL)
add_document_line ("", 0);
- sprintf (buf, _("Document entered %s %02d:%02d:%02d by %s (%s):"),
- curdate, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, version,
- host_system);
+ sprintf (buf, _("Document entered %s by %s:"), get_start_date (), version);
add_document_line (buf, 1);
}
static int compaction_necessary;
/* Time at which vfm was last invoked. */
-time_t last_vfm_invocation;
+static time_t last_vfm_invocation;
/* Lag queue. */
int n_lag; /* Number of cases to lag. */
static void internal_procedure (int (*proc_func) (struct ccase *, void *),
void *aux);
+static void update_last_vfm_invocation (void);
static void create_trns_case (struct ccase *, struct dictionary *);
static void open_active_file (void);
static int write_case (struct write_case_data *wc_data);
\f
/* Public functions. */
+/* Returns the last time the data was read. */
+time_t
+vfm_last_invocation (void)
+{
+ if (last_vfm_invocation == 0)
+ update_last_vfm_invocation ();
+ return last_vfm_invocation;
+}
+
/* Reads the data from the input program and writes it to a new
active file. For each case we read from the input program, we
do the following
&& n_trns == 0)
{
/* Nothing to do. */
+ update_last_vfm_invocation ();
return;
}
case_create (&wc_data.sink_case, dict_get_next_value_idx (default_dict));
wc_data.cases_written = 0;
- last_vfm_invocation = time (NULL);
+ update_last_vfm_invocation ();
if (vfm_source != NULL)
vfm_source->class->read (vfm_source,
assert (--recursive_call == 0);
}
+/* Updates last_vfm_invocation. */
+static void
+update_last_vfm_invocation (void)
+{
+ last_vfm_invocation = time (NULL);
+}
+
/* Creates and returns a case, initializing it from the vectors
that say which `value's need to be initialized just once, and
which ones need to be re-initialized before every case. */
#include <time.h>
-/* This is the time at which vfm was last invoked. */
-extern time_t last_vfm_invocation;
-
struct ccase;
typedef struct write_case_data *write_case_data;
typedef int write_case_func (write_case_data);
void multipass_procedure_with_splits (void (*) (const struct casefile *,
void *),
void *aux);
+\f
+time_t vfm_last_invocation (void);
#endif /* !vfm_h */