1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
28 #include <libpspp/i18n.h>
30 static int viewlength = 24;
31 static int viewwidth = 79;
32 static bool long_view = false;
34 static bool safer_mode = false;
36 static bool echo = false;
37 static bool include = true;
39 static int epoch = -1;
41 static bool errorbreak = false;
43 static bool scompress = true;
45 static bool undefined = true;
46 static double blanks = SYSMIS;
48 static int mxwarns = 100;
49 static int mxerrs = 100;
51 static bool printback = true;
52 static bool mprint = true;
54 static int mxloops = 1;
56 static bool nulline = true;
58 static char endcmd = '.';
60 static size_t workspace = 4L * 1024 * 1024;
62 static struct fmt_spec default_format = {FMT_F, 8, 2};
64 static bool testing_mode = false;
66 static int global_algorithm = ENHANCED;
67 static int cmd_algorithm = ENHANCED;
68 static int *algorithm = &global_algorithm;
70 static int syntax = ENHANCED;
72 static void init_viewport (void);
87 /* Screen length in lines. */
94 /* Sets the view length. */
96 set_viewlength (int viewlength_)
98 viewlength = viewlength_;
101 /* Set view width to a very long value, and prevent it from ever
104 force_long_view (void)
117 /* Sets the screen width. */
119 set_viewwidth (int viewwidth_)
121 viewwidth = viewwidth_;
126 get_termcap_viewport (void)
128 char term_buffer[16384];
129 if (getenv ("TERM") == NULL)
131 else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
133 msg (IE, _("Could not access definition for terminal `%s'."), termtype);
137 if (tgetnum ("li") > 0)
138 viewlength = tgetnum ("li");
140 if (tgetnum ("co") > 1)
141 viewwidth = tgetnum ("co") - 1;
143 #endif /* HAVE_LIBTERMCAP */
151 viewwidth = viewlength = -1;
154 get_termcap_viewport ();
155 #endif /* HAVE_LIBTERMCAP */
157 if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
158 viewwidth = atoi (getenv ("COLUMNS"));
159 if (viewlength < 0 && getenv ("LINES") != NULL)
160 viewlength = atoi (getenv ("LINES"));
168 /* Whether PSPP can erase and overwrite files. */
170 get_safer_mode (void)
175 /* Set safer mode. */
177 set_safer_mode (void)
182 /* Echo commands to the listing file/printer? */
191 set_echo (bool echo_)
196 /* If echo is on, whether commands from include files are echoed. */
203 /* Set include file echo. */
205 set_include (bool include_)
210 /* What year to use as the start of the epoch. */
217 struct tm *tm = localtime (&t);
218 epoch = (tm != NULL ? tm->tm_year + 1900 : 2000) - 69;
224 /* Sets the year that starts the epoch. */
226 set_epoch (int epoch_)
231 /* Does an error stop execution? */
233 get_errorbreak (void)
238 /* Sets whether an error stops execution. */
240 set_errorbreak (bool errorbreak_)
242 errorbreak = errorbreak_;
245 /* Compress system files by default? */
247 get_scompression (void)
252 /* Set system file default compression. */
254 set_scompression (bool scompress_)
256 scompress = scompress_;
259 /* Whether to warn on undefined values in numeric data. */
266 /* Set whether to warn on undefined values. */
268 set_undefined (bool undefined_)
270 undefined = undefined_;
273 /* The value that blank numeric fields are set to when read in. */
280 /* Set the value that blank numeric fields are set to when read
283 set_blanks (double blanks_)
288 /* Maximum number of warnings + errors. */
295 /* Sets maximum number of warnings + errors. */
297 set_mxwarns (int mxwarns_)
302 /* Maximum number of errors. */
309 /* Sets maximum number of errors. */
311 set_mxerrs (int mxerrs_)
316 /* Whether commands are written to the display. */
323 /* Sets whether commands are written to the display. */
325 set_printback (bool printback_)
327 printback = printback_;
330 /* Independent of get_printback, controls whether the commands
331 generated by macro invocations are displayed. */
338 /* Sets whether the commands generated by macro invocations are
341 set_mprint (bool mprint_)
346 /* Implied limit of unbounded loop. */
353 /* Set implied limit of unbounded loop. */
355 set_mxloops (int mxloops_)
360 /* Whether a blank line is a command terminator. */
367 /* Set whether a blank line is a command terminator. */
369 set_nulline (bool nulline_)
374 /* The character used to terminate commands. */
381 /* Set the character used to terminate commands. */
383 set_endcmd (char endcmd_)
388 /* Approximate maximum amount of memory to use for cases, in
396 /* Set approximate maximum amount of memory to use for cases, in
400 set_workspace (size_t workspace_)
402 workspace = workspace_;
405 /* Default format for variables created by transformations and by
406 DATA LIST {FREE,LIST}. */
407 const struct fmt_spec *
410 return &default_format;
413 /* Set default format for variables created by transformations
414 and by DATA LIST {FREE,LIST}. */
416 set_format (const struct fmt_spec *default_format_)
418 default_format = *default_format_;
421 /* Are we in testing mode? (e.g. --testing-mode command line
424 get_testing_mode (void)
429 /* Set testing mode. */
431 set_testing_mode (bool testing_mode_)
433 testing_mode = testing_mode_;
436 /* Return the current algorithm setting */
443 /* Set the algorithm option globally. */
445 set_algorithm (enum behavior_mode mode)
447 global_algorithm = mode;
450 /* Set the algorithm option for this command only */
452 set_cmd_algorithm (enum behavior_mode mode)
454 cmd_algorithm = mode;
455 algorithm = &cmd_algorithm;
458 /* Unset the algorithm option for this command */
460 unset_cmd_algorithm (void)
462 algorithm = &global_algorithm;
465 /* Get the current syntax setting */
472 /* Set the syntax option */
474 set_syntax (enum behavior_mode mode)