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 defined (__WIN32__) && defined (__BORLANDC__)
68 #define gettext(STRING) \
85 #include "file-handle.h"
89 #include "julcal/julcal.h"
100 struct dictionary *default_dict;
101 struct expression *process_if_expr;
103 struct trns_header **t_trns;
108 int FILTER_before_TEMPORARY;
110 struct file_handle *default_handle;
112 struct ctl_stmt *ctl_stack;
121 static void get_date (void);
124 static char term_buffer[16384];
128 init_glob (int argc UNUSED, char **argv)
130 /* FIXME: Allow i18n of other locale items (besides LC_MESSAGES). */
133 setlocale (LC_MESSAGES, "");
135 setlocale (LC_MONETARY, "");
136 bindtextdomain (PACKAGE, locale_dir);
137 textdomain (PACKAGE);
138 #endif /* ENABLE_NLS */
140 /* Workable defaults before we determine the real terminal size. */
147 /* PORTME: If your system/OS has the nasty tendency to halt with a
148 SIGFPE whenever there's a floating-point overflow (or other
149 exception), be sure to mask off those bits in the FPU here.
150 PSPP wants a guarantee that, no matter what boneheaded
151 floating-point operation it performs, the process will not halt. */
152 #if HAVE_FEHOLDEXCEPT
158 #elif HAVE___SETFPUCW && defined(_FPU_IEEE)
159 __setfpucw (_FPU_IEEE);
161 _control87 (0xffff, 0x137f);
165 default_dict = dict_create ();
167 last_vfm_invocation = time (NULL);
170 ds_init (NULL, &tokstr, 64);
179 cp = strchr (pgmname, DIR_SEPARATOR);
188 #if !USE_INTERNAL_PAGER
192 pager = getenv ("STAT_PAGER");
194 pager = getenv ("PAGER");
196 set_pager = xstrdup (pager);
199 set_pager = xstrdup (DEFAULT_PAGER);
200 #endif /* DEFAULT_PAGER */
202 #endif /* !USE_INTERNAL_PAGER */
205 set_scompression = 1;
206 set_format.type = FMT_F;
211 set_results_file = xstrdup ("pspp.prc");
212 set_dprompt = xstrdup (_("data> "));
217 for (i = 0; i < 5; i++)
219 struct set_cust_currency *cc = &set_cc[i];
220 strcpy (cc->buf, "-");
221 cc->neg_prefix = cc->buf;
222 cc->prefix = &cc->buf[1];
223 cc->suffix = &cc->buf[1];
224 cc->neg_suffix = &cc->buf[1];
234 set_journal = xstrdup ("pspp.jnl");
243 set_cprompt = xstrdup (" > ");
250 set_prompt = xstrdup ("PSPP> ");
253 #if __DJGPP__ || __BORLANDC__
258 set_viewlength = max (ti.screenheight, 25);
259 set_viewwidth = max (ti.screenwidth, 79);
261 #elif HAVE_LIBTERMCAP
266 /* This code stolen from termcap.info, though modified. */
267 termtype = getenv ("TERM");
269 msg (FE, _("Specify a terminal type with `setenv TERM <yourtype>'."));
271 success = tgetent (term_buffer, termtype);
275 msg (IE, _("Could not access the termcap data base."));
277 msg (IE, _("Terminal type `%s' is not defined."), termtype);
278 msg (MM, _("Assuming screen of size 79x25."));
284 set_viewlength = tgetnum ("li");
285 set_viewwidth = tgetnum ("co") - 1;
288 #else /* !HAVE_LIBTERMCAP */
291 #endif /* !HAVE_LIBTERMCAP */
295 logfn = xstrdup ("pspp.log");
311 if ((time_t) -1 == time (&t))
313 strcpy (curdate, "?? ??? 2???");
316 tmp = localtime (&t);
318 strftime (curdate, 12, "%d %b %Y",tmp);
323 _RTLENTRY _EXPFUNC _matherr (struct exception _FAR *__e)
329 _RTLENTRY _EXPFUNC _matherrl (struct _exceptionl _FAR *__e)