From 2d4dd90964061defa92972156ae2a12323708519 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 29 Nov 2006 11:50:31 +0000 Subject: [PATCH] Applying patch #5562 --- po/de.po | 112 ++++++++++++++--------------- po/pspp.pot | 112 ++++++++++++++--------------- src/language/ChangeLog | 9 +++ src/language/automake.mk | 6 +- src/language/command.c | 6 +- src/language/control/repeat.c | 69 ++++++++++++------ src/language/data-io/data-reader.c | 6 +- src/language/data-io/file-handle.q | 1 - src/language/lexer/lexer.c | 2 +- src/language/utilities/include.c | 24 ++++++- src/language/utilities/set.q | 8 +-- src/libpspp/ChangeLog | 8 +++ src/libpspp/automake.mk | 4 ++ src/libpspp/message.c | 11 ++- src/libpspp/message.h | 3 +- src/ui/flexifile.c | 1 + src/ui/gui/message-dialog.c | 12 +--- src/ui/gui/psppire.c | 6 +- src/ui/terminal/command-line.c | 12 ++-- src/ui/terminal/main.c | 6 +- src/ui/terminal/msg-ui.c | 8 ++- src/ui/terminal/read-line.c | 69 +++++++++++++++--- src/ui/terminal/read-line.h | 7 +- tests/bugs/get-no-file.sh | 2 +- 24 files changed, 314 insertions(+), 190 deletions(-) diff --git a/po/de.po b/po/de.po index db558a79..bd5717df 100644 --- a/po/de.po +++ b/po/de.po @@ -10,7 +10,7 @@ msgid "" msgstr "" "Project-Id-Version: PSPP 0.4.2\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-11-29 09:30+0800\n" +"POT-Creation-Date: 2006-11-29 18:57+0800\n" "PO-Revision-Date: 2006-05-26 17:49+0800\n" "Last-Translator: John Darrington \n" "Language-Team: German \n" @@ -1012,33 +1012,33 @@ msgstr "" msgid "This command may not follow ELSE in DO IF...END IF." msgstr "" -#: src/language/control/repeat.c:144 +#: src/language/control/repeat.c:156 #, c-format msgid "Dummy variable name \"%s\" hides dictionary variable \"%s\"." msgstr "" -#: src/language/control/repeat.c:150 +#: src/language/control/repeat.c:162 #, c-format msgid "Dummy variable name \"%s\" is given twice." msgstr "" -#: src/language/control/repeat.c:196 +#: src/language/control/repeat.c:209 #, c-format msgid "" "Dummy variable \"%s\" had %d substitutions, so \"%s\" must also, but %d were " "specified." msgstr "" -#: src/language/control/repeat.c:401 +#: src/language/control/repeat.c:415 #, c-format msgid "%ld TO %ld is an invalid range." msgstr "" -#: src/language/control/repeat.c:437 +#: src/language/control/repeat.c:451 msgid "String expected." msgstr "" -#: src/language/control/repeat.c:456 +#: src/language/control/repeat.c:470 msgid "No matching DO REPEAT." msgstr "" @@ -1184,44 +1184,44 @@ msgstr "" msgid "I/O error occurred writing data file \"%s\"." msgstr "" -#: src/language/data-io/file-handle.q:69 +#: src/language/data-io/file-handle.q:68 #, c-format msgid "" "File handle %s is already defined. Use CLOSE FILE HANDLE before redefining " "a file handle." msgstr "" -#: src/language/data-io/file-handle.q:101 +#: src/language/data-io/file-handle.q:100 #, c-format msgid "" "Fixed-length records were specified on /RECFORM, but record length was not " "specified on /LRECL. Assuming %d-character records." msgstr "" -#: src/language/data-io/file-handle.q:106 +#: src/language/data-io/file-handle.q:105 #, c-format msgid "" "Record length (%ld) must be at least one byte. Assuming %d-character " "records." msgstr "" -#: src/language/data-io/file-handle.q:152 +#: src/language/data-io/file-handle.q:151 msgid "file" msgstr "" -#: src/language/data-io/file-handle.q:154 +#: src/language/data-io/file-handle.q:153 msgid "inline file" msgstr "" -#: src/language/data-io/file-handle.q:156 +#: src/language/data-io/file-handle.q:155 msgid "scratch file" msgstr "" -#: src/language/data-io/file-handle.q:177 +#: src/language/data-io/file-handle.q:176 msgid "expecting a file name or handle name" msgstr "" -#: src/language/data-io/file-handle.q:204 +#: src/language/data-io/file-handle.q:203 #, c-format msgid "Handle for %s not allowed here." msgstr "" @@ -2159,8 +2159,8 @@ msgstr "" msgid "%s is a PSPP extension." msgstr "" -#: src/language/expressions/parse.c:1244 src/ui/terminal/command-line.c:131 -#: src/ui/terminal/command-line.c:150 src/ui/terminal/command-line.c:162 +#: src/language/expressions/parse.c:1244 src/ui/terminal/command-line.c:132 +#: src/ui/terminal/command-line.c:151 src/ui/terminal/command-line.c:163 #, c-format msgid "%s is not yet implemented." msgstr "" @@ -2356,31 +2356,6 @@ msgstr "" msgid "Bad bounds in use of TO convention." msgstr "" -#: src/language/line-buffer.c:251 -#, c-format -msgid "Can't find `%s' in include file search path." -msgstr "" - -#: src/language/line-buffer.c:335 -#, c-format -msgid "Closing `%s': %s." -msgstr "" - -#: src/language/line-buffer.c:446 -#, c-format -msgid "opening \"%s\" as syntax file" -msgstr "" - -#: src/language/line-buffer.c:451 -#, c-format -msgid "Opening `%s': %s." -msgstr "" - -#: src/language/line-buffer.c:464 -#, c-format -msgid "Reading `%s': %s." -msgstr "" - #: src/language/stats/aggregate.c:218 msgid "while expecting COLUMNWISE" msgstr "" @@ -3472,6 +3447,26 @@ msgstr "" msgid "%s & %s" msgstr "" +#: src/language/syntax-file.c:88 +#, c-format +msgid "opening \"%s\" as syntax file" +msgstr "" + +#: src/language/syntax-file.c:93 +#, c-format +msgid "Opening `%s': %s." +msgstr "" + +#: src/language/syntax-file.c:106 +#, c-format +msgid "Reading `%s': %s." +msgstr "" + +#: src/language/syntax-file.c:126 +#, c-format +msgid "Closing `%s': %s." +msgstr "" + #: src/language/tests/float-format.c:127 #, c-format msgid "%d-byte string needed but %d-byte string supplied." @@ -3500,10 +3495,15 @@ msgstr "" msgid "Only USE ALL is currently implemented." msgstr "" -#: src/language/utilities/include.c:43 +#: src/language/utilities/include.c:49 msgid "expecting file name" msgstr "" +#: src/language/utilities/include.c:65 +#, c-format +msgid "Can't find `%s' in include file search path." +msgstr "" + #: src/language/utilities/permissions.c:77 #, c-format msgid "Expecting %s or %s." @@ -4213,15 +4213,15 @@ msgstr "Speichern unter" msgid "Font Selection" msgstr "Schriftwahlung" -#: src/ui/gui/message-dialog.c:136 +#: src/ui/gui/message-dialog.c:128 msgid "Script Error" msgstr "Skript Fehler" -#: src/ui/gui/message-dialog.c:140 +#: src/ui/gui/message-dialog.c:132 msgid "Data File Error" msgstr "Datei Fehler" -#: src/ui/gui/message-dialog.c:145 +#: src/ui/gui/message-dialog.c:137 msgid "PSPP Error" msgstr "PSPP Fehler" @@ -4233,7 +4233,7 @@ msgstr "Unpassend Wert für Variable" msgid "Incorrect range specification" msgstr "Falshe Spannweitebeschreibung" -#: src/ui/gui/psppire.c:70 +#: src/ui/gui/psppire.c:71 msgid "Sorry. The help system hasn't yet been implemented." msgstr "Es gibt noch nicht kein Helpsysteme. Schade!" @@ -4596,7 +4596,7 @@ msgstr "Ordinalwert" msgid "Scale" msgstr "Skalwert" -#: src/ui/terminal/command-line.c:219 +#: src/ui/terminal/command-line.c:221 #, c-format msgid "" "PSPP, a program for statistical analysis of sample data.\n" @@ -4642,43 +4642,43 @@ msgid "" "\n" msgstr "" -#: src/ui/terminal/command-line.c:254 +#: src/ui/terminal/command-line.c:256 #, c-format msgid "" "\n" "Report bugs to <%s>.\n" msgstr "" -#: src/ui/terminal/main.c:117 +#: src/ui/terminal/main.c:120 msgid "" "Stopping syntax file processing here to avoid a cascade of dependent command " "failures." msgstr "" -#: src/ui/terminal/msg-ui.c:62 +#: src/ui/terminal/msg-ui.c:66 #, c-format msgid "Cannot open %s (%s). Writing errors to stdout instead.\n" msgstr "" -#: src/ui/terminal/msg-ui.c:89 +#: src/ui/terminal/msg-ui.c:93 msgid "Terminating execution of syntax file due to error." msgstr "" -#: src/ui/terminal/msg-ui.c:91 +#: src/ui/terminal/msg-ui.c:95 #, c-format msgid "Errors (%d) exceeds limit (%d)." msgstr "" -#: src/ui/terminal/msg-ui.c:94 +#: src/ui/terminal/msg-ui.c:98 #, c-format msgid "Warnings (%d) exceed limit (%d)." msgstr "" -#: src/ui/terminal/msg-ui.c:143 +#: src/ui/terminal/msg-ui.c:147 msgid "error" msgstr "Fehler" -#: src/ui/terminal/msg-ui.c:144 +#: src/ui/terminal/msg-ui.c:148 msgid "warning" msgstr "Warnung" diff --git a/po/pspp.pot b/po/pspp.pot index 46e9bc1a..fe72d407 100644 --- a/po/pspp.pot +++ b/po/pspp.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n" -"POT-Creation-Date: 2006-11-29 09:30+0800\n" +"POT-Creation-Date: 2006-11-29 18:57+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1011,33 +1011,33 @@ msgstr "" msgid "This command may not follow ELSE in DO IF...END IF." msgstr "" -#: src/language/control/repeat.c:144 +#: src/language/control/repeat.c:156 #, c-format msgid "Dummy variable name \"%s\" hides dictionary variable \"%s\"." msgstr "" -#: src/language/control/repeat.c:150 +#: src/language/control/repeat.c:162 #, c-format msgid "Dummy variable name \"%s\" is given twice." msgstr "" -#: src/language/control/repeat.c:196 +#: src/language/control/repeat.c:209 #, c-format msgid "" "Dummy variable \"%s\" had %d substitutions, so \"%s\" must also, but %d were " "specified." msgstr "" -#: src/language/control/repeat.c:401 +#: src/language/control/repeat.c:415 #, c-format msgid "%ld TO %ld is an invalid range." msgstr "" -#: src/language/control/repeat.c:437 +#: src/language/control/repeat.c:451 msgid "String expected." msgstr "" -#: src/language/control/repeat.c:456 +#: src/language/control/repeat.c:470 msgid "No matching DO REPEAT." msgstr "" @@ -1183,44 +1183,44 @@ msgstr "" msgid "I/O error occurred writing data file \"%s\"." msgstr "" -#: src/language/data-io/file-handle.q:69 +#: src/language/data-io/file-handle.q:68 #, c-format msgid "" "File handle %s is already defined. Use CLOSE FILE HANDLE before redefining " "a file handle." msgstr "" -#: src/language/data-io/file-handle.q:101 +#: src/language/data-io/file-handle.q:100 #, c-format msgid "" "Fixed-length records were specified on /RECFORM, but record length was not " "specified on /LRECL. Assuming %d-character records." msgstr "" -#: src/language/data-io/file-handle.q:106 +#: src/language/data-io/file-handle.q:105 #, c-format msgid "" "Record length (%ld) must be at least one byte. Assuming %d-character " "records." msgstr "" -#: src/language/data-io/file-handle.q:152 +#: src/language/data-io/file-handle.q:151 msgid "file" msgstr "" -#: src/language/data-io/file-handle.q:154 +#: src/language/data-io/file-handle.q:153 msgid "inline file" msgstr "" -#: src/language/data-io/file-handle.q:156 +#: src/language/data-io/file-handle.q:155 msgid "scratch file" msgstr "" -#: src/language/data-io/file-handle.q:177 +#: src/language/data-io/file-handle.q:176 msgid "expecting a file name or handle name" msgstr "" -#: src/language/data-io/file-handle.q:204 +#: src/language/data-io/file-handle.q:203 #, c-format msgid "Handle for %s not allowed here." msgstr "" @@ -2158,8 +2158,8 @@ msgstr "" msgid "%s is a PSPP extension." msgstr "" -#: src/language/expressions/parse.c:1244 src/ui/terminal/command-line.c:131 -#: src/ui/terminal/command-line.c:150 src/ui/terminal/command-line.c:162 +#: src/language/expressions/parse.c:1244 src/ui/terminal/command-line.c:132 +#: src/ui/terminal/command-line.c:151 src/ui/terminal/command-line.c:163 #, c-format msgid "%s is not yet implemented." msgstr "" @@ -2355,31 +2355,6 @@ msgstr "" msgid "Bad bounds in use of TO convention." msgstr "" -#: src/language/line-buffer.c:251 -#, c-format -msgid "Can't find `%s' in include file search path." -msgstr "" - -#: src/language/line-buffer.c:335 -#, c-format -msgid "Closing `%s': %s." -msgstr "" - -#: src/language/line-buffer.c:446 -#, c-format -msgid "opening \"%s\" as syntax file" -msgstr "" - -#: src/language/line-buffer.c:451 -#, c-format -msgid "Opening `%s': %s." -msgstr "" - -#: src/language/line-buffer.c:464 -#, c-format -msgid "Reading `%s': %s." -msgstr "" - #: src/language/stats/aggregate.c:218 msgid "while expecting COLUMNWISE" msgstr "" @@ -3471,6 +3446,26 @@ msgstr "" msgid "%s & %s" msgstr "" +#: src/language/syntax-file.c:88 +#, c-format +msgid "opening \"%s\" as syntax file" +msgstr "" + +#: src/language/syntax-file.c:93 +#, c-format +msgid "Opening `%s': %s." +msgstr "" + +#: src/language/syntax-file.c:106 +#, c-format +msgid "Reading `%s': %s." +msgstr "" + +#: src/language/syntax-file.c:126 +#, c-format +msgid "Closing `%s': %s." +msgstr "" + #: src/language/tests/float-format.c:127 #, c-format msgid "%d-byte string needed but %d-byte string supplied." @@ -3499,10 +3494,15 @@ msgstr "" msgid "Only USE ALL is currently implemented." msgstr "" -#: src/language/utilities/include.c:43 +#: src/language/utilities/include.c:49 msgid "expecting file name" msgstr "" +#: src/language/utilities/include.c:65 +#, c-format +msgid "Can't find `%s' in include file search path." +msgstr "" + #: src/language/utilities/permissions.c:77 #, c-format msgid "Expecting %s or %s." @@ -4212,15 +4212,15 @@ msgstr "" msgid "Font Selection" msgstr "" -#: src/ui/gui/message-dialog.c:136 +#: src/ui/gui/message-dialog.c:128 msgid "Script Error" msgstr "" -#: src/ui/gui/message-dialog.c:140 +#: src/ui/gui/message-dialog.c:132 msgid "Data File Error" msgstr "" -#: src/ui/gui/message-dialog.c:145 +#: src/ui/gui/message-dialog.c:137 msgid "PSPP Error" msgstr "" @@ -4232,7 +4232,7 @@ msgstr "" msgid "Incorrect range specification" msgstr "" -#: src/ui/gui/psppire.c:70 +#: src/ui/gui/psppire.c:71 msgid "Sorry. The help system hasn't yet been implemented." msgstr "" @@ -4587,7 +4587,7 @@ msgstr "" msgid "Scale" msgstr "" -#: src/ui/terminal/command-line.c:219 +#: src/ui/terminal/command-line.c:221 #, c-format msgid "" "PSPP, a program for statistical analysis of sample data.\n" @@ -4633,42 +4633,42 @@ msgid "" "\n" msgstr "" -#: src/ui/terminal/command-line.c:254 +#: src/ui/terminal/command-line.c:256 #, c-format msgid "" "\n" "Report bugs to <%s>.\n" msgstr "" -#: src/ui/terminal/main.c:117 +#: src/ui/terminal/main.c:120 msgid "" "Stopping syntax file processing here to avoid a cascade of dependent command " "failures." msgstr "" -#: src/ui/terminal/msg-ui.c:62 +#: src/ui/terminal/msg-ui.c:66 #, c-format msgid "Cannot open %s (%s). Writing errors to stdout instead.\n" msgstr "" -#: src/ui/terminal/msg-ui.c:89 +#: src/ui/terminal/msg-ui.c:93 msgid "Terminating execution of syntax file due to error." msgstr "" -#: src/ui/terminal/msg-ui.c:91 +#: src/ui/terminal/msg-ui.c:95 #, c-format msgid "Errors (%d) exceeds limit (%d)." msgstr "" -#: src/ui/terminal/msg-ui.c:94 +#: src/ui/terminal/msg-ui.c:98 #, c-format msgid "Warnings (%d) exceed limit (%d)." msgstr "" -#: src/ui/terminal/msg-ui.c:143 +#: src/ui/terminal/msg-ui.c:147 msgid "error" msgstr "" -#: src/ui/terminal/msg-ui.c:144 +#: src/ui/terminal/msg-ui.c:148 msgid "warning" msgstr "" diff --git a/src/language/ChangeLog b/src/language/ChangeLog index d645127f..45df782c 100644 --- a/src/language/ChangeLog +++ b/src/language/ChangeLog @@ -1,3 +1,12 @@ +Wed Nov 29 19:35:44 WST 2006 John Darrington + + * command.c: Updated to reflect changed function names. + + * line-buffer.c line-buffer.h: Removed. Guts of it moved to + libpspp/getl.[ch] The rest moved to files listed below. + + * syntax-file.c syntax-file.h prompt.c prompt.h: New files. + Wed Nov 22 06:26:42 2006 Ben Pfaff * command.def: HOST command needs F_KEEP_FINAL_TOKEN. diff --git a/src/language/automake.mk b/src/language/automake.mk index e1aed86a..6e53fbf3 100644 --- a/src/language/automake.mk +++ b/src/language/automake.mk @@ -13,8 +13,10 @@ include $(top_srcdir)/src/language/expressions/automake.mk noinst_LIBRARIES += src/language/liblanguage.a src_language_liblanguage_a_SOURCES = \ - src/language/line-buffer.c \ - src/language/line-buffer.h \ + src/language/syntax-file.c \ + src/language/syntax-file.h \ + src/language/prompt.c \ + src/language/prompt.h \ src/language/command.c \ src/language/command.h \ src/language/command.def diff --git a/src/language/command.c b/src/language/command.c index cfae2ba0..032e4d7f 100644 --- a/src/language/command.c +++ b/src/language/command.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -162,7 +162,7 @@ do_parse_command (struct lexer *lexer, struct dataset *ds, enum cmd_state state) enum cmd_result result; /* Read the command's first token. */ - getl_set_prompt_style (GETL_PROMPT_FIRST); + prompt_set_style (PROMPT_FIRST); set_completion_state (state); lex_get (lexer); if (lex_token (lexer) == T_STOP) @@ -172,7 +172,7 @@ do_parse_command (struct lexer *lexer, struct dataset *ds, enum cmd_state state) /* Null commands can result from extra empty lines. */ return CMD_SUCCESS; } - getl_set_prompt_style (GETL_PROMPT_LATER); + prompt_set_style (PROMPT_LATER); /* Parse the command name. */ command = parse_command_name (lexer); diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c index 384ac775..45e95829 100644 --- a/src/language/control/repeat.c +++ b/src/language/control/repeat.c @@ -28,13 +28,12 @@ #include #include #include +#include #include #include #include -#include #include #include -#include #include #include #include @@ -73,6 +72,8 @@ struct repeat_entry /* A DO REPEAT...END REPEAT block. */ struct repeat_block { + struct getl_interface parent ; + struct pool *pool; /* Pool used for storage. */ struct dataset *ds; /* The dataset for this block */ struct line_list *first_line; /* First line in line buffer. */ @@ -87,14 +88,20 @@ static bool parse_specification (struct lexer *, struct repeat_block *); static bool parse_lines (struct lexer *, struct repeat_block *); static void create_vars (struct repeat_block *); -static int parse_ids (struct lexer *, const struct dictionary *dict, struct repeat_entry *, struct pool *); -static int parse_numbers (struct lexer *, struct repeat_entry *, struct pool *); -static int parse_strings (struct lexer *, struct repeat_entry *, struct pool *); +static int parse_ids (struct lexer *, const struct dictionary *dict, + struct repeat_entry *, struct pool *); + +static int parse_numbers (struct lexer *, struct repeat_entry *, + struct pool *); + +static int parse_strings (struct lexer *, struct repeat_entry *, + struct pool *); + +static void do_repeat_filter (struct getl_interface *, struct string *); +static bool do_repeat_read (struct getl_interface *, struct string *); +static void do_repeat_close (struct getl_interface *); +static bool always_false (const struct getl_interface *i UNUSED); -static void do_repeat_filter (struct string *line, void *block); -static bool do_repeat_read (struct string *line, char **file_name, - int *line_number, void *block); -static void do_repeat_close (void *block); int cmd_do_repeat (struct lexer *lexer, struct dataset *ds) @@ -111,8 +118,13 @@ cmd_do_repeat (struct lexer *lexer, struct dataset *ds) block->cur_line = NULL; block->loop_idx = -1; - getl_include_filter (do_repeat_filter, do_repeat_close, block); - getl_include_function (do_repeat_read, NULL, block); + + block->parent.read = do_repeat_read; + block->parent.close = do_repeat_close; + block->parent.filter = do_repeat_filter; + block->parent.interactive = always_false; + + getl_include_source ( (struct getl_interface *) block); return CMD_SUCCESS; @@ -147,7 +159,8 @@ parse_specification (struct lexer *lexer, struct repeat_block *block) for (iter = block->macros; iter != NULL; iter = iter->next) if (!strcasecmp (iter->id, lex_tokid (lexer))) { - msg (SE, _("Dummy variable name \"%s\" is given twice."), lex_tokid (lexer)); + msg (SE, _("Dummy variable name \"%s\" is given twice."), + lex_tokid (lexer)); return false; } @@ -278,8 +291,8 @@ parse_lines (struct lexer *lexer, struct repeat_block *block) for (;;) { - const char *cur_file_name; - int cur_line_number; + const char *cur_file_name = getl_source_name (); + int cur_line_number = getl_source_location (); struct line_list *line; struct string cur_line_copy; bool dot; @@ -288,9 +301,10 @@ parse_lines (struct lexer *lexer, struct repeat_block *block) return false; /* If the current file has changed then record the fact. */ - getl_location (&cur_file_name, &cur_line_number); - if (previous_file_name == NULL + if (cur_file_name && + (previous_file_name == NULL || !strcmp (cur_file_name, previous_file_name)) + ) previous_file_name = pool_strdup (block->pool, cur_file_name); ds_init_string (&cur_line_copy, lex_entire_line_ds (lexer) ); @@ -474,9 +488,9 @@ find_substitution (struct repeat_block *block, const char *name, size_t length) /* Makes appropriate DO REPEAT macro substitutions within the repeated lines. */ static void -do_repeat_filter (struct string *line, void *block_) +do_repeat_filter (struct getl_interface *block_, struct string *line) { - struct repeat_block *block = block_; + struct repeat_block *block = (struct repeat_block *) block_; bool in_apos, in_quote; char *cp; struct string output; @@ -523,11 +537,15 @@ do_repeat_filter (struct string *line, void *block_) Puts the line in OUTPUT, sets the file name in *FILE_NAME and line number in *LINE_NUMBER. Returns true if a line was obtained, false if the source is exhausted. */ +#if 0 static bool do_repeat_read (struct string *output, char **file_name, int *line_number, void *block_) +#endif +static bool +do_repeat_read (struct getl_interface *b, struct string *output) { - struct repeat_block *block = block_; + struct repeat_block *block = (struct repeat_block *) b; struct line_list *line; if (block->cur_line == NULL) @@ -540,8 +558,10 @@ do_repeat_read (struct string *output, char **file_name, int *line_number, line = block->cur_line; ds_assign_cstr (output, line->line); +#if 0 *file_name = line->file_name; *line_number = -line->line_number; +#endif block->cur_line = line->next; return true; } @@ -549,8 +569,15 @@ do_repeat_read (struct string *output, char **file_name, int *line_number, /* Frees a DO REPEAT block. Called by getl to close out the DO REPEAT block. */ static void -do_repeat_close (void *block_) +do_repeat_close (struct getl_interface *block_) { - struct repeat_block *block = block_; + struct repeat_block *block = (struct repeat_block *) block_; pool_destroy (block->pool); } + + +static bool +always_false (const struct getl_interface *i UNUSED) +{ + return false; +} diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index cd065ddb..49ec7789 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include @@ -169,7 +169,7 @@ read_inline_record (struct dfm_reader *r) lex_get (r->lexer); if (!lex_force_match_id (r->lexer, "BEGIN") || !lex_force_match_id (r->lexer, "DATA")) return false; - getl_set_prompt_style (GETL_PROMPT_DATA); + prompt_set_style (PROMPT_DATA); } if (!lex_get_line_raw (r->lexer)) @@ -444,7 +444,7 @@ cmd_begin_data (struct lexer *lexer, struct dataset *ds) r->flags |= DFM_SAW_BEGIN_DATA; /* Input procedure reads from inline file. */ - getl_set_prompt_style (GETL_PROMPT_DATA); + prompt_set_style (PROMPT_DATA); ok = procedure (ds, NULL, NULL); dfm_close_reader (r); diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index 31039a35..ada87f95 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/src/language/lexer/lexer.c b/src/language/lexer/lexer.c index b6e5fc4e..9c6063fd 100644 --- a/src/language/lexer/lexer.c +++ b/src/language/lexer/lexer.c @@ -30,9 +30,9 @@ #include #include #include -#include #include #include +#include #include #include "size_max.h" diff --git a/src/language/utilities/include.c b/src/language/utilities/include.c index 3e9a5b7b..c812c972 100644 --- a/src/language/utilities/include.c +++ b/src/language/utilities/include.c @@ -23,9 +23,12 @@ #include #include #include -#include +#include +#include #include #include +#include + #include "gettext.h" #define _(msgid) gettext (msgid) @@ -33,6 +36,9 @@ int cmd_include (struct lexer *lexer, struct dataset *ds UNUSED) { + char *found_fn; + char *target_fn; + /* Skip optional FILE=. */ if (lex_match_id (lexer, "FILE")) lex_match (lexer, '='); @@ -43,7 +49,21 @@ cmd_include (struct lexer *lexer, struct dataset *ds UNUSED) lex_error (lexer, _("expecting file name")); return CMD_CASCADING_FAILURE; } - getl_include_syntax_file (ds_cstr (lex_tokstr (lexer))); + + target_fn = ds_cstr (lex_tokstr (lexer)); + + found_fn = fn_search_path (target_fn, + getl_include_path (), + NULL); + + if (found_fn != NULL) + { + getl_include_source (create_syntax_file_source (found_fn)); + free (found_fn); + } + else + msg (SE, _("Can't find `%s' in include file search path."), + target_fn); lex_get (lexer); return lex_end_of_command (lexer); diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index 8a79b194..d6252cf4 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -152,11 +152,11 @@ cmd_set (struct lexer *lexer, struct dataset *ds) do_cc (cmd.s_cce, FMT_CCE); if (cmd.sbc_prompt) - getl_set_prompt (GETL_PROMPT_FIRST, cmd.s_prompt); + prompt_set (PROMPT_FIRST, cmd.s_prompt); if (cmd.sbc_cprompt) - getl_set_prompt (GETL_PROMPT_LATER, cmd.s_cprompt); + prompt_set (PROMPT_LATER, cmd.s_cprompt); if (cmd.sbc_dprompt) - getl_set_prompt (GETL_PROMPT_DATA, cmd.s_dprompt); + prompt_set (PROMPT_DATA, cmd.s_dprompt); if (cmd.sbc_decimal) fmt_set_decimal (cmd.dec == STC_DOT ? '.' : ','); diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index 85ab3204..6e09dfb2 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,11 @@ +Wed Nov 29 19:35:44 WST 2006 John Darrington + + * getl.c getl.h: New files. Created interface from base of + language/line-buffer.[ch] + + * msg-locator.c msg-locator.h: New files. Moved from + language/line-buffer.[ch] + Fri Nov 24 17:27:00 2006 Ben Pfaff * misc.h: (min) Removed. All references updated to use MIN, from diff --git a/src/libpspp/automake.mk b/src/libpspp/automake.mk index da01e2d5..305a7c21 100644 --- a/src/libpspp/automake.mk +++ b/src/libpspp/automake.mk @@ -19,12 +19,16 @@ src_libpspp_libpspp_a_SOURCES = \ src/libpspp/float-format.h \ src/libpspp/freaderror.c \ src/libpspp/freaderror.h \ + src/libpspp/getl.h \ + src/libpspp/getl.c \ src/libpspp/hash.c \ src/libpspp/hash.h \ src/libpspp/i18n.c \ src/libpspp/i18n.h \ src/libpspp/integer-format.c \ src/libpspp/integer-format.h \ + src/libpspp/msg-locator.c \ + src/libpspp/msg-locator.h \ src/libpspp/ll.c \ src/libpspp/ll.h \ src/libpspp/llx.c \ diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 1a4601fc..24bb8e87 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -19,7 +19,8 @@ #include -#include +#include "message.h" +#include "msg-locator.h" #include #include @@ -39,8 +40,6 @@ static char *command_name; /* Message handler as set by msg_init(). */ static void (*msg_handler) (const struct msg *); -static void (*msg_location) (struct msg_locator *); - /* Disables emitting messages if positive. */ static int messages_disabled; @@ -65,11 +64,9 @@ msg (enum msg_class class, const char *format, ...) } void -msg_init ( void (*handler) (const struct msg *), - void (*location) (struct msg_locator *) ) +msg_init ( void (*handler) (const struct msg *) ) { msg_handler = handler; - msg_location = location; } void @@ -102,7 +99,7 @@ msg_destroy(struct msg *m) void msg_emit (struct msg *m) { - msg_location (&m->where); + get_msg_location (&m->where); if (!messages_disabled) msg_handler (m); free (m->text); diff --git a/src/libpspp/message.h b/src/libpspp/message.h index e345ea65..ffafd999 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -86,8 +86,7 @@ struct msg }; /* Initialization. */ -void msg_init ( void (*handler) (const struct msg *), - void (*location) (struct msg_locator *) ) ; +void msg_init ( void (*handler) (const struct msg *) ); void msg_done (void); diff --git a/src/ui/flexifile.c b/src/ui/flexifile.c index 5d06f876..9ab6cb98 100644 --- a/src/ui/flexifile.c +++ b/src/ui/flexifile.c @@ -22,6 +22,7 @@ #include #include #include "flexifile.h" +#include #include #include #include diff --git a/src/ui/gui/message-dialog.c b/src/ui/gui/message-dialog.c index af1886c9..77876b0f 100644 --- a/src/ui/gui/message-dialog.c +++ b/src/ui/gui/message-dialog.c @@ -29,6 +29,7 @@ #define N_(msgid) msgid #include +#include #include "message-dialog.h" #include "progname.h" @@ -49,22 +50,13 @@ static void enqueue_msg (const struct msg *m); static GQueue *message_queue; -static void -msg_location (struct msg_locator *loc) -{ - loc->file_name = NULL; - loc->line_number = -1; -} - - void message_dialog_init (void) { message_queue = g_queue_new(); - msg_init (enqueue_msg, msg_location); + msg_init (enqueue_msg); } - void message_dialog_done (void) { diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 8ae97f15..6dd41b34 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -113,11 +114,9 @@ main(int argc, char *argv[]) glade_init(); - - fmt_init(); settings_init(); - + getl_initialize (); message_dialog_init(); the_dictionary = psppire_dict_new(); @@ -169,6 +168,7 @@ main(int argc, char *argv[]) /* start the event loop */ gtk_main(); + getl_uninitialize (); message_dialog_done(); settings_done(); diff --git a/src/ui/terminal/command-line.c b/src/ui/terminal/command-line.c index 54e4a7c2..f7090a3e 100644 --- a/src/ui/terminal/command-line.c +++ b/src/ui/terminal/command-line.c @@ -30,15 +30,16 @@ #include #include #include -#include +#include #include "progname.h" #include -#include "read-line.h" #include #include +#include #include #include #include +#include "read-line.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -194,7 +195,8 @@ parse_command_line (int argc, char **argv) char *pspprc_fn = fn_search_path ("rc", config_path, NULL); if (pspprc_fn != NULL) { - getl_append_syntax_file (pspprc_fn); + getl_append_source (create_syntax_file_source (pspprc_fn)); + free (pspprc_fn); } } @@ -204,12 +206,12 @@ parse_command_line (int argc, char **argv) outp_configure_macro (argv[i]); else { - getl_append_syntax_file (argv[i]); + getl_append_source (create_syntax_file_source (argv[i])); syntax_files++; } if (!syntax_files || interactive_mode) - getl_append_interactive (readln_read); + getl_append_source (create_readln_source () ); return true; } diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 5e9a605b..5b4ad2d3 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -28,8 +28,10 @@ #include "progname.h" #include "read-line.h" + #include #include +#include #include #include #include @@ -38,7 +40,7 @@ #include #include #include -#include +#include #include #include #include @@ -94,6 +96,7 @@ main (int argc, char **argv) fn_init (); fh_init (); getl_initialize (); + prompt_init (); readln_initialize (); settings_init (); random_init (); @@ -194,6 +197,7 @@ terminate (bool success) fh_done (); lex_destroy (the_lexer); getl_uninitialize (); + prompt_done (); readln_uninitialize (); outp_done (); diff --git a/src/ui/terminal/msg-ui.c b/src/ui/terminal/msg-ui.c index ddd927c5..7cb652c0 100644 --- a/src/ui/terminal/msg-ui.c +++ b/src/ui/terminal/msg-ui.c @@ -24,10 +24,14 @@ #include "exit.h" #include "linebreak.h" -#include +#include +#include #include #include +#include #include +#include + #include "gettext.h" #define _(msgid) gettext (msgid) @@ -65,7 +69,7 @@ msg_ui_init (void) msg_file = stdout; } } - msg_init (handle_msg, get_msg_location); + msg_init (handle_msg); } void diff --git a/src/ui/terminal/read-line.c b/src/ui/terminal/read-line.c index 46b53b70..97427c6c 100644 --- a/src/ui/terminal/read-line.c +++ b/src/ui/terminal/read-line.c @@ -28,14 +28,13 @@ #include "msg-ui.h" -#include #include #include #include #include #include #include -#include +#include #include "xalloc.h" @@ -52,6 +51,16 @@ static char **complete_command_name (const char *, int, int); static char **dont_complete (const char *, int, int); #endif /* HAVE_READLINE */ + +struct readln_source +{ + struct getl_interface parent ; + + bool (*interactive_func) (struct string *line, + enum prompt_style) ; +}; + + static bool initialised = false; /* Initialize getl. */ @@ -81,13 +90,29 @@ readln_uninitialize (void) initialised = false; #if HAVE_READLINE && unix - if (history_file != NULL) + if (history_file != NULL && false == get_testing_mode() ) write_history (history_file); clear_history (); free (history_file); #endif } + +static bool +read_interactive (struct getl_interface *s, struct string *line) +{ + struct readln_source *is = + (struct readln_source *) s ; + + return is->interactive_func (line, prompt_get_style ()); +} + +static bool +always_true (const struct getl_interface *s UNUSED) +{ + return true; +} + /* Display a welcoming message. */ static void welcome (void) @@ -113,14 +138,19 @@ welcome (void) #endif } + + + + + /* Gets a line from the user and stores it into LINE. Prompts the user with PROMPT. Returns true if successful, false at end of file. - Suitable for passing to getl_append_interactive(). */ -bool -readln_read (struct string *line, enum getl_prompt_style style) + */ +static bool +readln_read (struct string *line, enum prompt_style style) { - const char *prompt = getl_get_prompt (style); + const char *prompt = prompt_get (style); #if HAVE_READLINE char *string; #endif @@ -132,7 +162,7 @@ readln_read (struct string *line, enum getl_prompt_style style) welcome (); #if HAVE_READLINE - rl_attempted_completion_function = (style == GETL_PROMPT_FIRST + rl_attempted_completion_function = (style == PROMPT_FIRST ? complete_command_name : dont_complete); string = readline (prompt); @@ -159,6 +189,29 @@ readln_read (struct string *line, enum getl_prompt_style style) #endif } + +static void +readln_close (struct getl_interface *i) +{ + free (i); +} + +/* Creates a source which uses readln to get its line */ +struct getl_interface * +create_readln_source (void) +{ + struct readln_source *rlns = xzalloc (sizeof (*rlns)); + + rlns->interactive_func = readln_read; + + rlns->parent.interactive = always_true; + rlns->parent.read = read_interactive; + rlns->parent.close = readln_close; + + return (struct getl_interface *) rlns; +} + + #if HAVE_READLINE static char *command_generator (const char *text, int state); diff --git a/src/ui/terminal/read-line.h b/src/ui/terminal/read-line.h index 9d490fc9..1133f648 100644 --- a/src/ui/terminal/read-line.h +++ b/src/ui/terminal/read-line.h @@ -21,11 +21,14 @@ #define READLN_H #include -#include +#include void readln_initialize (void); void readln_uninitialize (void); -bool readln_read (struct string *line, enum getl_prompt_style); + +struct getl_interface *create_readln_source (void); + + #endif /* READLN_H */ diff --git a/tests/bugs/get-no-file.sh b/tests/bugs/get-no-file.sh index 56bb153a..45b68827 100755 --- a/tests/bugs/get-no-file.sh +++ b/tests/bugs/get-no-file.sh @@ -64,7 +64,7 @@ if [ $? -ne 0 ] ; then no_result ; fi # We use the stdinput here, because the bug seems to manifest itself only in # interactive mode. activity="run program" -cat $TESTFILE | $SUPERVISOR $PSPP -o raw-ascii > /dev/null +cat $TESTFILE | $SUPERVISOR $PSPP --testing-mode -o raw-ascii > /dev/null if [ $? -ne 0 ] ; then fail ; fi pass -- 2.30.2