projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cite tokens when reporting invalid identifiers.
[pspp]
/
src
/
language
/
data-io
/
trim.c
diff --git
a/src/language/data-io/trim.c
b/src/language/data-io/trim.c
index b9983ef49ef34c2cee318089ac62a2e85158d78c..cf493391e4d9ccdf5729a6d974ce1056ce8bb774 100644
(file)
--- a/
src/language/data-io/trim.c
+++ b/
src/language/data-io/trim.c
@@
-55,7
+55,7
@@
parse_dict_trim (struct lexer *lexer, struct dictionary *dict, bool relax)
return parse_dict_rename (lexer, dict, relax);
else
{
return parse_dict_rename (lexer, dict, relax);
else
{
- lex_error
(lexer, _("expecting a valid subcommand")
);
+ lex_error
_expecting (lexer, "MAP", "DROP", "KEEP", "RENAME"
);
return false;
}
}
return false;
}
}
@@
-95,12
+95,22
@@
try_to_sequence (struct lexer *lexer, const struct dictionary *dict,
/* Check that the first and last tokens are suitable as
variable names. */
const char *s0 = lex_tokcstr (lexer);
/* Check that the first and last tokens are suitable as
variable names. */
const char *s0 = lex_tokcstr (lexer);
- if (!id_is_valid (s0, dict_get_encoding (dict), true))
- return NULL;
+ char *error = id_is_valid__ (s0, dict_get_encoding (dict));
+ if (error)
+ {
+ lex_error (lexer, "%s", error);
+ free (error);
+ return NULL;
+ }
const char *s1 = lex_next_tokcstr (lexer, 2);
const char *s1 = lex_next_tokcstr (lexer, 2);
- if (!id_is_valid (s1, dict_get_encoding (dict), true))
- return NULL;
+ error = id_is_valid__ (s1, dict_get_encoding (dict));
+ if (error)
+ {
+ lex_next_error (lexer, 2, 2, "%s", error);
+ free (error);
+ return NULL;
+ }
int x0 = strcspn (s0, "0123456789");
int x1 = strcspn (s1, "0123456789");
int x0 = strcspn (s0, "0123456789");
int x1 = strcspn (s1, "0123456789");
@@
-211,8
+221,16
@@
parse_dict_rename (struct lexer *lexer, struct dictionary *dict,
if (n_newvars >= n_oldvars)
break;
const char *new_name = lex_tokcstr (lexer);
if (n_newvars >= n_oldvars)
break;
const char *new_name = lex_tokcstr (lexer);
- if (!relax && ! id_is_plausible (new_name, true))
- goto fail;
+ if (!relax)
+ {
+ char *error = id_is_plausible__ (new_name);
+ if (error)
+ {
+ lex_error (lexer, "%s", error);
+ free (error);
+ goto fail;
+ }
+ }
if (!check_rename (dict, var_get_name (oldvars[n_newvars]), new_name))
goto fail;
if (!check_rename (dict, var_get_name (oldvars[n_newvars]), new_name))
goto fail;
@@
-276,7
+294,7
@@
parse_dict_drop (struct lexer *lexer, struct dictionary *dict)
dict_delete_vars (dict, v, nv);
free (v);
dict_delete_vars (dict, v, nv);
free (v);
- if (dict_get_
var_cnt
(dict) == 0)
+ if (dict_get_
n_vars
(dict) == 0)
{
msg (SE, _("Cannot DROP all variables from dictionary."));
return false;
{
msg (SE, _("Cannot DROP all variables from dictionary."));
return false;
@@
-302,16
+320,16
@@
parse_dict_keep (struct lexer *lexer, struct dictionary *dict)
dict_reorder_vars (dict, v, nv);
/* Delete the remaining variables. */
dict_reorder_vars (dict, v, nv);
/* Delete the remaining variables. */
- if (dict_get_
var_cnt
(dict) == nv)
+ if (dict_get_
n_vars
(dict) == nv)
{
free (v);
return true;
}
{
free (v);
return true;
}
- v = xnrealloc (v, dict_get_
var_cnt
(dict) - nv, sizeof *v);
- for (i = nv; i < dict_get_
var_cnt
(dict); i++)
+ v = xnrealloc (v, dict_get_
n_vars
(dict) - nv, sizeof *v);
+ for (i = nv; i < dict_get_
n_vars
(dict); i++)
v[i - nv] = dict_get_var (dict, i);
v[i - nv] = dict_get_var (dict, i);
- dict_delete_vars (dict, v, dict_get_
var_cnt
(dict) - nv);
+ dict_delete_vars (dict, v, dict_get_
n_vars
(dict) - nv);
free (v);
return true;
free (v);
return true;