1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include <libpspp/i18n.h>
30 #define _(msgid) gettext (msgid)
32 static int *viewlength = NULL;
33 static int *viewwidth = NULL;
34 static bool long_view = false;
36 static bool safer_mode = false;
38 static bool do_echo = false;
39 static bool include = true;
41 static int epoch = -1;
43 static bool errorbreak = false;
45 static bool route_errors_to_terminal = true;
46 static bool route_errors_to_listing = true;
48 static bool scompress = true;
50 static bool undefined = true;
51 static double blanks = SYSMIS;
53 static int mxwarns = 100;
54 static int mxerrs = 100;
56 static bool printback = true;
57 static bool mprint = true;
59 static int mxloops = 1;
61 static bool nulline = true;
63 static char endcmd = '.';
65 static size_t workspace = 4L * 1024 * 1024;
67 static struct fmt_spec default_format = {FMT_F, 8, 2};
69 static bool testing_mode = false;
71 static int global_algorithm = ENHANCED;
72 static int cmd_algorithm = ENHANCED;
73 static int *algorithm = &global_algorithm;
75 static int syntax = ENHANCED;
77 static void init_viewport (int *, int *);
80 settings_init (int *width, int *length)
82 init_viewport (width, length);
92 /* Screen length in lines. */
99 /* Sets the view length. */
101 set_viewlength (int viewlength_)
103 *viewlength = viewlength_;
106 /* Set view width to a very long value, and prevent it from ever
109 force_long_view (void)
124 /* Sets the screen width. */
126 set_viewwidth (int viewwidth_)
128 *viewwidth = viewwidth_;
132 init_viewport (int *width, int *length)
142 /* Whether PSPP can erase and overwrite files. */
144 get_safer_mode (void)
149 /* Set safer mode. */
151 set_safer_mode (void)
156 /* Echo commands to the listing file/printer? */
165 set_echo (bool echo_)
170 /* If echo is on, whether commands from include files are echoed. */
177 /* Set include file echo. */
179 set_include (bool include_)
184 /* What year to use as the start of the epoch. */
191 struct tm *tm = localtime (&t);
192 epoch = (tm != NULL ? tm->tm_year + 1900 : 2000) - 69;
198 /* Sets the year that starts the epoch. */
200 set_epoch (int epoch_)
205 /* Does an error stop execution? */
207 get_errorbreak (void)
212 /* Sets whether an error stops execution. */
214 set_errorbreak (bool errorbreak_)
216 errorbreak = errorbreak_;
219 /* Route error messages to terminal? */
221 get_error_routing_to_terminal (void)
223 return route_errors_to_terminal;
226 /* Sets whether error messages should be routed to the
229 set_error_routing_to_terminal (bool route_to_terminal)
231 route_errors_to_terminal = route_to_terminal;
234 /* Route error messages to listing file? */
236 get_error_routing_to_listing (void)
238 return route_errors_to_listing;
241 /* Sets whether error messages should be routed to the
244 set_error_routing_to_listing (bool route_to_listing)
246 route_errors_to_listing = route_to_listing;
249 /* Compress system files by default? */
251 get_scompression (void)
256 /* Set system file default compression. */
258 set_scompression (bool scompress_)
260 scompress = scompress_;
263 /* Whether to warn on undefined values in numeric data. */
270 /* Set whether to warn on undefined values. */
272 set_undefined (bool undefined_)
274 undefined = undefined_;
277 /* The value that blank numeric fields are set to when read in. */
284 /* Set the value that blank numeric fields are set to when read
287 set_blanks (double blanks_)
292 /* Maximum number of warnings + errors. */
299 /* Sets maximum number of warnings + errors. */
301 set_mxwarns (int mxwarns_)
306 /* Maximum number of errors. */
313 /* Sets maximum number of errors. */
315 set_mxerrs (int mxerrs_)
320 /* Whether commands are written to the display. */
327 /* Sets whether commands are written to the display. */
329 set_printback (bool printback_)
331 printback = printback_;
334 /* Independent of get_printback, controls whether the commands
335 generated by macro invocations are displayed. */
342 /* Sets whether the commands generated by macro invocations are
345 set_mprint (bool mprint_)
350 /* Implied limit of unbounded loop. */
357 /* Set implied limit of unbounded loop. */
359 set_mxloops (int mxloops_)
364 /* Whether a blank line is a command terminator. */
371 /* Set whether a blank line is a command terminator. */
373 set_nulline (bool nulline_)
378 /* The character used to terminate commands. */
385 /* Set the character used to terminate commands. */
387 set_endcmd (char endcmd_)
392 /* Approximate maximum amount of memory to use for cases, in
400 /* Approximate maximum number of cases to allocate in-core, given
401 that each case contains VALUE_CNT values. */
403 get_workspace_cases (size_t value_cnt)
405 size_t case_size = sizeof (union value) * value_cnt + 4 * sizeof (void *);
406 size_t case_cnt = MAX (get_workspace () / case_size, 4);
410 /* Set approximate maximum amount of memory to use for cases, in
414 set_workspace (size_t workspace_)
416 workspace = workspace_;
419 /* Default format for variables created by transformations and by
420 DATA LIST {FREE,LIST}. */
421 const struct fmt_spec *
424 return &default_format;
427 /* Set default format for variables created by transformations
428 and by DATA LIST {FREE,LIST}. */
430 set_format (const struct fmt_spec *default_format_)
432 default_format = *default_format_;
435 /* Are we in testing mode? (e.g. --testing-mode command line
438 get_testing_mode (void)
443 /* Set testing mode. */
445 set_testing_mode (bool testing_mode_)
447 testing_mode = testing_mode_;
450 /* Return the current algorithm setting */
457 /* Set the algorithm option globally. */
459 set_algorithm (enum behavior_mode mode)
461 global_algorithm = mode;
464 /* Set the algorithm option for this command only */
466 set_cmd_algorithm (enum behavior_mode mode)
468 cmd_algorithm = mode;
469 algorithm = &cmd_algorithm;
472 /* Unset the algorithm option for this command */
474 unset_cmd_algorithm (void)
476 algorithm = &global_algorithm;
479 /* Get the current syntax setting */
486 /* Set the syntax option */
488 set_syntax (enum behavior_mode mode)