Skip to content

Commit a4ef001

Browse files
authored
Merge branch 'develop' into fix-inspect-improve
2 parents 1a297ab + 46ef3dc commit a4ef001

File tree

11 files changed

+360
-39
lines changed

11 files changed

+360
-39
lines changed

.github/workflows/create-release.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,29 @@ jobs:
4444
gh release upload ${{ github.ref_name }} cobj.exe --clobber
4545
gh release upload ${{ github.ref_name }} libcobj.jar --clobber
4646
gh release upload ${{ github.ref_name }} config/default.conf --clobber
47-
47+
48+
# publish libcobj.jar to GitHub Packages
49+
publish:
50+
needs: check-workflows
51+
runs-on: ubuntu-latest
52+
permissions:
53+
contents: read
54+
packages: write
55+
steps:
56+
- uses: actions/checkout@v4
57+
- run: |
58+
cd ../
59+
mv opensourcecobol4j/* .
60+
mv libcobj/* opensourcecobol4j
61+
- uses: actions/setup-java@v4
62+
with:
63+
java-version: '11'
64+
distribution: 'temurin'
65+
- name: Validate Gradle wrapper
66+
uses: gradle/wrapper-validation-action@v3
67+
- name: Publish package
68+
uses: gradle/gradle-build-action@v3
69+
with:
70+
arguments: publish
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish-libcobj.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

cobj/codegen.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,7 @@ static void joutput_cond(cb_tree x, int save_flag) {
19731973
}
19741974
joutput_indent("(new GetInt() {");
19751975
joutput_indent_level += 2;
1976-
joutput_indent("public int run(){");
1976+
joutput_indent("public int run() throws CobolStopRunException {");
19771977
joutput_indent_level += 2;
19781978
for (; x; x = CB_CHAIN(x)) {
19791979
// 最後の文ならreturn文を書く
@@ -2667,6 +2667,7 @@ static void joutput_search_all(cb_tree table, cb_tree stmt, cb_tree cond,
26672667
joutput_prefix();
26682668
joutput("int tail = ");
26692669
if (p->occurs_depending) {
2670+
joutput("(int)");
26702671
joutput_integer(p->occurs_depending);
26712672
joutput(" + 1;\n");
26722673
} else {

libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/common/GetInt.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
*/
1919
package jp.osscons.opensourcecobol.libcobj.common;
2020

21+
import jp.osscons.opensourcecobol.libcobj.exceptions.CobolStopRunException;
22+
2123
/** TODO: 準備中 */
2224
public interface GetInt {
2325
/**
2426
* TODO: 準備中
2527
*
2628
* @return TODO: 準備中
29+
* @throws CobolStopRunException TODO: 準備中
2730
*/
28-
int run();
31+
int run() throws CobolStopRunException;
2932
}

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,49 @@ private int addInt(int in, int opt) {
691691
}
692692
}
693693

694+
if (this.isPositiveZeroOrNegativeZero()) {
695+
sign = 1;
696+
}
697+
694698
this.putSign(sign);
695699
return 0;
696700
}
697701

702+
/**
703+
* このフィールドが正のゼロまたは負のゼロであるかどうかを判定する
704+
*/
705+
private boolean isPositiveZeroOrNegativeZero() {
706+
int signIndex;
707+
CobolFieldAttribute attr = this.getAttribute();
708+
if (attr.isFlagHaveSign() && !attr.isFlagSignSeparate()) {
709+
if (attr.isFlagSignLeading()) {
710+
signIndex = 0;
711+
} else {
712+
signIndex = this.getSize() - 1;
713+
}
714+
} else {
715+
signIndex = -1000;
716+
}
717+
718+
CobolDataStorage data = this.getDataStorage();
719+
int size = this.getFieldSize();
720+
int firstDataIndex = this.getFirstDataIndex();
721+
for (int i = 0; i < size; ++i) {
722+
int index = firstDataIndex + i;
723+
byte value = data.getByte(index);
724+
if (index == signIndex) {
725+
if (value != 0x30 && value != 0x70) {
726+
return false;
727+
}
728+
} else {
729+
if (value != 0x30) {
730+
return false;
731+
}
732+
}
733+
}
734+
return true;
735+
}
736+
698737
/**
699738
* libcob/numeric.cのdisplay_add_intの実装
700739
*
@@ -767,6 +806,9 @@ private static int displaySubInt(CobolDataStorage data, int firstDataIndex, int
767806

768807
/* perform subtraction */
769808
byte val = data.getByte(sp);
809+
if (val >= 0x70) {
810+
val -= 0x40;
811+
}
770812
data.setByte(sp, (byte) (val - (i + carry)));
771813
if (val - (i + carry) < '0') {
772814
carry = 1;

tests/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ misc_DEPENDENCIES = \
221221
misc.src/evaluate-switch.at \
222222
misc.src/fserial-variable.at \
223223
misc.src/file-handler-japanese.at \
224+
misc.src/perform-until-div.at \
225+
misc.src/search-occurs-depending.at \
226+
misc.src/fix-subtract.at \
224227
misc.src/display-inspect-sign.at
225228

226229
EXTRA_DIST = $(srcdir)/package.m4 \

tests/Makefile.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,10 @@ misc_DEPENDENCIES = \
760760
misc.src/evaluate-switch.at \
761761
misc.src/fserial-variable.at \
762762
misc.src/file-handler-japanese.at \
763-
misc.src/display-inspect-sign.at
763+
misc.src/perform-until-div.at \
764+
misc.src/search-occurs-depending.at \
765+
misc.src/fix-subtract.at \
766+
misc.src/display-inspect-sign.at
764767

765768
EXTRA_DIST = $(srcdir)/package.m4 \
766769
$(TESTS) \

tests/misc.at

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ m4_include([japanese-char-section-var.at])
5050
m4_include([evaluate-switch.at])
5151
m4_include([fserial-variable.at])
5252
m4_include([file-handler-japanese.at])
53+
m4_include([perform-until-div.at])
54+
m4_include([search-occurs-depending.at])
55+
m4_include([fix-subtract.at])
5356
m4_include([display-inspect-sign.at])

0 commit comments

Comments
 (0)