1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000, 2007, 2010, 2011 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/>. */
22 #include "data/dataset.h"
23 #include "data/dictionary.h"
24 #include "data/variable.h"
25 #include "language/command.h"
26 #include "language/lexer/lexer.h"
27 #include "language/lexer/token.h"
28 #include "libpspp/message.h"
29 #include "libpspp/start-date.h"
30 #include "libpspp/version.h"
31 #include "output/driver.h"
33 #include "gl/c-ctype.h"
34 #include "gl/xalloc.h"
37 #define _(msgid) gettext (msgid)
40 parse_title (struct lexer *lexer, void (*set_title) (const char *))
42 if (lex_token (lexer) == T_STRING)
44 set_title (lex_tokcstr (lexer));
49 int start_ofs = lex_ofs (lexer);
50 while (lex_token (lexer) != T_ENDCMD)
53 /* Get the raw representation of all the tokens, including any space
54 between them, and use it as the title. */
55 char *title = lex_ofs_representation (lexer, start_ofs,
64 cmd_title (struct lexer *lexer, struct dataset *ds UNUSED)
66 return parse_title (lexer, output_set_title);
70 cmd_subtitle (struct lexer *lexer, struct dataset *ds UNUSED)
72 return parse_title (lexer, output_set_subtitle);
75 /* Performs the FILE LABEL command. */
77 cmd_file_label (struct lexer *lexer, struct dataset *ds)
79 if (!lex_force_string (lexer))
82 dict_set_label (dataset_dict (ds), lex_tokcstr (lexer));
88 /* Performs the DOCUMENT command. */
90 cmd_document (struct lexer *lexer, struct dataset *ds)
92 struct dictionary *dict = dataset_dict (ds);
95 if (!lex_force_string (lexer))
98 while (lex_is_string (lexer))
100 dict_add_document_line (dict, lex_tokcstr (lexer), true);
104 trailer = xasprintf (_(" (Entered %s)"), get_start_date ());
105 dict_add_document_line (dict, trailer, true);
111 /* Performs the ADD DOCUMENTS command. */
113 cmd_add_documents (struct lexer *lexer, struct dataset *ds)
115 return cmd_document (lexer, ds);
118 /* Performs the DROP DOCUMENTS command. */
120 cmd_drop_documents (struct lexer *lexer UNUSED, struct dataset *ds)
122 dict_clear_documents (dataset_dict (ds));