X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fcontrol%2Frepeat.c;h=d7cc544fe6e8e001268b6c37643cacc91bce7daf;hb=638a86001fe7a237bd6c19a181d796305290d72a;hp=e518d51e112885bd3a7fae6d0537da5599bd10f8;hpb=9f087e7aa4cdff1d5d46d5e188c0017a9d2d0029;p=pspp diff --git a/src/language/control/repeat.c b/src/language/control/repeat.c index e518d51e11..d7cc544fe6 100644 --- a/src/language/control/repeat.c +++ b/src/language/control/repeat.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2007, 2009, 2010 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 published by @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -168,12 +169,12 @@ parse_specification (struct lexer *lexer, struct repeat_block *block) if (!lex_force_id (lexer)) return false; if (dict_lookup_var (dict, lex_tokid (lexer))) - msg (SW, _("Dummy variable name \"%s\" hides dictionary " - "variable \"%s\"."), + msg (SW, _("Dummy variable name `%s' hides dictionary " + "variable `%s'."), lex_tokid (lexer), lex_tokid (lexer)); if (find_macro (block, ss_cstr (lex_tokid (lexer)))) { - msg (SE, _("Dummy variable name \"%s\" is given twice."), + msg (SE, _("Dummy variable name `%s' is given twice."), lex_tokid (lexer)); return false; } @@ -194,7 +195,7 @@ parse_specification (struct lexer *lexer, struct repeat_block *block) count = parse_ids (lexer, dict, macro, block->pool); else if (lex_is_number (lexer)) count = parse_numbers (lexer, macro, block->pool); - else if (lex_token (lexer) == T_STRING) + else if (lex_is_string (lexer)) count = parse_strings (lexer, macro, block->pool); else { @@ -219,8 +220,8 @@ parse_specification (struct lexer *lexer, struct repeat_block *block) } else if (block->loop_cnt != count) { - msg (SE, _("Dummy variable \"%.*s\" had %d " - "substitutions, so \"%.*s\" must also, but %d " + msg (SE, _("Dummy variable `%.*s' had %d " + "substitutions, so `%.*s' must also, but %d " "were specified."), (int) ss_length (first_name), ss_data (first_name), block->loop_cnt, @@ -330,7 +331,7 @@ parse_lines (struct lexer *lexer, struct repeat_block *block) &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++; @@ -475,7 +476,7 @@ parse_strings (struct lexer *lexer, struct repeat_macro *macro, struct pool *poo { char *string; - if (lex_token (lexer) != T_STRING) + if (!lex_force_string (lexer)) { msg (SE, _("String expected.")); return 0; @@ -512,10 +513,10 @@ find_substitution (struct repeat_block *block, struct substring name) /* Makes appropriate DO REPEAT macro substitutions within the repeated lines. */ static void -do_repeat_filter (struct getl_interface *block_, - struct string *line) +do_repeat_filter (struct getl_interface *interface, struct string *line) { - struct repeat_block *block = (struct repeat_block *) block_; + struct repeat_block *block + = UP_CAST (interface, struct repeat_block, parent); bool in_apos, in_quote, dot; struct substring input; struct string output; @@ -525,8 +526,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) @@ -549,7 +549,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); @@ -558,7 +558,8 @@ do_repeat_filter (struct getl_interface *block_, static struct repeat_line * current_line (const struct getl_interface *interface) { - struct repeat_block *block = (struct repeat_block *) interface; + struct repeat_block *block + = UP_CAST (interface, struct repeat_block, parent); return (block->cur_line != ll_null (&block->lines) ? ll_data (block->cur_line, struct repeat_line, ll) : NULL); @@ -571,7 +572,8 @@ static bool do_repeat_read (struct getl_interface *interface, struct string *output) { - struct repeat_block *block = (struct repeat_block *) interface; + struct repeat_block *block + = UP_CAST (interface, struct repeat_block, parent); struct repeat_line *line; block->cur_line = ll_next (block->cur_line); @@ -592,9 +594,10 @@ do_repeat_read (struct getl_interface *interface, /* Frees a DO REPEAT block. Called by getl to close out the DO REPEAT block. */ static void -do_repeat_close (struct getl_interface *block_) +do_repeat_close (struct getl_interface *interface) { - struct repeat_block *block = (struct repeat_block *) block_; + struct repeat_block *block + = UP_CAST (interface, struct repeat_block, parent); pool_destroy (block->pool); } @@ -615,10 +618,10 @@ do_repeat_name (const struct getl_interface *interface) } /* Returns the line number in the source file from which the - previous line was originally obtained, or -1 if none. */ + previous line was originally obtained, or 0 if none. */ static int do_repeat_location (const struct getl_interface *interface) { struct repeat_line *line = current_line (interface); - return line ? line->line_number : -1; + return line ? line->line_number : 0; }