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., 59 Temple Place - Suite 330, Boston, MA
33 #include "debug-print.h"
35 static int get_title (const char *cmd, char **title);
40 return get_title ("TITLE", &outp_title);
46 return get_title ("SUBTITLE", &outp_subtitle);
50 get_title (const char *cmd, char **title)
54 c = lex_look_ahead ();
55 debug_printf ((_("%s before: %s\n"), cmd, *title ? *title : _("<none>")));
56 if (c == '"' || c == '\'')
59 if (!lex_force_string ())
63 *title = xstrdup (ds_value (&tokstr));
67 msg (SE, _("%s: `.' expected after string."), cmd);
77 *title = xstrdup (lex_rest_of_line (NULL));
78 for (cp = *title; *cp; cp++)
79 *cp = toupper ((unsigned char) (*cp));
82 debug_printf ((_("%s after: %s\n"), cmd, *title));
86 /* Performs the FILE LABEL command. */
92 label = lex_rest_of_line (NULL);
93 while (isspace ((unsigned char) *label))
96 dict_set_label (default_dict, label);
102 /* Add LINE as a line of document information to default_dict,
103 indented by INDENT spaces. */
105 add_document_line (const char *line, int indent)
107 const char *old_documents;
111 old_documents = dict_get_documents (default_dict);
112 old_len = old_documents != NULL ? strlen (old_documents) : 0;
113 new_documents = xmalloc (old_len + 81);
115 memcpy (new_documents, old_documents, old_len);
116 memset (new_documents + old_len, ' ', indent);
117 st_bare_pad_copy (new_documents + old_len + indent, line, 80 - indent);
118 new_documents[old_len + 80] = '\0';
120 dict_set_documents (default_dict, new_documents);
122 free (new_documents);
125 /* Performs the DOCUMENT command. */
129 /* Add a few header lines for reference. */
132 struct tm *tmp = localtime (&last_vfm_invocation);
134 if (dict_get_documents (default_dict) != NULL)
135 add_document_line ("", 0);
137 sprintf (buf, _("Document entered %s %02d:%02d:%02d by %s (%s):"),
138 curdate, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, version,
140 add_document_line (buf, 1);
148 line = lex_rest_of_line (&had_dot);
149 while (isspace ((unsigned char) *line))
154 char *cp = strchr (line, 0);
159 add_document_line (line, 3);
170 /* Performs the DROP DOCUMENTS command. */
172 cmd_drop_documents (void)
174 lex_match_id ("DROP");
175 lex_match_id ("DOCUMENTS");
177 dict_set_documents (default_dict, NULL);
179 return lex_end_of_command ();