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 ccase *temp_case;
105 struct trns_header **t_trns;
110 int FILTER_before_TEMPORARY;
112 struct file_handle *default_handle;
114 void (*read_active_file) (void);
115 void (*cancel_input_pgm) (void);
117 struct ctl_stmt *ctl_stack;
126 static void get_date (void);
129 static char term_buffer[16384];
133 init_glob (int argc UNUSED, char **argv)
135 /* FIXME: Allow i18n of other locale items (besides LC_MESSAGES). */
138 setlocale (LC_MESSAGES, "");
140 setlocale (LC_MONETARY, "");
141 bindtextdomain (PACKAGE, locale_dir);
142 textdomain (PACKAGE);
143 #endif /* ENABLE_NLS */
145 /* Workable defaults before we determine the real terminal size. */
152 /* PORTME: If your system/OS has the nasty tendency to halt with a
153 SIGFPE whenever there's a floating-point overflow (or other
154 exception), be sure to mask off those bits in the FPU here.
155 PSPP wants a guarantee that, no matter what boneheaded
156 floating-point operation it performs, the process will not halt. */
157 #if HAVE_FEHOLDEXCEPT
163 #elif HAVE___SETFPUCW && defined(_FPU_IEEE)
164 __setfpucw (_FPU_IEEE);
166 _control87 (0xffff, 0x137f);
170 default_dict = dict_create ();
172 last_vfm_invocation = time (NULL);
175 ds_init (NULL, &tokstr, 64);
184 cp = strchr (pgmname, DIR_SEPARATOR);
193 #if !USE_INTERNAL_PAGER
197 pager = getenv ("STAT_PAGER");
199 pager = getenv ("PAGER");
201 set_pager = xstrdup (pager);
204 set_pager = xstrdup (DEFAULT_PAGER);
205 #endif /* DEFAULT_PAGER */
207 #endif /* !USE_INTERNAL_PAGER */
210 set_scompression = 1;
211 set_format.type = FMT_F;
216 set_results_file = xstrdup ("pspp.prc");
217 set_dprompt = xstrdup (_("data> "));
222 for (i = 0; i < 5; i++)
224 struct set_cust_currency *cc = &set_cc[i];
225 strcpy (cc->buf, "-");
226 cc->neg_prefix = cc->buf;
227 cc->prefix = &cc->buf[1];
228 cc->suffix = &cc->buf[1];
229 cc->neg_suffix = &cc->buf[1];
239 set_journal = xstrdup ("pspp.jnl");
248 set_cprompt = xstrdup (" > ");
255 set_prompt = xstrdup ("PSPP> ");
258 #if __DJGPP__ || __BORLANDC__
263 set_viewlength = max (ti.screenheight, 25);
264 set_viewwidth = max (ti.screenwidth, 79);
266 #elif HAVE_LIBTERMCAP
271 /* This code stolen from termcap.info, though modified. */
272 termtype = getenv ("TERM");
274 msg (FE, _("Specify a terminal type with `setenv TERM <yourtype>'."));
276 success = tgetent (term_buffer, termtype);
280 msg (IE, _("Could not access the termcap data base."));
282 msg (IE, _("Terminal type `%s' is not defined."), termtype);
283 msg (MM, _("Assuming screen of size 79x25."));
289 set_viewlength = tgetnum ("li");
290 set_viewwidth = tgetnum ("co") - 1;
293 #else /* !HAVE_LIBTERMCAP */
296 #endif /* !HAVE_LIBTERMCAP */
300 logfn = xstrdup ("pspp.log");
316 if ((time_t) -1 == time (&t))
318 strcpy (curdate, "?? ??? 2???");
321 tmp = localtime (&t);
323 strftime (curdate, 12, "%d %b %Y",tmp);
328 _RTLENTRY _EXPFUNC _matherr (struct exception _FAR *__e)
334 _RTLENTRY _EXPFUNC _matherrl (struct _exceptionl _FAR *__e)