encountered in the input.
@menu
+* ADD DOCUMENT:: Add documentary text to the active file.
* COMMENT:: Document your syntax file.
* DOCUMENT:: Document the active file.
* DISPLAY DOCUMENTS:: Display active file documents.
* TITLE:: Provide a document title.
@end menu
-@node COMMENT, DOCUMENT, Utilities, Utilities
+@node ADD DOCUMENT, COMMENT, Utilities, Utilities
+@comment node-name, next, previous, up
+@section ADD DOCUMENT
+@vindex ADD DOCUMENT
+
+@display
+ADD DOCUMENT
+ 'line one' 'line two' @dots{} 'last line' .
+@end display
+
+
+@cmd{ADD DOCUMENT} adds one or more lines of descriptive commentary to
+the active file. Documents added in this way are saved to system files.
+They can be viewed using @cmd{SYSFILE INFO} or @cmd{DISPLAY
+DOCUMENTS}. They can be removed from the active file with @cmd{DROP
+DOCUMENTS}.
+
+Each line of documentary text must be enclosed in quotation marks, and
+may not be more than 80 bytes long. @xref{DOCUMENT}.
+
+
+
+@node COMMENT, DOCUMENT, ADD DOCUMENT, Utilities
@section COMMENT
@vindex COMMENT
@vindex *
@cmd{COMMENT} can extend over any number of lines. Don't forget to
terminate it with a dot or a blank line.
+
+
@node DOCUMENT, DISPLAY DOCUMENTS, COMMENT, Utilities
@section DOCUMENT
@vindex DOCUMENT
@display
-DOCUMENT documentary_text.
+DOCUMENT @var{documentary_text}.
@end display
@cmd{DOCUMENT} adds one or more lines of descriptive commentary to the
DOCUMENTS}. They can be removed from the active file with @cmd{DROP
DOCUMENTS}.
-Specify the documentary text following the DOCUMENT keyword. You can
-extend the documentary text over as many lines as necessary. Lines are
-truncated at 80 characters width. Don't forget to terminate
-the command with a dot or a blank line.
+Specify the @var{documentary text} following the DOCUMENT keyword.
+It is interpreted literally --- any quotes or other punctuation marks
+will be included in the file.
+You can extend the documentary text over as many lines as necessary.
+Lines are truncated at 80 bytes. Don't forget to terminate
+the command with a dot or a blank line. @xref{ADD DOCUMENT}.
@node DISPLAY DOCUMENTS, DISPLAY FILE LABEL, DOCUMENT, Utilities
@section DISPLAY DOCUMENTS
msgstr ""
"Project-Id-Version: PSPP 0.4.2\n"
"Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2007-04-29 12:09+0800\n"
+"POT-Creation-Date: 2007-05-02 14:35+0800\n"
"PO-Revision-Date: 2006-05-26 17:49+0800\n"
"Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
"Language-Team: German <pspp-dev@gnu.org>\n"
msgid "Error opening \"%s\" for writing as a system file: %s."
msgstr ""
-#: src/data/sys-file-writer.c:1104
+#: src/data/sys-file-writer.c:1101
#, c-format
msgid "An I/O error occurred writing system file \"%s\"."
msgstr ""
"s."
msgstr ""
-#: src/language/dictionary/value-labels.c:158 src/language/lexer/lexer.c:600
+#: src/language/dictionary/value-labels.c:158 src/language/lexer/lexer.c:609
msgid "expecting string"
msgstr ""
-#: src/language/dictionary/value-labels.c:167 src/language/lexer/lexer.c:614
+#: src/language/dictionary/value-labels.c:167 src/language/lexer/lexer.c:623
msgid "expecting integer"
msgstr ""
msgid "Syntax error at %s."
msgstr ""
-#: src/language/lexer/lexer.c:569 src/language/lexer/lexer.c:586
+#: src/language/lexer/lexer.c:578 src/language/lexer/lexer.c:595
#, c-format
msgid "expecting `%s'"
msgstr ""
-#: src/language/lexer/lexer.c:627
+#: src/language/lexer/lexer.c:636
msgid "expecting number"
msgstr ""
-#: src/language/lexer/lexer.c:639
+#: src/language/lexer/lexer.c:648
msgid "expecting identifier"
msgstr ""
-#: src/language/lexer/lexer.c:1028
+#: src/language/lexer/lexer.c:1037
msgid "binary"
msgstr ""
-#: src/language/lexer/lexer.c:1033
+#: src/language/lexer/lexer.c:1042
msgid "octal"
msgstr ""
-#: src/language/lexer/lexer.c:1038
+#: src/language/lexer/lexer.c:1047
msgid "hex"
msgstr ""
-#: src/language/lexer/lexer.c:1048
+#: src/language/lexer/lexer.c:1057
#, c-format
msgid "String of %s digits has %d characters, which is not a multiple of %d."
msgstr ""
-#: src/language/lexer/lexer.c:1077
+#: src/language/lexer/lexer.c:1086
#, c-format
msgid "`%c' is not a valid %s digit."
msgstr ""
-#: src/language/lexer/lexer.c:1111
+#: src/language/lexer/lexer.c:1120
msgid "Unterminated string constant."
msgstr ""
-#: src/language/lexer/lexer.c:1165
+#: src/language/lexer/lexer.c:1174
msgid "Unexpected end of file in string concatenation."
msgstr ""
-#: src/language/lexer/lexer.c:1173
+#: src/language/lexer/lexer.c:1182
msgid "String expected following `+'."
msgstr ""
-#: src/language/lexer/lexer.c:1186
+#: src/language/lexer/lexer.c:1195
#, c-format
msgid "String exceeds 255 characters in length (%d characters)."
msgstr ""
msgid "Closing `%s': %s."
msgstr ""
+#: src/language/tests/check-model.q:139
+msgid "PATH and SEARCH subcommands are mutually exclusive. Ignoring PATH."
+msgstr ""
+
+#: src/language/tests/check-model.q:157
+msgid "At least one value must be specified on PATH."
+msgstr ""
+
+#: src/language/tests/check-model.q:168
+#, c-format
+msgid "Hash bits adjusted to %d."
+msgstr ""
+
+#: src/language/tests/check-model.q:209
+#, c-format
+msgid "error opening \"%s\" for writing"
+msgstr ""
+
#: src/language/tests/float-format.c:126
#, c-format
msgid "%d-byte string needed but %d-byte string supplied."
msgid "Document entered %s by %s:"
msgstr ""
+#: src/language/utilities/title.c:184
+#, c-format
+msgid "(Entered %s)"
+msgstr ""
+
+#: src/language/utilities/title.c:195
+msgid "Document lines may not be more than 80 bytes long"
+msgstr ""
+
#: src/language/xforms/compute.c:147 src/language/xforms/compute.c:195
#, c-format
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2007-04-29 12:09+0800\n"
+"POT-Creation-Date: 2007-05-02 14:35+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "Error opening \"%s\" for writing as a system file: %s."
msgstr ""
-#: src/data/sys-file-writer.c:1104
+#: src/data/sys-file-writer.c:1101
#, c-format
msgid "An I/O error occurred writing system file \"%s\"."
msgstr ""
"s."
msgstr ""
-#: src/language/dictionary/value-labels.c:158 src/language/lexer/lexer.c:600
+#: src/language/dictionary/value-labels.c:158 src/language/lexer/lexer.c:609
msgid "expecting string"
msgstr ""
-#: src/language/dictionary/value-labels.c:167 src/language/lexer/lexer.c:614
+#: src/language/dictionary/value-labels.c:167 src/language/lexer/lexer.c:623
msgid "expecting integer"
msgstr ""
msgid "Syntax error at %s."
msgstr ""
-#: src/language/lexer/lexer.c:569 src/language/lexer/lexer.c:586
+#: src/language/lexer/lexer.c:578 src/language/lexer/lexer.c:595
#, c-format
msgid "expecting `%s'"
msgstr ""
-#: src/language/lexer/lexer.c:627
+#: src/language/lexer/lexer.c:636
msgid "expecting number"
msgstr ""
-#: src/language/lexer/lexer.c:639
+#: src/language/lexer/lexer.c:648
msgid "expecting identifier"
msgstr ""
-#: src/language/lexer/lexer.c:1028
+#: src/language/lexer/lexer.c:1037
msgid "binary"
msgstr ""
-#: src/language/lexer/lexer.c:1033
+#: src/language/lexer/lexer.c:1042
msgid "octal"
msgstr ""
-#: src/language/lexer/lexer.c:1038
+#: src/language/lexer/lexer.c:1047
msgid "hex"
msgstr ""
-#: src/language/lexer/lexer.c:1048
+#: src/language/lexer/lexer.c:1057
#, c-format
msgid "String of %s digits has %d characters, which is not a multiple of %d."
msgstr ""
-#: src/language/lexer/lexer.c:1077
+#: src/language/lexer/lexer.c:1086
#, c-format
msgid "`%c' is not a valid %s digit."
msgstr ""
-#: src/language/lexer/lexer.c:1111
+#: src/language/lexer/lexer.c:1120
msgid "Unterminated string constant."
msgstr ""
-#: src/language/lexer/lexer.c:1165
+#: src/language/lexer/lexer.c:1174
msgid "Unexpected end of file in string concatenation."
msgstr ""
-#: src/language/lexer/lexer.c:1173
+#: src/language/lexer/lexer.c:1182
msgid "String expected following `+'."
msgstr ""
-#: src/language/lexer/lexer.c:1186
+#: src/language/lexer/lexer.c:1195
#, c-format
msgid "String exceeds 255 characters in length (%d characters)."
msgstr ""
msgid "Closing `%s': %s."
msgstr ""
+#: src/language/tests/check-model.q:139
+msgid "PATH and SEARCH subcommands are mutually exclusive. Ignoring PATH."
+msgstr ""
+
+#: src/language/tests/check-model.q:157
+msgid "At least one value must be specified on PATH."
+msgstr ""
+
+#: src/language/tests/check-model.q:168
+#, c-format
+msgid "Hash bits adjusted to %d."
+msgstr ""
+
+#: src/language/tests/check-model.q:209
+#, c-format
+msgid "error opening \"%s\" for writing"
+msgstr ""
+
#: src/language/tests/float-format.c:126
#, c-format
msgid "%d-byte string needed but %d-byte string supplied."
msgid "Document entered %s by %s:"
msgstr ""
+#: src/language/utilities/title.c:184
+#, c-format
+msgid "(Entered %s)"
+msgstr ""
+
+#: src/language/utilities/title.c:195
+msgid "Document lines may not be more than 80 bytes long"
+msgstr ""
+
#: src/language/xforms/compute.c:147 src/language/xforms/compute.c:195
#, c-format
msgid ""
int32_t n_lines ; /* Number of lines of documents. */
} ATTRIBUTE((packed)) rec_6;
- const char *documents;
- size_t n_lines;
+ const char * documents = dict_get_documents (d);
+ size_t doc_bytes = strlen (documents);
- documents = dict_get_documents (d);
- n_lines = strlen (documents) / 80;
+ assert (doc_bytes % 80 == 0);
rec_6.rec_type = 6;
- rec_6.n_lines = n_lines;
+ rec_6.n_lines = doc_bytes / 80;
buf_write (w, &rec_6, sizeof rec_6);
- buf_write (w, documents, 80 * n_lines);
+ buf_write (w, documents, 80 * rec_6.n_lines);
}
/* Write the alignment, width and scale values */
/* Transformations and utilities that may appear after active
file definition or within INPUT PROGRAM. */
DEF_CMD (S_DATA | S_INPUT_PROGRAM, 0, "ADD VALUE LABELS", cmd_add_value_labels)
+DEF_CMD (S_DATA | S_INPUT_PROGRAM, 0, "ADD DOCUMENT", cmd_add_documents)
DEF_CMD (S_DATA | S_INPUT_PROGRAM, 0, "APPLY DICTIONARY", cmd_apply_dictionary)
DEF_CMD (S_DATA | S_INPUT_PROGRAM, 0, "BREAK", cmd_break)
DEF_CMD (S_DATA | S_INPUT_PROGRAM, 0, "COMPUTE", cmd_compute)
+2007-05-03 John Darrington <john@darrington.wattle.id.au>
+
+ * lexer.c lexer.h: Added lex_is_string function.
+
2007-04-15 Ben Pfaff <blp@gnu.org>
* q2c.c: Fully support lists of integer values. Add support for
return lexer->token == T_POS_NUM || lexer->token == T_NEG_NUM;
}
+
+/* Returns true if the current token is a string. */
+bool
+lex_is_string (struct lexer *lexer)
+{
+ return lexer->token == T_STRING;
+}
+
+
/* Returns the value of the current token, which must be a
floating point number. */
double
double lex_number (struct lexer *);
bool lex_is_integer (struct lexer *);
long lex_integer (struct lexer *);
+bool lex_is_string (struct lexer *);
+
/* Token matching functions. */
bool lex_match (struct lexer *, int);
+2007-05-03 John Darrington <john@darrington.wattle.ud.au>
+
+ * title.c: Implemented ADD DOCUMENT command.
+
Sun Nov 19 09:21:39 2006 Ben Pfaff <blp@gnu.org>
* set.q: Add RIB, RRB settings to control binary formats used by
/* PSPP - computes sample statistics.
- Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
return lex_end_of_command (lexer);
}
+
+
+/* Performs the ADD DOCUMENTS command. */
+int
+cmd_add_documents (struct lexer *lexer, struct dataset *ds)
+{
+ int i;
+ int n_lines = 0;
+ char buf[256];
+ struct string *lines = NULL;
+
+ sprintf (buf, _("(Entered %s)"), get_start_date ());
+
+ if ( ! lex_force_string (lexer) )
+ return CMD_FAILURE;
+
+ while ( lex_is_string (lexer))
+ {
+ const struct string *s = lex_tokstr (lexer);
+ if ( ds_length (s) > 80)
+ {
+ /* Note to translators: "bytes" is correct, not characters */
+ msg (SE, _("Document lines may not be more than 80 bytes long."));
+ goto failure;
+
+ }
+ lines = xrealloc (lines, (n_lines + 1) * sizeof (*lines));
+ ds_init_string (&lines[n_lines++], s);
+
+ lex_get (lexer);
+ }
+
+ for ( i = 0 ; i < n_lines ; ++i)
+ {
+ add_document_line (dataset_dict (ds), ds_cstr (&lines[i]), 0);
+ ds_destroy (&lines[i]);
+ }
+
+ free (lines);
+
+ add_document_line (dataset_dict (ds), buf, 3);
+
+ return lex_end_of_command (lexer) ;
+
+ failure:
+ for ( i = 0 ; i < n_lines ; ++i)
+ ds_destroy (&lines[i]);
+
+ free (lines);
+
+ return CMD_FAILURE;
+}
#!/bin/sh
-# This program tests the FILE LABEL and DOCUMENT commands
+# This program tests the FILE LABEL and DOCUMENT, and ADD DOCUMENT commands
TEMPDIR=/tmp/pspp-tst-$$
TESTFILE=$TEMPDIR/`basename $0`.sps
This is the second very long line of a document in an attempt to overflow the input buffer with a really long line
Note that the last line should end with a period: .
+
/* Display the documents.
display documents.
display file label.
+ADD DOCUMENT 'Line one' 'Line two'.
+
/* Save the active file then get it and display the documents again.
save /OUTFILE='foo.save'.
get /FILE='foo.save'.
# We need to filter out the dates/times
activity="date filter"
-grep -v 'Document entered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
+grep -v '[Ee]ntered' $TEMPDIR/pspp.list > $TEMPDIR/pspp.filtered
if [ $? -ne 0 ] ; then no_result ; fi
First line of a document
This is the second very long line of a document in an attempt to overflow the
Note that the last line should end with a period: .
+Line one
+Line two
File label:
This is a test file label
Documents in the active file:
First line of a document
This is the second very long line of a document in an attempt to overflow the
Note that the last line should end with a period: .
+Line one
+Line two
There should be another document now.
Documents in the active file:
First line of a document
This is the second very long line of a document in an attempt to overflow the
Note that the last line should end with a period: .
+Line one
+Line two
There should be another document now.
File label:
This is a test file label