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
25 #include "dictionary.h"
34 #include "debug-print.h"
36 static int get_title (const char *cmd, char **title);
41 return get_title ("TITLE", &outp_title);
47 return get_title ("SUBTITLE", &outp_subtitle);
51 get_title (const char *cmd, char **title)
55 c = lex_look_ahead ();
56 debug_printf ((_("%s before: %s\n"), cmd, *title ? *title : _("<none>")));
57 if (c == '"' || c == '\'')
60 if (!lex_force_string ())
64 *title = xstrdup (ds_c_str (&tokstr));
68 msg (SE, _("%s: `.' expected after string."), cmd);
78 *title = xstrdup (lex_rest_of_line (NULL));
80 for (cp = *title; *cp; cp++)
81 *cp = toupper ((unsigned char) (*cp));
84 debug_printf ((_("%s after: %s\n"), cmd, *title));
88 /* Performs the FILE LABEL command. */
94 label = lex_rest_of_line (NULL);
96 while (isspace ((unsigned char) *label))
99 dict_set_label (default_dict, label);
105 /* Add LINE as a line of document information to default_dict,
106 indented by INDENT spaces. */
108 add_document_line (const char *line, int indent)
110 const char *old_documents;
114 old_documents = dict_get_documents (default_dict);
115 old_len = old_documents != NULL ? strlen (old_documents) : 0;
116 new_documents = xmalloc (old_len + 81);
118 memcpy (new_documents, old_documents, old_len);
119 memset (new_documents + old_len, ' ', indent);
120 st_bare_pad_copy (new_documents + old_len + indent, line, 80 - indent);
121 new_documents[old_len + 80] = '\0';
123 dict_set_documents (default_dict, new_documents);
125 free (new_documents);
128 /* Performs the DOCUMENT command. */
132 /* Add a few header lines for reference. */
135 struct tm *tmp = localtime (&last_vfm_invocation);
137 if (dict_get_documents (default_dict) != NULL)
138 add_document_line ("", 0);
140 sprintf (buf, _("Document entered %s %02d:%02d:%02d by %s (%s):"),
141 curdate, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, version,
143 add_document_line (buf, 1);
149 const char *orig_line;
152 orig_line = lex_rest_of_line (&had_dot);
154 while (isspace ((unsigned char) *orig_line))
157 copy_line = xmalloc (strlen (orig_line) + 2);
158 strcpy (copy_line, orig_line);
160 strcat (copy_line, ".");
162 add_document_line (copy_line, 3);
174 /* Performs the DROP DOCUMENTS command. */
176 cmd_drop_documents (void)
178 dict_set_documents (default_dict, NULL);
180 return lex_end_of_command ();