QUICK CLUSTER: Use fixed format for cluster centers.
[pspp.git] / src / ui / source-init-opts.c
blobc7963c01477afc6b268d2c428a3164ddea0e2052
1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2008, 2010, 2014 Free Software Foundation
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/>. */
17 #include <config.h>
19 #include "source-init-opts.h"
21 #include <stdbool.h>
22 #include <stdlib.h>
23 #include <string.h>
25 #include "data/settings.h"
26 #include "language/lexer/include-path.h"
27 #include "language/lexer/lexer.h"
28 #include "libpspp/assertion.h"
29 #include "libpspp/argv-parser.h"
30 #include "libpspp/llx.h"
31 #include "libpspp/message.h"
32 #include "ui/syntax-gen.h"
34 #include "gl/error.h"
35 #include "gl/xalloc.h"
37 #include "gettext.h"
38 #define _(msgid) gettext (msgid)
39 #define N_(msgid) msgid
41 enum
43 OPT_ALGORITHM,
44 OPT_INCLUDE,
45 OPT_NO_INCLUDE,
46 OPT_SAFER,
47 OPT_SYNTAX,
48 N_SOURCE_INIT_OPTIONS
51 static const struct argv_option source_init_options[N_SOURCE_INIT_OPTIONS] =
53 {"algorithm", 'a', required_argument, OPT_ALGORITHM},
54 {"include", 'I', required_argument, OPT_INCLUDE},
55 {"no-include", 0, no_argument, OPT_NO_INCLUDE},
56 {"safer", 's', no_argument, OPT_SAFER},
57 {"syntax", 'x', required_argument, OPT_SYNTAX},
60 static void
61 source_init_option_callback (int id, void *aux UNUSED)
63 switch (id)
65 case OPT_ALGORITHM:
66 if (!strcmp (optarg, "compatible"))
67 settings_set_algorithm (COMPATIBLE);
68 else if (!strcmp (optarg, "enhanced"))
69 settings_set_algorithm (ENHANCED);
70 else
71 error (1, 0,
72 _("Algorithm must be either `%s' or `%s'."), "compatible", "enhanced");
73 break;
75 case OPT_INCLUDE:
76 if (!strcmp (optarg, "-"))
77 include_path_clear ();
78 else
79 include_path_add (optarg);
80 break;
82 case OPT_NO_INCLUDE:
83 include_path_clear ();
84 break;
86 case OPT_SAFER:
87 settings_set_safer_mode ();
88 break;
90 case OPT_SYNTAX:
91 if (!strcmp (optarg, "compatible"))
92 settings_set_syntax (COMPATIBLE);
93 else if (!strcmp (optarg, "enhanced"))
94 settings_set_syntax (ENHANCED);
95 else
96 error (1, 0,
97 _("Syntax must be either `%s' or `%s'."), "compatible", "enhanced");
98 break;
100 default:
101 NOT_REACHED ();
105 void
106 source_init_register_argv_parser (struct argv_parser *ap)
108 argv_parser_add_options (ap, source_init_options, N_SOURCE_INIT_OPTIONS,
109 source_init_option_callback, NULL);