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;
35 static bool safer_mode = false;
37 static bool do_echo = false;
38 static bool include = true;
40 static int epoch = -1;
42 static bool errorbreak = false;
44 static bool route_errors_to_terminal = true;
45 static bool route_errors_to_listing = true;
47 static bool scompress = true;
49 static bool undefined = true;
50 static double blanks = SYSMIS;
52 static int mxwarns = 100;
53 static int mxerrs = 100;
55 static bool printback = true;
56 static bool mprint = true;
58 static int mxloops = 1;
60 static bool nulline = true;
62 static char endcmd = '.';
64 static size_t workspace = 4L * 1024 * 1024;
66 static struct fmt_spec default_format = {FMT_F, 8, 2};
68 static bool testing_mode = false;
70 static int global_algorithm = ENHANCED;
71 static int cmd_algorithm = ENHANCED;
72 static int *algorithm = &global_algorithm;
74 static int syntax = ENHANCED;
76 static void init_viewport (int *, int *);
79 settings_init (int *width, int *length)
81 init_viewport (width, length);
91 /* Screen length in lines. */
98 /* Sets the view length. */
100 set_viewlength (int viewlength_)
102 *viewlength = viewlength_;
112 /* Sets the screen width. */
114 set_viewwidth (int viewwidth_)
116 *viewwidth = viewwidth_;
120 init_viewport (int *width, int *length)
126 /* Whether PSPP can erase and overwrite files. */
128 get_safer_mode (void)
133 /* Set safer mode. */
135 set_safer_mode (void)
140 /* Echo commands to the listing file/printer? */
149 set_echo (bool echo_)
154 /* If echo is on, whether commands from include files are echoed. */
161 /* Set include file echo. */
163 set_include (bool include_)
168 /* What year to use as the start of the epoch. */
175 struct tm *tm = localtime (&t);
176 epoch = (tm != NULL ? tm->tm_year + 1900 : 2000) - 69;
182 /* Sets the year that starts the epoch. */
184 set_epoch (int epoch_)
189 /* Does an error stop execution? */
191 get_errorbreak (void)
196 /* Sets whether an error stops execution. */
198 set_errorbreak (bool errorbreak_)
200 errorbreak = errorbreak_;
203 /* Route error messages to terminal? */
205 get_error_routing_to_terminal (void)
207 return route_errors_to_terminal;
210 /* Sets whether error messages should be routed to the
213 set_error_routing_to_terminal (bool route_to_terminal)
215 route_errors_to_terminal = route_to_terminal;
218 /* Route error messages to listing file? */
220 get_error_routing_to_listing (void)
222 return route_errors_to_listing;
225 /* Sets whether error messages should be routed to the
228 set_error_routing_to_listing (bool route_to_listing)
230 route_errors_to_listing = route_to_listing;
233 /* Compress system files by default? */
235 get_scompression (void)
240 /* Set system file default compression. */
242 set_scompression (bool scompress_)
244 scompress = scompress_;
247 /* Whether to warn on undefined values in numeric data. */
254 /* Set whether to warn on undefined values. */
256 set_undefined (bool undefined_)
258 undefined = undefined_;
261 /* The value that blank numeric fields are set to when read in. */
268 /* Set the value that blank numeric fields are set to when read
271 set_blanks (double blanks_)
276 /* Maximum number of warnings + errors. */
283 /* Sets maximum number of warnings + errors. */
285 set_mxwarns (int mxwarns_)
290 /* Maximum number of errors. */
297 /* Sets maximum number of errors. */
299 set_mxerrs (int mxerrs_)
304 /* Whether commands are written to the display. */
311 /* Sets whether commands are written to the display. */
313 set_printback (bool printback_)
315 printback = printback_;
318 /* Independent of get_printback, controls whether the commands
319 generated by macro invocations are displayed. */
326 /* Sets whether the commands generated by macro invocations are
329 set_mprint (bool mprint_)
334 /* Implied limit of unbounded loop. */
341 /* Set implied limit of unbounded loop. */
343 set_mxloops (int mxloops_)
348 /* Whether a blank line is a command terminator. */
355 /* Set whether a blank line is a command terminator. */
357 set_nulline (bool nulline_)
362 /* The character used to terminate commands. */
369 /* Set the character used to terminate commands. */
371 set_endcmd (char endcmd_)
376 /* Approximate maximum amount of memory to use for cases, in
384 /* Approximate maximum number of cases to allocate in-core, given
385 that each case contains VALUE_CNT values. */
387 get_workspace_cases (size_t value_cnt)
389 size_t case_size = sizeof (union value) * value_cnt + 4 * sizeof (void *);
390 size_t case_cnt = MAX (get_workspace () / case_size, 4);
394 /* Set approximate maximum amount of memory to use for cases, in
398 set_workspace (size_t workspace_)
400 workspace = workspace_;
403 /* Default format for variables created by transformations and by
404 DATA LIST {FREE,LIST}. */
405 const struct fmt_spec *
408 return &default_format;
411 /* Set default format for variables created by transformations
412 and by DATA LIST {FREE,LIST}. */
414 set_format (const struct fmt_spec *default_format_)
416 default_format = *default_format_;
419 /* Are we in testing mode? (e.g. --testing-mode command line
422 get_testing_mode (void)
427 /* Set testing mode. */
429 set_testing_mode (bool testing_mode_)
431 testing_mode = testing_mode_;
434 /* Return the current algorithm setting */
441 /* Set the algorithm option globally. */
443 set_algorithm (enum behavior_mode mode)
445 global_algorithm = mode;
448 /* Set the algorithm option for this command only */
450 set_cmd_algorithm (enum behavior_mode mode)
452 cmd_algorithm = mode;
453 algorithm = &cmd_algorithm;
456 /* Unset the algorithm option for this command */
458 unset_cmd_algorithm (void)
460 algorithm = &global_algorithm;
463 /* Get the current syntax setting */
470 /* Set the syntax option */
472 set_syntax (enum behavior_mode mode)