X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdata-io%2Ftrim.c;h=68a2b5ed9c1ef28c8963cccfcdac0b364bf1b04b;hb=35717813005e999b6b807fc3f4bd6bb2d770f301;hp=9f76b10516b1b8d88dc2eba668b919020c784d58;hpb=55e6e7ba37a30570f5a31e2d78c22dfa7b61a36f;p=pspp diff --git a/src/language/data-io/trim.c b/src/language/data-io/trim.c index 9f76b10516..68a2b5ed9c 100644 --- a/src/language/data-io/trim.c +++ b/src/language/data-io/trim.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2007, 2008, 2010, 2011 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 @@ -16,17 +16,17 @@ #include -#include +#include "language/data-io/trim.h" #include -#include -#include -#include -#include -#include +#include "data/dictionary.h" +#include "data/variable.h" +#include "language/lexer/lexer.h" +#include "language/lexer/variable-parser.h" +#include "libpspp/message.h" -#include "xalloc.h" +#include "gl/xalloc.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -75,27 +75,27 @@ parse_dict_rename (struct lexer *lexer, struct dictionary *dict) lex_match (lexer, T_EQUALS); if (lex_token (lexer) != T_LPAREN) { - struct variable *v; - - v = parse_variable (lexer, dict); + struct variable *v = parse_variable (lexer, dict); if (v == NULL) return 0; - if (!lex_force_match (lexer, T_EQUALS) - || !lex_force_id (lexer)) - return 0; - if (dict_lookup_var (dict, lex_tokcstr (lexer)) != NULL) + if (!lex_force_match (lexer, T_EQUALS)) + return 0; + + char *new_name = parse_DATA_LIST_var (lexer, dict); + if (dict_lookup_var (dict, new_name) != NULL) { msg (SE, _("Cannot rename %s as %s because there already exists " "a variable named %s. To rename variables with " "overlapping names, use a single RENAME subcommand " "such as `/RENAME (A=B)(B=C)(C=A)', or equivalently, " "`/RENAME (A B C=B C A)'."), - var_get_name (v), lex_tokcstr (lexer), lex_tokcstr (lexer)); + var_get_name (v), new_name, new_name); + free (new_name); return 0; } - dict_rename_var (dict, v, lex_tokcstr (lexer)); - lex_get (lexer); + dict_rename_var (dict, v, new_name); + free (new_name); return 1; } @@ -111,10 +111,10 @@ parse_dict_rename (struct lexer *lexer, struct dictionary *dict) goto done; if (!lex_match (lexer, T_EQUALS)) { - msg (SE, _("`=' expected after variable list.")); + lex_error_expecting (lexer, "`='", NULL_SENTINEL); goto done; } - if (!parse_DATA_LIST_vars (lexer, &new_names, &nn, + if (!parse_DATA_LIST_vars (lexer, dict, &new_names, &nn, PV_APPEND | PV_NO_SCRATCH | PV_NO_DUPLICATE)) goto done; if (nn != nv)