Skip to content

Commit 2a19aa5

Browse files
Fix error handlings of 0 divisions (#273)
1 parent d01ee46 commit 2a19aa5

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1919
* Fix the message of COB_VERBOSE file sort (#260)
2020
* Fix the process that checks MOVE statements (#266, #267)
2121
* Fix `INSPECT` statement (#268)
22+
* Fix error handlings of 0 divisions (#273)
2223
### Optimized
2324
* Optimize the file reading process (#257)
2425

cobj/codegen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3563,7 +3563,7 @@ static void joutput_stmt(cb_tree x, enum joutput_stmt_type output_type) {
35633563
((strcmp(p->name, "DIVIDE") == 0) ||
35643564
(strcmp(p->name, "COMPUTE") == 0)) &&
35653565
(!p->handler1 && !p->handler2)) {
3566-
joutput_line("cobolErrorOnExitFlag = true;");
3566+
joutput_line("CobolUtil.cobErrorOnExitFlag = true;");
35673567
}
35683568

35693569
if (p->null_check) {

libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/data/CobolDecimal.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,9 @@ public void div(CobolDecimal decimal) throws CobolStopRunException {
377377
if (decimal.getValue().signum() == 0) {
378378
this.setScale(DECIMAL_NAN);
379379
if (CobolUtil.cobErrorOnExitFlag) {
380-
// TODO より正確な実装に変更
381-
System.err.println("Detected division by zero");
382-
CobolStopRunException.throwException(1);
380+
CobolUtil.runtimeError("Detected division by zero.");
381+
CobolStopRunException.stopRunAndThrow(1);
382+
;
383383
}
384384
return;
385385
}

tests/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ jp_compat_DEPENDENCIES = \
136136
jp-compat.src/greater-less-than-equal.at \
137137
jp-compat.src/file-desc.at \
138138
jp-compat.src/abort-on-file-error.at \
139-
jp-compat.src/system-routine.at
139+
jp-compat.src/system-routine.at \
140+
jp-compat.src/catch-exception.at
140141

141142
command_line_options_DEPENDENCIES = \
142143
command-line-options.src/free.at \

tests/Makefile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ jp_compat_DEPENDENCIES = \
677677
jp-compat.src/greater-less-than-equal.at \
678678
jp-compat.src/file-desc.at \
679679
jp-compat.src/abort-on-file-error.at \
680-
jp-compat.src/system-routine.at
680+
jp-compat.src/system-routine.at \
681+
jp-compat.src/catch-exception.at
681682

682683
command_line_options_DEPENDENCIES = \
683684
command-line-options.src/free.at \

tests/jp-compat.src/catch-exception.at

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ AT_CLEANUP
4949
# 3) DONE
5050

5151
AT_SETUP([Divide by zero: by variable - option yes])
52-
AT_CHECK([${SKIP_TEST}])
5352

5453
AT_DATA([prog.cob], [
5554
IDENTIFICATION DIVISION.
@@ -150,7 +149,6 @@ AT_CLEANUP
150149
# 7) DONE
151150

152151
AT_SETUP([Divide by zero: by variable compute - option yes])
153-
AT_CHECK([${SKIP_TEST}])
154152

155153
AT_DATA([prog.cob], [
156154
IDENTIFICATION DIVISION.
@@ -204,7 +202,6 @@ AT_CLEANUP
204202
# 9) DONE
205203

206204
AT_SETUP([Divide by zero: by variable with on size error])
207-
AT_CHECK([${SKIP_TEST}])
208205

209206
AT_DATA([prog.cob], [
210207
IDENTIFICATION DIVISION.

0 commit comments

Comments
 (0)