projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
format: Cite variable names in messages reporting incompatible width.
[pspp]
/
src
/
language
/
dictionary
/
attributes.c
diff --git
a/src/language/dictionary/attributes.c
b/src/language/dictionary/attributes.c
index fc9cc9a5d28b72dd7b86701fb1cf42557b66a9f0..954314ef4fb07339f599e8f6974582e5b1cf00c3 100644
(file)
--- a/
src/language/dictionary/attributes.c
+++ b/
src/language/dictionary/attributes.c
@@
-52,7
+52,7
@@
cmd_variable_attribute (struct lexer *lexer, struct dataset *ds)
struct dictionary *dict = dataset_dict (ds);
const char *dict_encoding = dict_get_encoding (dict);
struct dictionary *dict = dataset_dict (ds);
const char *dict_encoding = dict_get_encoding (dict);
- do
+ do
{
struct variable **vars;
struct attrset **sets;
{
struct variable **vars;
struct attrset **sets;
@@
-87,23
+87,22
@@
static char *
parse_attribute_name (struct lexer *lexer, const char *dict_encoding,
size_t *index)
{
parse_attribute_name (struct lexer *lexer, const char *dict_encoding,
size_t *index)
{
- char *name;
-
- if (!lex_force_id (lexer)
- || !id_is_valid (lex_tokcstr (lexer), dict_encoding, true))
+ if (!lex_force_id (lexer))
return NULL;
return NULL;
- name = xstrdup (lex_tokcstr (lexer));
+ char *error = id_is_valid__ (lex_tokcstr (lexer), dict_encoding);
+ if (error)
+ {
+ lex_error (lexer, "%s", error);
+ free (error);
+ return NULL;
+ }
+ char *name = xstrdup (lex_tokcstr (lexer));
lex_get (lexer);
if (lex_match (lexer, T_LBRACK))
{
lex_get (lexer);
if (lex_match (lexer, T_LBRACK))
{
- if (!lex_force_int
(lexer
))
+ if (!lex_force_int
_range (lexer, NULL, 1, 65535
))
goto error;
goto error;
- if (lex_integer (lexer) < 1 || lex_integer (lexer) > 65535)
- {
- msg (SE, _("Attribute array index must be between 1 and 65535."));
- goto error;
- }
*index = lex_integer (lexer);
lex_get (lexer);
if (!lex_force_match (lexer, T_RBRACK))
*index = lex_integer (lexer);
lex_get (lexer);
if (!lex_force_match (lexer, T_RBRACK))
@@
-120,7
+119,7
@@
error:
static bool
add_attribute (struct lexer *lexer, const char *dict_encoding,
static bool
add_attribute (struct lexer *lexer, const char *dict_encoding,
- struct attrset **sets, size_t n)
+ struct attrset **sets, size_t n)
{
const char *value;
size_t index, i;
{
const char *value;
size_t index, i;
@@
-139,10
+138,10
@@
add_attribute (struct lexer *lexer, const char *dict_encoding,
for (i = 0; i < n; i++)
{
struct attribute *attr = attrset_lookup (sets[i], name);
for (i = 0; i < n; i++)
{
struct attribute *attr = attrset_lookup (sets[i], name);
- if (attr == NULL)
+ if (attr == NULL)
{
attr = attribute_create (name);
{
attr = attribute_create (name);
- attrset_add (sets[i], attr);
+ attrset_add (sets[i], attr);
}
attribute_set_value (attr, index ? index - 1 : 0, value);
}
}
attribute_set_value (attr, index ? index - 1 : 0, value);
}
@@
-154,7
+153,7
@@
add_attribute (struct lexer *lexer, const char *dict_encoding,
static bool
delete_attribute (struct lexer *lexer, const char *dict_encoding,
static bool
delete_attribute (struct lexer *lexer, const char *dict_encoding,
- struct attrset **sets, size_t n)
+ struct attrset **sets, size_t n)
{
size_t index, i;
char *name;
{
size_t index, i;
char *name;
@@
-163,7
+162,7
@@
delete_attribute (struct lexer *lexer, const char *dict_encoding,
if (name == NULL)
return false;
if (name == NULL)
return false;
- for (i = 0; i < n; i++)
+ for (i = 0; i < n; i++)
{
struct attrset *set = sets[i];
if (index == 0)
{
struct attrset *set = sets[i];
if (index == 0)
@@
-171,11
+170,11
@@
delete_attribute (struct lexer *lexer, const char *dict_encoding,
else
{
struct attribute *attr = attrset_lookup (set, name);
else
{
struct attribute *attr = attrset_lookup (set, name);
- if (attr != NULL)
+ if (attr != NULL)
{
attribute_del_value (attr, index - 1);
if (attribute_get_n_values (attr) == 0)
{
attribute_del_value (attr, index - 1);
if (attribute_get_n_values (attr) == 0)
- attrset_delete (set, name);
+ attrset_delete (set, name);
}
}
}
}
}
}
@@
-186,10
+185,10
@@
delete_attribute (struct lexer *lexer, const char *dict_encoding,
static enum cmd_result
parse_attributes (struct lexer *lexer, const char *dict_encoding,
static enum cmd_result
parse_attributes (struct lexer *lexer, const char *dict_encoding,
- struct attrset **sets, size_t n)
+ struct attrset **sets, size_t n)
{
enum { UNKNOWN, ADD, DELETE } command = UNKNOWN;
{
enum { UNKNOWN, ADD, DELETE } command = UNKNOWN;
- do
+ do
{
if (lex_match_phrase (lexer, "ATTRIBUTE="))
command = ADD;
{
if (lex_match_phrase (lexer, "ATTRIBUTE="))
command = ADD;
@@
-197,7
+196,7
@@
parse_attributes (struct lexer *lexer, const char *dict_encoding,
command = DELETE;
else if (command == UNKNOWN)
{
command = DELETE;
else if (command == UNKNOWN)
{
- lex_error_expecting (lexer, "ATTRIBUTE=", "DELETE="
, NULL_SENTINEL
);
+ lex_error_expecting (lexer, "ATTRIBUTE=", "DELETE=");
return CMD_FAILURE;
}
return CMD_FAILURE;
}