/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007, 2009 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
/* Get a stand-in variable name and make sure it's unique. */
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'."),
- lex_tokid (lexer), lex_tokid (lexer));
- if (find_macro (block, ss_cstr (lex_tokid (lexer))))
+ if (dict_lookup_var (dict, lex_tokcstr (lexer)))
+ msg (SW, _("Dummy variable name `%s' hides dictionary variable `%s'."),
+ lex_tokcstr (lexer), lex_tokcstr (lexer));
+ if (find_macro (block, lex_tokss (lexer)))
{
msg (SE, _("Dummy variable name `%s' is given twice."),
- lex_tokid (lexer));
+ lex_tokcstr (lexer));
return false;
}
/* Make a new macro. */
macro = pool_alloc (block->pool, sizeof *macro);
- ss_alloc_substring_pool (¯o->name, ss_cstr (lex_tokid (lexer)),
- block->pool);
+ ss_alloc_substring_pool (¯o->name, lex_tokss (lexer), block->pool);
ll_push_tail (&block->macros, ¯o->ll);
/* Skip equals sign. */
lex_get (lexer);
- if (!lex_force_match (lexer, '='))
+ if (!lex_force_match (lexer, T_EQUALS))
return false;
/* Get the details of the variable's possible values. */
}
if (count == 0)
return false;
- if (lex_token (lexer) != '/' && lex_token (lexer) != '.')
+ if (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD)
{
lex_error (lexer, NULL);
return false;
return false;
}
- lex_match (lexer, '/');
+ lex_match (lexer, T_SLASH);
}
- while (lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_ENDCMD);
return true;
}
{
struct substring id;
ss_ltrim (line, ss_cstr (CC_SPACES));
- ss_get_chars (line, lex_id_get_length (*line), &id);
+ ss_get_bytes (line, lex_id_get_length (*line), &id);
return lex_id_match (ss_cstr (keyword), id);
}
/* Retrieve an input line and make a copy of it. */
if (!lex_get_line_raw (lexer))
- return false;
+ {
+ msg (SE, _("DO REPEAT without END REPEAT."));
+ return false;
+ }
ds_init_string (&text, lex_entire_line_ds (lexer));
/* Record file name. */
add_replacement (ss_cstr (pool_asprintf (pool, "%g", i)),
macro, pool, &used, &allocated);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD);
return used;
}
add_replacement (ss_cstr (string), macro, pool, &used, &allocated);
lex_get (lexer);
- lex_match (lexer, ',');
+ lex_match (lexer, T_COMMA);
}
- while (lex_token (lexer) != '/' && lex_token (lexer) != '.');
+ while (lex_token (lexer) != T_SLASH && lex_token (lexer) != T_ENDCMD);
return used;
}
/* Strip trailing whitespace, check for & remove terminal dot. */
ds_rtrim (line, ss_cstr (CC_SPACES));
- dot = ds_chomp (line, settings_get_endcmd ());
+ dot = ds_chomp (line, '.');
input = ds_ss (line);
in_apos = in_quote = false;
while ((c = ss_first (input)) != EOF)
if (in_quote || in_apos || !lex_is_id1 (c))
{
- ds_put_char (&output, c);
+ ds_put_byte (&output, c);
ss_advance (&input, 1);
}
else
{
struct substring id;
- ss_get_chars (&input, lex_id_get_length (input), &id);
+ ss_get_bytes (&input, lex_id_get_length (input), &id);
ds_put_substring (&output, find_substitution (block, id));
}
}
if (dot)
- ds_put_char (&output, settings_get_endcmd ());
+ ds_put_byte (&output, '.');
ds_swap (line, &output);
ds_destroy (&output);
}
/* 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;
}