X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Futilities%2Ftitle.c;h=e7a463d10fde1b03690d4627486aae53a5fcd938;hb=fad7434e2db08ed248228e03533b314b8335ef2f;hp=62c86530fe362e450b70a677e4198bd7392f0465;hpb=b06c888cf2e8c126b04d4678120439533a5086e5;p=pspp-builds.git diff --git a/src/language/utilities/title.c b/src/language/utilities/title.c index 62c86530..e7a463d1 100644 --- a/src/language/utilities/title.c +++ b/src/language/utilities/title.c @@ -1,5 +1,5 @@ /* 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 @@ -174,3 +174,55 @@ cmd_drop_documents (struct lexer *lexer, struct dataset *ds) 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; +}