1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2008, 2010 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/>. */
19 #include "source-init-opts.h"
25 #include "data/file-name.h"
26 #include "data/por-file-reader.h"
27 #include "data/settings.h"
28 #include "data/sys-file-reader.h"
29 #include "language/lexer/include-path.h"
30 #include "language/lexer/lexer.h"
31 #include "libpspp/assertion.h"
32 #include "libpspp/argv-parser.h"
33 #include "libpspp/llx.h"
34 #include "libpspp/message.h"
35 #include "ui/syntax-gen.h"
38 #include "gl/xalloc.h"
41 #define _(msgid) gettext (msgid)
42 #define N_(msgid) msgid
54 static const struct argv_option source_init_options[N_SOURCE_INIT_OPTIONS] =
56 {"algorithm", 'a', required_argument, OPT_ALGORITHM},
57 {"include", 'I', required_argument, OPT_INCLUDE},
58 {"no-include", 0, no_argument, OPT_NO_INCLUDE},
59 {"safer", 's', no_argument, OPT_SAFER},
60 {"syntax", 'x', required_argument, OPT_SYNTAX},
64 source_init_option_callback (int id, void *aux UNUSED)
69 if (!strcmp (optarg, "compatible"))
70 settings_set_algorithm (COMPATIBLE);
71 else if (!strcmp (optarg, "enhanced"))
72 settings_set_algorithm (ENHANCED);
74 /* TRANSLATORS: Leave the words `compatible' and `enhanced' in their
77 _("Algorithm must be either `compatible' or `enhanced'."));
81 if (!strcmp (optarg, "-"))
82 include_path_clear ();
84 include_path_add (optarg);
88 include_path_clear ();
92 settings_set_safer_mode ();
96 if (!strcmp (optarg, "compatible") )
97 settings_set_syntax (COMPATIBLE);
98 else if (!strcmp (optarg, "enhanced"))
99 settings_set_syntax (ENHANCED);
101 /* TRANSLATORS: Leave the words `compatible' and `enhanced' in their
104 _("Syntax must be either `compatible' or `enhanced'."));
113 source_init_register_argv_parser (struct argv_parser *ap)
115 argv_parser_add_options (ap, source_init_options, N_SOURCE_INIT_OPTIONS,
116 source_init_option_callback, NULL);