X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fcontrol%2Frepeat.c;h=32847bb4a9298bd100f0cb80e8489097adc7d8ca;hb=ed7039fafdba4e2f72ad6e4192197fc938c6d2b0;hp=ede37016ee816a05820c6e97a97ff0bbe873ec43;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c index ede37016..32847bb4 100644 --- a/src/language/control/repeat.c +++ b/src/language/control/repeat.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -38,6 +37,7 @@ #include #include "intprops.h" +#include "xalloc.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -49,7 +49,6 @@ struct repeat_line const char *file_name; /* File name. */ int line_number; /* Line number. */ struct substring text; /* Contents. */ - enum getl_syntax syntax; /* Syntax mode. */ }; /* The type of substitution made for a DO REPEAT macro. */ @@ -103,9 +102,9 @@ static int parse_strings (struct lexer *, struct repeat_macro *, struct pool *); static void do_repeat_filter (struct getl_interface *, - struct string *, enum getl_syntax); + struct string *); static bool do_repeat_read (struct getl_interface *, - struct string *, enum getl_syntax *); + struct string *); static void do_repeat_close (struct getl_interface *); static bool always_false (const struct getl_interface *); static const char *do_repeat_name (const struct getl_interface *); @@ -136,7 +135,11 @@ cmd_do_repeat (struct lexer *lexer, struct dataset *ds) block->parent.location = do_repeat_location; if (!ll_is_empty (&block->lines)) - getl_include_source (lex_get_source_stream (lexer), &block->parent); + getl_include_source (lex_get_source_stream (lexer), + &block->parent, + lex_current_syntax_mode (lexer), + lex_current_error_mode (lexer) + ); else pool_destroy (block->pool); @@ -298,11 +301,10 @@ parse_lines (struct lexer *lexer, struct repeat_block *block) const char *cur_file_name; struct repeat_line *line; struct string text; - enum getl_syntax syntax; bool command_ends_before_line, command_ends_after_line; /* Retrieve an input line and make a copy of it. */ - if (!lex_get_line_raw (lexer, &syntax)) + if (!lex_get_line_raw (lexer)) return false; ds_init_string (&text, lex_entire_line_ds (lexer)); @@ -318,16 +320,17 @@ parse_lines (struct lexer *lexer, struct repeat_block *block) line->file_name = previous_file_name; line->line_number = getl_source_location (lex_get_source_stream (lexer)); ss_alloc_substring_pool (&line->text, ds_ss (&text), block->pool); - line->syntax = syntax; + /* Check whether the line contains a DO REPEAT or END REPEAT command. */ - lex_preprocess_line (&text, syntax, + lex_preprocess_line (&text, + lex_current_syntax_mode (lexer), &command_ends_before_line, &command_ends_after_line); if (recognize_do_repeat (ds_ss (&text))) { - if (get_syntax () == COMPATIBLE) + if (settings_get_syntax () == COMPATIBLE) msg (SE, _("DO REPEAT may not nest in compatibility mode.")); else nesting_level++; @@ -510,7 +513,7 @@ find_substitution (struct repeat_block *block, struct substring name) repeated lines. */ static void do_repeat_filter (struct getl_interface *block_, - struct string *line, enum getl_syntax syntax UNUSED) + struct string *line) { struct repeat_block *block = (struct repeat_block *) block_; bool in_apos, in_quote, dot; @@ -522,8 +525,7 @@ do_repeat_filter (struct getl_interface *block_, /* Strip trailing whitespace, check for & remove terminal dot. */ ds_rtrim (line, ss_cstr (CC_SPACES)); - dot = ds_chomp (line, get_endcmd ()); - + dot = ds_chomp (line, settings_get_endcmd ()); input = ds_ss (line); in_apos = in_quote = false; while ((c = ss_first (input)) != EOF) @@ -546,7 +548,7 @@ do_repeat_filter (struct getl_interface *block_, } } if (dot) - ds_put_char (&output, get_endcmd ()); + ds_put_char (&output, settings_get_endcmd ()); ds_swap (line, &output); ds_destroy (&output); @@ -566,7 +568,7 @@ current_line (const struct getl_interface *interface) was obtained, false if the source is exhausted. */ static bool do_repeat_read (struct getl_interface *interface, - struct string *output, enum getl_syntax *syntax) + struct string *output) { struct repeat_block *block = (struct repeat_block *) interface; struct repeat_line *line; @@ -583,7 +585,6 @@ do_repeat_read (struct getl_interface *interface, line = current_line (interface); ds_assign_substring (output, line->text); - *syntax = line->syntax; return true; }