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 route_errors_to_terminal = true;
44 static bool route_errors_to_listing = true;
46 static bool scompress = true;
48 static bool undefined = true;
49 static double blanks = SYSMIS;
51 static int mxwarns = 100;
52 static int mxerrs = 100;
54 static bool printback = true;
55 static bool mprint = true;
57 static int mxloops = 1;
59 static bool nulline = true;
61 static char endcmd = '.';
63 static size_t workspace = 4L * 1024 * 1024;
65 static struct fmt_spec default_format = {FMT_F, 8, 2};
67 static bool testing_mode = false;
69 static int global_algorithm = ENHANCED;
70 static int cmd_algorithm = ENHANCED;
71 static int *algorithm = &global_algorithm;
73 static int syntax = ENHANCED;
75 static void init_viewport (void);
90 /* Screen length in lines. */
97 /* Sets the view length. */
99 set_viewlength (int viewlength_)
101 viewlength = viewlength_;
104 /* Set view width to a very long value, and prevent it from ever
107 force_long_view (void)
120 /* Sets the screen width. */
122 set_viewwidth (int viewwidth_)
124 viewwidth = viewwidth_;
129 get_termcap_viewport (void)
131 char term_buffer[16384];
132 if (getenv ("TERM") == NULL)
134 else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
136 msg (IE, _("Could not access definition for terminal `%s'."), termtype);
140 if (tgetnum ("li") > 0)
141 viewlength = tgetnum ("li");
143 if (tgetnum ("co") > 1)
144 viewwidth = tgetnum ("co") - 1;
146 #endif /* HAVE_LIBTERMCAP */
154 viewwidth = viewlength = -1;
157 get_termcap_viewport ();
158 #endif /* HAVE_LIBTERMCAP */
160 if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
161 viewwidth = atoi (getenv ("COLUMNS"));
162 if (viewlength < 0 && getenv ("LINES") != NULL)
163 viewlength = atoi (getenv ("LINES"));
171 /* Whether PSPP can erase and overwrite files. */
173 get_safer_mode (void)
178 /* Set safer mode. */
180 set_safer_mode (void)
185 /* Echo commands to the listing file/printer? */
194 set_echo (bool echo_)
199 /* If echo is on, whether commands from include files are echoed. */
206 /* Set include file echo. */
208 set_include (bool include_)
213 /* What year to use as the start of the epoch. */
220 struct tm *tm = localtime (&t);
221 epoch = (tm != NULL ? tm->tm_year + 1900 : 2000) - 69;
227 /* Sets the year that starts the epoch. */
229 set_epoch (int epoch_)
234 /* Does an error stop execution? */
236 get_errorbreak (void)
241 /* Sets whether an error stops execution. */
243 set_errorbreak (bool errorbreak_)
245 errorbreak = errorbreak_;
248 /* Route error messages to terminal? */
250 get_error_routing_to_terminal (void)
252 return route_errors_to_terminal;
255 /* Sets whether error messages should be routed to the
258 set_error_routing_to_terminal (bool route_to_terminal)
260 route_errors_to_terminal = route_to_terminal;
263 /* Route error messages to listing file? */
265 get_error_routing_to_listing (void)
267 return route_errors_to_listing;
270 /* Sets whether error messages should be routed to the
273 set_error_routing_to_listing (bool route_to_listing)
275 route_errors_to_listing = route_to_listing;
278 /* Compress system files by default? */
280 get_scompression (void)
285 /* Set system file default compression. */
287 set_scompression (bool scompress_)
289 scompress = scompress_;
292 /* Whether to warn on undefined values in numeric data. */
299 /* Set whether to warn on undefined values. */
301 set_undefined (bool undefined_)
303 undefined = undefined_;
306 /* The value that blank numeric fields are set to when read in. */
313 /* Set the value that blank numeric fields are set to when read
316 set_blanks (double blanks_)
321 /* Maximum number of warnings + errors. */
328 /* Sets maximum number of warnings + errors. */
330 set_mxwarns (int mxwarns_)
335 /* Maximum number of errors. */
342 /* Sets maximum number of errors. */
344 set_mxerrs (int mxerrs_)
349 /* Whether commands are written to the display. */
356 /* Sets whether commands are written to the display. */
358 set_printback (bool printback_)
360 printback = printback_;
363 /* Independent of get_printback, controls whether the commands
364 generated by macro invocations are displayed. */
371 /* Sets whether the commands generated by macro invocations are
374 set_mprint (bool mprint_)
379 /* Implied limit of unbounded loop. */
386 /* Set implied limit of unbounded loop. */
388 set_mxloops (int mxloops_)
393 /* Whether a blank line is a command terminator. */
400 /* Set whether a blank line is a command terminator. */
402 set_nulline (bool nulline_)
407 /* The character used to terminate commands. */
414 /* Set the character used to terminate commands. */
416 set_endcmd (char endcmd_)
421 /* Approximate maximum amount of memory to use for cases, in
429 /* Set approximate maximum amount of memory to use for cases, in
433 set_workspace (size_t workspace_)
435 workspace = workspace_;
438 /* Default format for variables created by transformations and by
439 DATA LIST {FREE,LIST}. */
440 const struct fmt_spec *
443 return &default_format;
446 /* Set default format for variables created by transformations
447 and by DATA LIST {FREE,LIST}. */
449 set_format (const struct fmt_spec *default_format_)
451 default_format = *default_format_;
454 /* Are we in testing mode? (e.g. --testing-mode command line
457 get_testing_mode (void)
462 /* Set testing mode. */
464 set_testing_mode (bool testing_mode_)
466 testing_mode = testing_mode_;
469 /* Return the current algorithm setting */
476 /* Set the algorithm option globally. */
478 set_algorithm (enum behavior_mode mode)
480 global_algorithm = mode;
483 /* Set the algorithm option for this command only */
485 set_cmd_algorithm (enum behavior_mode mode)
487 cmd_algorithm = mode;
488 algorithm = &cmd_algorithm;
491 /* Unset the algorithm option for this command */
493 unset_cmd_algorithm (void)
495 algorithm = &global_algorithm;
498 /* Get the current syntax setting */
505 /* Set the syntax option */
507 set_syntax (enum behavior_mode mode)