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
25 #include "dictionary.h"
36 #define _(msgid) gettext (msgid)
38 #include "debug-print.h"
40 static int get_title (const char *cmd, char **title);
45 return get_title ("TITLE", &outp_title);
51 return get_title ("SUBTITLE", &outp_subtitle);
55 get_title (const char *cmd, char **title)
59 c = lex_look_ahead ();
60 debug_printf ((_("%s before: %s\n"), cmd, *title ? *title : _("<none>")));
61 if (c == '"' || c == '\'')
64 if (!lex_force_string ())
68 *title = xstrdup (ds_c_str (&tokstr));
72 msg (SE, _("%s: `.' expected after string."), cmd);
82 *title = xstrdup (lex_rest_of_line (NULL));
84 for (cp = *title; *cp; cp++)
85 *cp = toupper ((unsigned char) (*cp));
88 debug_printf ((_("%s after: %s\n"), cmd, *title));
92 /* Performs the FILE LABEL command. */
98 label = lex_rest_of_line (NULL);
100 while (isspace ((unsigned char) *label))
103 dict_set_label (default_dict, label);
109 /* Add LINE as a line of document information to default_dict,
110 indented by INDENT spaces. */
112 add_document_line (const char *line, int indent)
114 const char *old_documents;
118 old_documents = dict_get_documents (default_dict);
119 old_len = old_documents != NULL ? strlen (old_documents) : 0;
120 new_documents = xmalloc (old_len + 81);
122 memcpy (new_documents, old_documents, old_len);
123 memset (new_documents + old_len, ' ', indent);
124 buf_copy_str_rpad (new_documents + old_len + indent, 80 - indent, line);
125 new_documents[old_len + 80] = '\0';
127 dict_set_documents (default_dict, new_documents);
129 free (new_documents);
132 /* Performs the DOCUMENT command. */
136 /* Add a few header lines for reference. */
140 if (dict_get_documents (default_dict) != NULL)
141 add_document_line ("", 0);
143 sprintf (buf, _("Document entered %s by %s:"), get_start_date (), version);
144 add_document_line (buf, 1);
150 const char *orig_line;
153 orig_line = lex_rest_of_line (&had_dot);
155 while (isspace ((unsigned char) *orig_line))
158 copy_line = xmalloc (strlen (orig_line) + 2);
159 strcpy (copy_line, orig_line);
161 strcat (copy_line, ".");
163 add_document_line (copy_line, 3);
175 /* Performs the DROP DOCUMENTS command. */
177 cmd_drop_documents (void)
179 dict_set_documents (default_dict, NULL);
181 return lex_end_of_command ();