Skip to content

Commit

Permalink
Make cob_move_ibm callable sooner by externalizing it
Browse files Browse the repository at this point in the history
  • Loading branch information
engboris committed Jan 13, 2025
1 parent 5a63526 commit 28727b5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
17 changes: 9 additions & 8 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -12031,13 +12031,7 @@ cb_build_move_copy (cb_tree src, cb_tree dst)
if (size == 1) {
return CB_BUILD_FUNCALL_2 ("$F", dst, src);
}
if (cb_move_ibm) {
overlapping = 0;
return CB_BUILD_FUNCALL_3 ("cob_move_ibm",
CB_BUILD_CAST_ADDRESS (dst),
CB_BUILD_CAST_ADDRESS (src),
CB_BUILD_CAST_LENGTH (dst));
} else if (overlapping
else if (overlapping
|| CB_FIELD_PTR (src)->storage == CB_STORAGE_LINKAGE
|| CB_FIELD_PTR (dst)->storage == CB_STORAGE_LINKAGE
|| CB_FIELD_PTR (src)->flag_item_based
Expand Down Expand Up @@ -12614,7 +12608,14 @@ cb_build_move_field (cb_tree src, cb_tree dst)
int src_size;
int dst_size;

if (dst_f->flag_any_length || src_f->flag_any_length) {
if (cb_move_ibm) {
overlapping = 0;
return CB_BUILD_FUNCALL_3 ("cob_move_ibm",
CB_BUILD_CAST_ADDRESS (dst),
CB_BUILD_CAST_ADDRESS (src),
CB_BUILD_CAST_LENGTH (dst));
}
else if (dst_f->flag_any_length || src_f->flag_any_length) {
return CB_BUILD_FUNCALL_2 ("cob_move", src, dst);
}
src_size = cb_field_size (src);
Expand Down
10 changes: 0 additions & 10 deletions libcob/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,6 @@ cob_move_alphanum_to_display (cob_field *f1, cob_field *f2)
int size;
unsigned char *tmp_src_data = NULL;

/* Initialize */
if ( (s1 >= s2 && s1 < e2) || (s2 >= s1 && s2 < e1) ){
tmp_src_data = cob_malloc (f1->size);
memcpy (tmp_src_data, s1, f1->size);
s1 = tmp_src_data;
e1 = s1 + f1->size;
}
memset (f2->data, '0', f2->size);

/* Skip white spaces */
Expand Down Expand Up @@ -366,14 +359,11 @@ cob_move_alphanum_to_display (cob_field *f1, cob_field *f2)
}

COB_PUT_SIGN (f2, sign);
if (tmp_src_data) cob_free (tmp_src_data);
return;

error:
memset (f2->data, '0', f2->size);
COB_PUT_SIGN (f2, 0);
if (tmp_src_data) cob_free (tmp_src_data);
return;
}

static void
Expand Down
4 changes: 1 addition & 3 deletions tests/testsuite.src/run_file.at
Original file line number Diff line number Diff line change
Expand Up @@ -14681,9 +14681,7 @@ AT_DATA([prog.cob], [
STOP RUN.
])

AT_CHECK([$COMPILE prog.cob -o prog], [0], [],
[prog.cob:16: warning: overlapping MOVE may produce unpredictable results
])
AT_CHECK([$COMPILE -fmove-ibm prog.cob -o prog], [0], [], [])

AT_CHECK([./prog], [0], [01234
])
Expand Down

0 comments on commit 28727b5

Please sign in to comment.