Skip to content

Commit

Permalink
Merge SVN 4638
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jun 19, 2024
1 parent 0da7dc0 commit 30f348f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
3 changes: 3 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@

* typeck.c (numeric_children_screen_pos_type): ignore redefined
fields
* field.c (cb_resolve_redefines): always search candidate with (small)
word list first, instead of checking the complete parent for a same
name with case-insensitive name comparison

2022-06-17 Nicolas Berthier <[email protected]>

Expand Down
47 changes: 24 additions & 23 deletions cobc/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,31 +637,32 @@ cb_resolve_redefines (struct cb_field *field, cb_tree redefines)
return NULL;
}

/* Resolve the name in the current group (if any) */
if (field->parent && field->parent->children) {
for (f = field->parent->children; f; f = f->sister) {
if (strcasecmp (f->name, name) == 0) {
break;
}
}
if (f == NULL) {
cb_error_x (x, _("'%s' is not defined in '%s'"), name, field->parent->name);
return NULL;
}
} else {
/* Get last defined name */
candidate = NULL;
items = r->word->items;
for (; items; items = CB_CHAIN (items)) {
if (CB_FIELD_P (CB_VALUE (items))) {
candidate = CB_VALUE (items);
}
}
if (!candidate) {
/* Get last defined name */
/* note: chaining over these are much faster than chaining over the complete
parent using strcasecmp */
for (items = r->word->items; items; items = CB_CHAIN (items)) {
const cb_tree value = CB_VALUE (items);
if (CB_FIELD_P (value)) {
candidate = value;
/* we want to get the last, so no "break" here */
}
}
if (!candidate) {
if (field->parent) {
cb_error_x (x, _("'%s' is not defined in '%s'"),
name, field->parent->name);
} else {
undefined_error (redefines);
return NULL;
}
f = CB_FIELD_PTR (candidate);
return NULL;
}
f = CB_FIELD_PTR (candidate);

/* Check if candidate is in the current group (if any) */
if (field->parent && field->parent != f->parent) {
cb_error_x (x, _ ("'%s' is not defined in '%s'"),
name, field->parent->name);
return NULL;
}

/* Check level number */
Expand Down

0 comments on commit 30f348f

Please sign in to comment.