Skip to content

Commit

Permalink
Merge SVN 5130
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jan 15, 2025
1 parent 369e5bd commit 2a0b91e
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 35 deletions.
9 changes: 9 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
* typeck.c (cb_emit_call): fixed skipping memory-fence generation for
EXTERNAL/BASED sub-fields

2023-07-20 Simon Sobisch <[email protected]>

* field.c (copy_validation): new function
* field.c (copy_validation, copy_into_field): handling validation
* cobc.c (print_fields): leave a hint to field being TYPEDEF
* cobc.c (xref_fields): dont output references for TYPEDEF sub items

2023-07-19 Simon Sobisch <[email protected]>

* typeck.c (refmod_checks): extracted from (cb_build_identifier)
Expand Down Expand Up @@ -257,6 +264,8 @@
2023-05-30 Simon Sobisch <[email protected]>

* typeck.y (is_subordinate_to): start with parent, not field
* field.c (copy_into_field_recursive, copy_into_field): handling more
field attributes, don't re-build picture

2023-05-28 Simon Sobisch <[email protected]>

Expand Down
22 changes: 18 additions & 4 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ static void print_program_header (void);
static void print_program_data (const char *);
static void print_program_trailer (void);
static void print_program_listing (void);
static void print_with_overflow (char *, char *);
static void print_with_overflow (const char *, char *);
static int process (const char *);

/* cobc functions */
Expand Down Expand Up @@ -5793,6 +5793,7 @@ print_88_values (struct cb_field *field)
" %-14.14s %02d %s",
"CONDITIONAL", f->level, f->name);
print_program_data (print_data);
/* CHECKME: Would it be useful or noise to print 88er values here? */
}
}

Expand Down Expand Up @@ -5852,7 +5853,14 @@ print_fields (struct cb_field *top, int *found)
pd_off = sprintf (print_data, "%05d ", top->size);
}

pd_off += sprintf (print_data + pd_off, "%-14.14s %02d ", type, top->level);
if (top->flag_is_typedef) {
/* at least leave a hint on the TYPEDEF in symbol listing,
note: for "ALPHANUMERIC" we have only 2 positions left, so "T " */
pd_off += sprintf (print_data + pd_off, "T %-12.12s ", type);
} else {
pd_off += sprintf (print_data + pd_off, "%-14.14s ", type);
}
pd_off += sprintf (print_data + pd_off, "%02d ", top->level);

name_or_filler = check_filler_name (top);
if (got_picture) {
Expand Down Expand Up @@ -6172,6 +6180,12 @@ xref_fields (struct cb_field *top)
xref_print (&top->xref, XREF_FIELD, NULL);
}

/* enough, if we are a typedef, as its contents are only
referenced through fields using this type */
if (top->flag_is_typedef) {
continue;
}

/* print xref for all assigned 88 validation entries */
if (top->validation) {
xref_88_values (top);
Expand Down Expand Up @@ -6416,7 +6430,7 @@ print_program_trailer (void)
cmd_line[pd_off - 1] = 0;
force_new_page_for_next_line ();
print_program_data (_("command line:"));
print_with_overflow ((char *)" ", cmd_line);
print_with_overflow (" ", cmd_line);
print_break = 0;
} else {
print_program_data ("");
Expand Down Expand Up @@ -6857,7 +6871,7 @@ print_free_line (const int line_num, char pch, char *line)
}

