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
26 #if TIME_WITH_SYS_TIME
40 #else /* !HAVE_TERMCAP_H */
41 int tgetent (char *, char *);
43 #endif /* !HAVE_TERMCAP_H */
44 #endif /* !HAVE_LIBTERMCAP */
47 #if HAVE_READLINE_HISTORY_H
48 #include <readline/history.h>
49 #else /* no readline/history.h */
50 extern void using_history ();
51 extern int read_history ();
52 extern void stifle_history ();
53 #endif /* no readline/history.h */
54 #endif /* -lhistory */
56 #if HAVE_FPU_CONTROL_H
57 #include <fpu_control.h>
65 #elif __WIN32__ && __BORLANDC__
68 #define gettext(STRING) \
88 #include "julcal/julcal.h"
99 struct dictionary default_dict;
100 struct expression *process_if_expr;
102 struct ccase *temp_case;
104 struct trns_header **t_trns;
109 int FILTER_before_TEMPORARY;
111 struct file_handle *default_handle;
113 void (*read_active_file) (void);
114 void (*cancel_input_pgm) (void);
116 struct ctl_stmt *ctl_stack;
125 static void get_date (void);
128 static char term_buffer[16384];
132 init_glob (int argc unused, char **argv)
134 /* FIXME: Allow i18n of other locale items (besides LC_MESSAGES). */
137 setlocale (LC_MESSAGES, "");
139 setlocale (LC_MONETARY, "");
140 bindtextdomain (PACKAGE, locale_dir);
141 textdomain (PACKAGE);
142 #endif /* ENABLE_NLS */
144 /* Workable defaults before we determine the real terminal size. */
151 /* PORTME: If your system/OS has the nasty tendency to halt with a
152 SIGFPE whenever there's a floating-point overflow (or other
153 exception), be sure to mask off those bits in the FPU here.
154 PSPP wants a guarantee that, no matter what boneheaded
155 floating-point operation it performs, the process will not halt. */
156 #if HAVE_FEHOLDEXCEPT
162 #elif HAVE___SETFPUCW && defined(_FPU_IEEE)
163 __setfpucw (_FPU_IEEE);
165 _control87 (0xffff, 0x137f);
169 default_dict.var_by_name = avl_create (NULL, cmp_variable, NULL);
171 vec_init (&reinit_sysmis);
172 vec_init (&reinit_blanks);
173 vec_init (&init_zero);
174 vec_init (&init_blanks);
176 last_vfm_invocation = time (NULL);
179 ds_init (NULL, &tokstr, 64);
188 cp = strchr (pgmname, DIR_SEPARATOR);
197 #if !USE_INTERNAL_PAGER
201 pager = getenv ("STAT_PAGER");
203 pager = getenv ("PAGER");
205 set_pager = xstrdup (pager);
208 set_pager = xstrdup (DEFAULT_PAGER);
209 #endif /* DEFAULT_PAGER */
211 #endif /* !USE_INTERNAL_PAGER */
214 set_scompression = 1;
215 set_format.type = FMT_F;
220 set_results_file = xstrdup ("pspp.prc");
221 set_dprompt = xstrdup (_("data> "));
226 for (i = 0; i < 5; i++)
228 struct set_cust_currency *cc = &set_cc[i];
229 strcpy (cc->buf, "-");
230 cc->neg_prefix = cc->buf;
231 cc->prefix = &cc->buf[1];
232 cc->suffix = &cc->buf[1];
233 cc->neg_suffix = &cc->buf[1];
243 set_journal = xstrdup ("pspp.jnl");
252 set_cprompt = xstrdup (" > ");
259 set_prompt = xstrdup ("PSPP> ");
262 #if __DJGPP__ || __BORLANDC__
267 set_viewlength = max (ti.screenheight, 25);
268 set_viewwidth = max (ti.screenwidth, 79);
270 #elif HAVE_LIBTERMCAP
275 /* This code stolen from termcap.info, though modified. */
276 termtype = getenv ("TERM");
278 msg (FE, _("Specify a terminal type with `setenv TERM <yourtype>'."));
280 success = tgetent (term_buffer, termtype);
284 msg (IE, _("Could not access the termcap data base."));
286 msg (IE, _("Terminal type `%s' is not defined."), termtype);
287 msg (MM, _("Assuming screen of size 79x25."));
293 set_viewlength = tgetnum ("li");
294 set_viewwidth = tgetnum ("co") - 1;
297 #else /* !HAVE_LIBTERMCAP */
300 #endif /* !HAVE_LIBTERMCAP */
304 logfn = xstrdup ("pspp.log");
309 extern void fh_init_files (void);
320 static const char *months[12] =
322 N_("Jan"), N_("Feb"), N_("Mar"), N_("Apr"), N_("May"), N_("Jun"),
323 N_("Jul"), N_("Aug"), N_("Sep"), N_("Oct"), N_("Nov"), N_("Dec"),
330 if ((time_t) -1 == time (&t))
332 strcpy (curdate, "1 Jan 1970");
335 tmp = localtime (&t);
349 yr = tmp->tm_year + 1900;
355 sprintf (curdate, "%2d %s %04d", dy, gettext (months[mn]), yr);
359 cmp_variable (const void *a, const void *b, void *foo unused)
361 return strcmp (((struct variable *) a)->name, ((struct variable *) b)->name);
366 _RTLENTRY _EXPFUNC _matherr (struct exception _FAR *__e)
372 _RTLENTRY _EXPFUNC _matherrl (struct _exceptionl _FAR *__e)