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., 51 Franklin Street, Fifth Floor, Boston, MA
29 static int viewlength = 24;
30 static int viewwidth = 79;
31 static bool long_view = false;
33 static bool safer_mode = false;
35 static char decimal = '.';
36 static char grouping = ',';
38 static bool echo = false;
39 static bool include = true;
41 static int epoch = -1;
43 static bool errorbreak = false;
45 static bool scompress = false;
47 static bool undefined = true;
48 static double blanks = SYSMIS;
50 static int mxwarns = 100;
51 static int mxerrs = 100;
53 static bool printback = true;
54 static bool mprint = true;
56 static int mxloops = 1;
58 static bool nulline = true;
60 static char endcmd = '.';
62 static size_t workspace = 4L * 1024 * 1024;
64 static struct fmt_spec default_format = {FMT_F, 8, 2};
66 #define CC_INITIALIZER {"-", "", "", "", '.', ','}
67 static struct custom_currency cc[CC_CNT] =
76 static bool testing_mode = false;
78 static int global_algorithm = ENHANCED;
79 static int cmd_algorithm = ENHANCED;
80 static int *algorithm = &global_algorithm;
82 static int syntax = ENHANCED;
84 static void init_viewport (void);
97 /* Screen length in lines. */
104 /* Sets the view length. */
106 set_viewlength (int viewlength_)
108 viewlength = viewlength_;
111 /* Set view width to a very long value, and prevent it from ever
114 force_long_view (void)
127 /* Sets the screen width. */
129 set_viewwidth (int viewwidth_)
131 viewwidth = viewwidth_;
136 get_termcap_viewport (void)
138 char term_buffer[16384];
139 if (getenv ("TERM") == NULL)
141 else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
143 msg (IE, _("Could not access definition for terminal `%s'."), termtype);
147 if (tgetnum ("li") > 0)
148 viewlength = tgetnum ("li");
150 if (tgetnum ("co") > 1)
151 viewwidth = tgetnum ("co") - 1;
153 #endif /* HAVE_LIBTERMCAP */
161 viewwidth = viewlength = -1;
164 get_termcap_viewport ();
165 #endif /* HAVE_LIBTERMCAP */
167 if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
168 viewwidth = atoi (getenv ("COLUMNS"));
169 if (viewlength < 0 && getenv ("LINES") != NULL)
170 viewlength = atoi (getenv ("LINES"));
178 /* Whether PSPP can erase and overwrite files. */
180 get_safer_mode (void)
185 /* Set safer mode. */
187 set_safer_mode (void)
192 /* The character used for a decimal point: ',' or '.'. Only
193 respected for data input and output. */
200 /* Sets the character used for a decimal point, which must be
201 either ',' or '.'. */
203 set_decimal (char decimal_)
205 assert (decimal_ == '.' || decimal_ == ',');
209 /* The character used for grouping in numbers: '.' or ','; the
210 opposite of set_decimal. Only used in COMMA data input and
218 /* Sets the character used for grouping, which must be either ','
221 set_grouping (char grouping_)
223 assert (grouping_ == '.' || grouping_ == ',');
224 grouping = grouping_;
227 /* Echo commands to the listing file/printer? */
236 set_echo (bool echo_)
241 /* If echo is on, whether commands from include files are echoed. */
248 /* Set include file echo. */
250 set_include (bool include_)
255 /* What year to use as the start of the epoch. */
262 struct tm *tm = localtime (&t);
263 epoch = (tm != NULL ? tm->tm_year + 1900 : 2000) - 69;
269 /* Sets the year that starts the epoch. */
271 set_epoch (int epoch_)
276 /* Does an error stop execution? */
278 get_errorbreak (void)
283 /* Sets whether an error stops execution. */
285 set_errorbreak (bool errorbreak_)
287 errorbreak = errorbreak_;
290 /* Compress system files by default? */
292 get_scompression (void)
297 /* Set system file default compression. */
299 set_scompression (bool scompress_)
301 scompress = scompress_;
304 /* Whether to warn on undefined values in numeric data. */
311 /* Set whether to warn on undefined values. */
313 set_undefined (bool undefined_)
315 undefined = undefined_;
318 /* The value that blank numeric fields are set to when read in. */
325 /* Set the value that blank numeric fields are set to when read
328 set_blanks (double blanks_)
333 /* Maximum number of warnings + errors. */
340 /* Sets maximum number of warnings + errors. */
342 set_mxwarns (int mxwarns_)
347 /* Maximum number of errors. */
354 /* Sets maximum number of errors. */
356 set_mxerrs (int mxerrs_)
361 /* Whether commands are written to the display. */
368 /* Sets whether commands are written to the display. */
370 set_printback (bool printback_)
372 printback = printback_;
375 /* Independent of get_printback, controls whether the commands
376 generated by macro invocations are displayed. */
383 /* Sets whether the commands generated by macro invocations are
386 set_mprint (bool mprint_)
391 /* Implied limit of unbounded loop. */
398 /* Set implied limit of unbounded loop. */
400 set_mxloops (int mxloops_)
405 /* Whether a blank line is a command terminator. */
412 /* Set whether a blank line is a command terminator. */
414 set_nulline (bool nulline_)
419 /* The character used to terminate commands. */
426 /* Set the character used to terminate commands. */
428 set_endcmd (char endcmd_)
433 /* Approximate maximum amount of memory to use for cases, in
441 /* Set approximate maximum amount of memory to use for cases, in
445 set_workspace (size_t workspace_)
447 workspace = workspace_;
450 /* Default format for variables created by transformations and by
451 DATA LIST {FREE,LIST}. */
452 const struct fmt_spec *
455 return &default_format;
458 /* Set default format for variables created by transformations
459 and by DATA LIST {FREE,LIST}. */
461 set_format (const struct fmt_spec *default_format_)
463 default_format = *default_format_;
466 /* Gets the custom currency specification with the given IDX. */
467 const struct custom_currency *
470 assert (idx >= 0 && idx < CC_CNT);
474 /* Gets custom currency specification IDX to CC. */
476 set_cc (int idx, const struct custom_currency *cc_)
478 assert (idx >= 0 && idx < CC_CNT);
482 /* Are we in testing mode? (e.g. --testing-mode command line
485 get_testing_mode (void)
490 /* Set testing mode. */
492 set_testing_mode (bool testing_mode_)
494 testing_mode = testing_mode_;
497 /* Return the current algorithm setting */
504 /* Set the algorithm option globally. */
506 set_algorithm (enum behavior_mode mode)
508 global_algorithm = mode;
511 /* Set the algorithm option for this command only */
513 set_cmd_algorithm (enum behavior_mode mode)
515 cmd_algorithm = mode;
516 algorithm = &cmd_algorithm;
519 /* Unset the algorithm option for this command */
521 unset_cmd_algorithm (void)
523 algorithm = &global_algorithm;
526 /* Get the current syntax setting */
533 /* Set the syntax option */
535 set_syntax (enum behavior_mode mode)