static void
print_with_overflow (char *prefix, char *content)
print_with_overflow (const char *prefix, char *content)
{
const unsigned int max_chars_on_line = cb_listing_wide ? 120 : 80;
int offset;
Expand Down
71 changes: 64 additions & 7 deletions cobc/field.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,33 @@ copy_duplicated_field_into_field (struct cb_field *field, struct cb_field *targe
copy_into_field_recursive (field, CB_FIELD (x), outer_indexes);
}

static void
copy_validation (struct cb_field *source, struct cb_field *target)
{
struct cb_field *val, *last_val;
#if 0 /* in case we want to allow combining condition-names of typedef and field */
for (last_val = target->validation; last_val; last_val = last_val->sister) {
/* get to the last validation entry*/
if (!last_val->sister) {
break;
}
}
#else
if (target->validation) {
(void) cb_syntax_check_x (CB_TREE (target->validation), _("duplicate %s"), "level 88");
}
#endif
for (val = source->validation; val; val = val->sister) {
/* create content-name and link into the reference list */
cb_tree x = cb_build_field_tree (88, cb_build_reference (val->name),
target, target->storage, target->file, 0);
last_val = CB_FIELD (x);
/* directly assign the typef's value + false (no need for copy) */
last_val->values = val->values;
last_val->false_88 = val->false_88;
}
}

static void
copy_children (struct cb_field *child, struct cb_field *target,
const int level, const int outer_indexes, const enum cb_storage storage)
Expand Down Expand Up @@ -813,10 +840,12 @@ copy_into_field_recursive (struct cb_field *source, struct cb_field *target,
field_attribute_override (flag_sign_leading);
field_attribute_override (flag_sign_separate);
field_attribute_override (flag_synchronized);
field_attribute_override (flag_item_based);
field_attribute_override (flag_sync_right);
field_attribute_override (flag_sync_left);
field_attribute_override (flag_any_length);
field_attribute_override (flag_any_numeric);
field_attribute_override (flag_invalid);
field_attribute_override (flag_item_based);
field_attribute_override (flag_is_pointer);
/* Note: attributes must be handled both here and in copy_into_field */

Expand All @@ -827,10 +856,18 @@ copy_into_field_recursive (struct cb_field *source, struct cb_field *target,
target->redefines = cb_resolve_redefines (target, ref);
}

/* copy all level 88 */
if (source->validation) {
copy_validation (source, target);
}

if (source->children) {
copy_children (source->children, target, target->level, outer_indexes, target->storage);
} else if (source->pic){
target->pic = cb_build_picture (source->pic->orig);
/* take over internal PICTURE representation as-is, no use in re-building
that from scratch and handle calculated ->pic special */
target->pic = cobc_parse_malloc (sizeof (struct cb_picture));
memcpy (target->pic, source->pic, sizeof (struct cb_picture));
}

if (source->sister) {
Expand Down Expand Up @@ -859,7 +896,8 @@ copy_into_field (struct cb_field *source, struct cb_field *target)
#endif

/* note: EXTERNAL is always applied from the typedef (if level 1/77),
but may be specified on the field */
but may be specified on the field;
note: MF has different syntax rules and _only_ allows it on the field */
if (target->level == 1 || target->level == 77) {
field_attribute_copy (flag_external);
if (target->flag_external
Expand All @@ -872,10 +910,15 @@ copy_into_field (struct cb_field *source, struct cb_field *target)
}
}
target->usage = source->usage;
target->common.category = source->common.category;
if (target->flag_external
&& target->ename == NULL) { /* External Name is required */
target->ename = target->name;
}
}

/* Note: The attributes GLOBAL and SELECT WHEN are never included;
SAME AS does not include EXTERNAL, but the TYPEDEF */

if (source->values) {
if (target->values) {
duplicate_clause_message (target->values, "VALUE");
Expand All @@ -888,19 +931,32 @@ copy_into_field (struct cb_field *source, struct cb_field *target)
field_attribute_copy (flag_sign_clause);
field_attribute_copy (flag_sign_leading);
field_attribute_copy (flag_sign_separate);
field_attribute_copy (flag_synchronized);
field_attribute_copy (flag_item_based);
if (source->flag_synchronized
&& !target->flag_synchronized) {
target->flag_synchronized = source->flag_synchronized;
target->flag_sync_right = source->flag_sync_right;
target->flag_sync_left = source->flag_sync_left;
}
field_attribute_override (flag_any_length);
field_attribute_override (flag_any_numeric);
field_attribute_override (flag_invalid);
field_attribute_copy (flag_item_based);
field_attribute_override (flag_is_pointer);
/* Note: attributes must be handled both here and in copy_into_field_recursive */

/* copy all level 88 */
if (source->validation) {
copy_validation (source, target);
}

if (!target->like_modifier) {
if (source->children) {
copy_children (source->children, target, target->level, target->indexes, target->storage);
} else if (source->pic) {
target->pic = cb_build_picture (source->pic->orig);
/* take over internal PICTURE representation as-is, no use in re-building
that from scratch and in handling calculated ->pic special */
target->pic = cobc_parse_malloc (sizeof (struct cb_picture));
memcpy (target->pic, source->pic, sizeof (struct cb_picture));
}
} else {
struct cb_picture *new_pic = NULL;
Expand Down Expand Up @@ -971,6 +1027,7 @@ copy_into_field (struct cb_field *source, struct cb_field *target)
if (new_pic) {
target->pic = new_pic;
} else if (target->pic) {
/* CHECKME: is there any use in re-building the PIC? */
target->pic = cb_build_picture (target->pic->orig);
}
}
Expand Down
Loading

0 comments on commit 2a0b91e

Please sign in to comment.