Skip to content

Hotfix/move to national error #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions libcob/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,19 +1859,6 @@ cob_move (cob_field *src_in, cob_field *dst)
return;
}

if (COB_FIELD_TYPE (src) != COB_TYPE_GROUP) {
if ((!(COB_FIELD_TYPE (src) == COB_TYPE_NATIONAL ||
COB_FIELD_TYPE (src) == COB_TYPE_NATIONAL_EDITED)) &&
(COB_FIELD_TYPE (dst) == COB_TYPE_NATIONAL ||
COB_FIELD_TYPE (dst) == COB_TYPE_NATIONAL_EDITED)) {
pTmp = judge_hankakujpn_exist (src, dst, &size);
if (pTmp != NULL) {
src->data = (unsigned char *)pTmp;
src->size = size;
}
}
}

/* Non-elementary move */
if (COB_FIELD_TYPE (src) == COB_TYPE_GROUP
|| COB_FIELD_TYPE (dst) == COB_TYPE_GROUP) {
Expand Down Expand Up @@ -1927,11 +1914,21 @@ cob_move (cob_field *src_in, cob_field *dst)
return;
}
case COB_TYPE_NATIONAL:
pTmp = judge_hankakujpn_exist (src, dst, &size);
if (pTmp != NULL) {
src->data = (unsigned char *)pTmp;
src->size = size;
}
cob_move_alphanum_to_national (src, dst);
break;
return;
case COB_TYPE_NATIONAL_EDITED:
pTmp = judge_hankakujpn_exist (src, dst, &size);
if (pTmp != NULL) {
src->data = (unsigned char *)pTmp;
src->size = size;
}
cob_move_alphanum_to_national_edited (src, dst);
break;
return;
default:
cob_move_display_to_alphanum (src, dst);
return;
Expand Down Expand Up @@ -2269,9 +2266,19 @@ cob_move (cob_field *src_in, cob_field *dst)
cob_move_alphanum_to_edited (src, dst);
return;
case COB_TYPE_NATIONAL_EDITED:
pTmp = judge_hankakujpn_exist (src, dst, &size);
if (pTmp != NULL) {
src->data = (unsigned char *)pTmp;
src->size = size;
}
cob_move_alphanum_to_national_edited (src, dst);
break;
case COB_TYPE_NATIONAL:
pTmp = judge_hankakujpn_exist (src, dst, &size);
if (pTmp != NULL) {
src->data = (unsigned char *)pTmp;
src->size = size;
}
cob_move_alphanum_to_national (src, dst);
break;
default:
Expand Down
77 changes: 76 additions & 1 deletion tests/testsuite
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,7 @@ at_help_all="1;used_binaries.at:27;compiler help and information;runmisc cobc;
1309;i18n_sjis_pic-n.at:444;PIC N Move with half-width dakuten kana.;;
1310;i18n_sjis_pic-n.at:463;PIC N Move with half-width han-dakuten kana.;;
1311;i18n_sjis_pic-n.at:482;INITIALIZE PIC N.;;
1312;i18n_sjis_pic-n.at:501;PIC N Move with NUMERIC items.;;
"
# List of the all the test groups.
at_groups_all=`$as_echo "$at_help_all" | sed 's/;.*//'`
Expand All @@ -1920,7 +1921,7 @@ at_fn_validate_ranges ()
for at_grp
do
eval at_value=\$$at_grp
if test $at_value -lt 1 || test $at_value -gt 1311; then
if test $at_value -lt 1 || test $at_value -gt 1312; then
$as_echo "invalid test group: $at_value" >&2
exit 1
fi
Expand Down Expand Up @@ -224606,3 +224607,77 @@ $at_traceon; }
) 5>&1 2>&1 7>&- | eval $at_tee_pipe
read at_status <"$at_status_file"
#AT_STOP_1311
#AT_START_1312
at_fn_group_banner 1312 'i18n_sjis_pic-n.at:501' \
"PIC N Move with NUMERIC items." " " 6
at_xfail=no
(
$as_echo "1312. $at_setup_line: testing $at_desc ..."
$at_traceon


cat >prog.cob <<'_ATEOF'

IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 F0 PIC N(5).
01 F1 PIC 9(5).
01 F2 PIC S9(5).
01 F3 PIC 9(5) COMP-3.
01 F4 PIC S9(5) COMP.
PROCEDURE DIVISION.
MOVE 123 TO F1.
MOVE F1 TO F0.
DISPLAY F0.
MOVE -123 TO F2.
MOVE F2 TO F0.
DISPLAY F0.
MOVE 123 TO F3.
MOVE F3 TO F0.
DISPLAY F0.
MOVE -123 TO F4.
MOVE F4 TO F0.
DISPLAY F0.
STOP RUN.
_ATEOF


{ set +x
$as_echo "$at_srcdir/i18n_sjis_pic-n.at:529: \${COMPILE} -x prog.cob"
at_fn_check_prepare_notrace 'a ${...} parameter expansion' "i18n_sjis_pic-n.at:529"
( $at_check_trace; ${COMPILE} -x prog.cob
) >>"$at_stdout" 2>>"$at_stderr" 5>&-
at_status=$? at_failed=false
$at_check_filter
at_fn_diff_devnull "$at_stderr" || at_failed=:
at_fn_diff_devnull "$at_stdout" || at_failed=:
at_fn_check_status 0 $at_status "$at_srcdir/i18n_sjis_pic-n.at:529"
$at_failed && at_fn_log_failure
$at_traceon; }

{ set +x
$as_echo "$at_srcdir/i18n_sjis_pic-n.at:530: ./prog"
at_fn_check_prepare_trace "i18n_sjis_pic-n.at:530"
( $at_check_trace; ./prog
) >>"$at_stdout" 2>>"$at_stderr" 5>&-
at_status=$? at_failed=false
$at_check_filter
at_fn_diff_devnull "$at_stderr" || at_failed=:
echo >>"$at_stdout"; $as_echo "�O�O�P�Q�R
�O�O�P�Q��
�O�O�P�Q�R
�O�O�P�Q��
" | \
$at_diff - "$at_stdout" || at_failed=:
at_fn_check_status 0 $at_status "$at_srcdir/i18n_sjis_pic-n.at:530"
$at_failed && at_fn_log_failure
$at_traceon; }


set +x
$at_times_p && times >"$at_times_file"
) 5>&1 2>&1 7>&- | eval $at_tee_pipe
read at_status <"$at_status_file"
#AT_STOP_1312
38 changes: 38 additions & 0 deletions tests/testsuite.src/i18n_sjis_pic-n.at
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,41 @@ AT_CHECK([${COMPILE} -x prog.cob], [0])
AT_CHECK([./prog], [0], [�@�@�@�@�@])

AT_CLEANUP

AT_SETUP([PIC N Move with NUMERIC items.])

AT_DATA([prog.cob], [
IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 F0 PIC N(5).
01 F1 PIC 9(5).
01 F2 PIC S9(5).
01 F3 PIC 9(5) COMP-3.
01 F4 PIC S9(5) COMP.
PROCEDURE DIVISION.
MOVE 123 TO F1.
MOVE F1 TO F0.
DISPLAY F0.
MOVE -123 TO F2.
MOVE F2 TO F0.
DISPLAY F0.
MOVE 123 TO F3.
MOVE F3 TO F0.
DISPLAY F0.
MOVE -123 TO F4.
MOVE F4 TO F0.
DISPLAY F0.
STOP RUN.
])

AT_CHECK([${COMPILE} -x prog.cob], [0])
AT_CHECK([./prog], [0],
[�O�O�P�Q�R
�O�O�P�Q��
�O�O�P�Q�R
�O�O�P�Q��
])

AT_CLEANUP