Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
579c31e
fix: convert SJIS string literals to ordinary Java string literals
yutaro-sakamoto Dec 10, 2024
bddb332
test: add test suites
yutaro-sakamoto Dec 12, 2024
a0ded88
test: add new tests cobol_utf8
yutaro-sakamoto Dec 20, 2024
bc503a0
ci: run tests of --enable-utf8 tests
yutaro-sakamoto Dec 20, 2024
2f2ebe9
ci: fix workflows for push events
yutaro-sakamoto Dec 20, 2024
9acdbea
ci: disable `fail-fast` of some jobs temporarily
yutaro-sakamoto Dec 20, 2024
89a9907
Merge branch 'develop' into cobol-utf8
yutaro-sakamoto Dec 20, 2024
07ca03f
ci: change pull_request.yml to runu utf8 tests
yutaro-sakamoto Dec 20, 2024
e744ad6
ci: fix push.yml and pull-request.yml slightly
yutaro-sakamoto Dec 20, 2024
dd50424
test: covert some misc tests to UTF8 versions and add them to cobol_utf8
yutaro-sakamoto Dec 24, 2024
cae6c11
test: change utf8 tests
yutaro-sakamoto Dec 24, 2024
19e1977
ci: run m4 when installing the compiler
yutaro-sakamoto Dec 25, 2024
02fe466
fix: dispatch encodings of javac
yutaro-sakamoto Dec 25, 2024
2813bcc
Merge branch 'develop' into cobol-utf8
Jan 6, 2025
3524f72
wip: fix slightly
Jan 6, 2025
711902b
wip: wip
Jan 8, 2025
d08181e
fix: update libcobj to encode Strings to SJIS
Jan 9, 2025
8e14245
fix: add -Wno-parentheses
yutaro-sakamoto Jan 9, 2025
88c2471
test: fix tests
yutaro-sakamoto Jan 9, 2025
6a6ca68
fix: disable size checks of UTF-8 data
yutaro-sakamoto Jan 9, 2025
1ccb944
fix: value clause
yutaro-sakamoto Jan 9, 2025
eb84448
test: fix pic-n.at and pic-x
yutaro-sakamoto Jan 14, 2025
b504532
fix: typeck.c to suppress checks against inspect statement
yutaro-sakamoto Jan 16, 2025
b291a1a
[WIP] fix: Remove the character encoding specification for 'new String'
kio-watanabe Jan 21, 2025
59f4005
[WIP] fix: Fix the byte size calculation for Japanese variable names.
kio-watanabe Jan 22, 2025
d96bf5d
fix: Fix the code related to the byte size of UTF-8.
kio-watanabe Jan 25, 2025
c1c5635
fix: Fix the code related to the byte size of UTF-8.
kio-watanabe Jan 25, 2025
9bda39b
fix: Fix the code related to the byte size of UTF-8.
kio-watanabe Jan 25, 2025
ee7efb6
fix: Remove unnecessary codes
kio-watanabe Jan 25, 2025
78cdf8d
fix: Minor adjustments related to code generation
kio-watanabe Jan 25, 2025
2d3d847
fix: Fix the code generation for strings that are SJIS multibyte.
kio-watanabe Jan 25, 2025
f06772e
fix: Fix Fix the bug about MOVE of literals when UTF-8
kio-watanabe Jan 25, 2025
46adfd3
fix: Remove unnecessary comments.
kio-watanabe Jan 25, 2025
11e17ad
fix: Fix regarding UTF8 multi byte strings
kio-watanabe Jan 28, 2025
9afcd5e
fix: Fix regarding UTF8 multi byte strings
kio-watanabe Jan 29, 2025
c13e287
Merge branch 'cobol-utf8-2' of github.com:kio-watanabe/opensourcecobo…
kio-watanabe Jan 29, 2025
147183a
fix: Fix regarding PROGRAM-ID written in UTF8 multibyte
kio-watanabe Jan 29, 2025
0371a5e
fix: Fix test scripts
kio-watanabe Jan 29, 2025
ada8a40
fix: Clean up codes
kio-watanabe Jan 29, 2025
3555447
Clean up codes
kio-watanabe Jan 29, 2025
b6bec64
fix: Clean up codes
kio-watanabe Jan 29, 2025
002d77b
fix: Minor fix
kio-watanabe Jan 29, 2025
6a9cc11
fix: fieldToString
ytr-sakamoto Jan 29, 2025
d286283
ci: install wget in alma and amazon linux
ytr-sakamoto Jan 29, 2025
943780f
fix: Fix a bug regarding PROGRAM-ID with multibyte chars
kio-watanabe Jan 30, 2025
edcd682
Merge pull request #5 from yutaro-sakamoto/cobol-utf8-watanabe-new2
kio-watanabe Jan 30, 2025
e7d764d
Fix: Convert cb_zero_utf8 to cb_zen_zero
kio-watanabe Jan 30, 2025
0f938e6
Merge branch 'cobol-utf8-2' of github.com:kio-watanabe/opensourcecobo…
kio-watanabe Jan 30, 2025
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
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
os:
required: true
type: string
configure-args:
required: false
type: string
default: ""

permissions:
contents: read
Expand All @@ -32,26 +36,27 @@ jobs:
if: inputs.os == 'ubuntu:24.04'
run: |
apt-get update -y
apt-get install -y build-essential gettext autoconf
apt-get install -y build-essential gettext autoconf bison flex

- name: Install dependencies on AlmaLinux 9
if: inputs.os == 'almalinux:9'
run: |
dnf -y update
dnf install -y gcc make autoconf diffutils gettext
dnf install -y gcc make autoconf diffutils gettext bison flex

- name: Install dependencies on Amazon Linux 2023
if: inputs.os == 'amazonlinux:2023'
run: |
dnf -y update
dnf install -y java-21-amazon-corretto-devel gcc make autoconf diffutils gettext tar gzip
dnf install -y java-21-amazon-corretto-devel gcc make autoconf diffutils gettext tar gzip bison flex

- name: Checkout opensource COBOL 4J
uses: actions/checkout@v4

- name: Install opensource COBOL 4J
run: |
./configure --prefix=/usr/ CFLAGS=-Werror
./configure --prefix=/usr/ CFLAGS=-Werror ${{ inputs.configure-args }}
touch cobj/*.m4
make
echo "ARTIFACT_NAME=${{ inputs.os }}" | sed 's/:/-/g' >> "$GITHUB_ENV"

Expand All @@ -64,5 +69,5 @@ jobs:
- name: Upload an artifact
uses: actions/upload-artifact@v4
with:
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}-opt_${{ inputs.configure-args }}
path: opensourcecobol4j.tar.gz
46 changes: 46 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ jobs:
with:
os: ${{ matrix.os }}

build-utf8:
needs: check-workflows
strategy:
matrix:
os: ["ubuntu:24.04", "almalinux:9", "amazonlinux:2023"]
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
configure-args: --enable-utf8

run-test-other:
needs: build
strategy:
Expand All @@ -49,6 +59,28 @@ jobs:
test-name: ${{ matrix.test_name }}
os: ${{ matrix.os }}

run-test-other-utf8:
needs: build-utf8
strategy:
fail-fast: false
matrix:
test_name:
- "command-line-options"
- "data-rep"
- "cobol_utf8"
#- "i18n_utf8"
- "jp-compat"
- "run"
- "syntax"
- "cobj-idx"
#- "misc"
os: ["ubuntu:24.04", "almalinux:9", "amazonlinux:2023"]
uses: ./.github/workflows/test-other.yml
with:
test-name: ${{ matrix.test_name }}
os: ${{ matrix.os }}
configure-args: --enable-utf8

run-test-cobj-api:
needs: build
strategy:
Expand All @@ -70,6 +102,20 @@ jobs:
check-result: true
os: ${{ matrix.os }}

run-test-nist-utf8:
needs: build-utf8
strategy:
fail-fast: false
matrix:
test_name: ["IC", "IF", "IX", "NC", "OB", "RL", "SG", "SM", "SQ", "ST"]
os: ["ubuntu:24.04", "almalinux:9", "amazonlinux:2023"]
uses: ./.github/workflows/test-nist.yml
with:
test-name: ${{ matrix.test_name }}
check-result: true
os: ${{ matrix.os }}
configure-args: --enable-utf8

run-test-nist-extra:
needs: build
strategy:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,20 @@ jobs:
with:
os: ${{ matrix.os }}

build-utf8:
needs: check-workflows
strategy:
matrix:
os: ["ubuntu:24.04"]
uses: ./.github/workflows/build.yml
with:
os: ${{ matrix.os }}
configure-args: --enable-utf8

run-test-other:
needs: build
strategy:
fail-fast: false
matrix:
test_name:
- "command-line-options"
Expand All @@ -47,6 +58,28 @@ jobs:
with:
test-name: ${{ matrix.test_name }}
os: ${{ matrix.os }}

run-test-other-utf8:
needs: build-utf8
strategy:
fail-fast: false
matrix:
test_name:
- "command-line-options"
- "data-rep"
- "cobol_utf8"
#- "i18n_utf8"
- "jp-compat"
- "run"
- "syntax"
- "cobj-idx"
#- "misc"
os: ["ubuntu:24.04"]
uses: ./.github/workflows/test-other.yml
with:
test-name: ${{ matrix.test_name }}
os: ${{ matrix.os }}
configure-args: --enable-utf8

run-test-cobj-api:
needs: build
Expand All @@ -60,6 +93,20 @@ jobs:
run-test-nist:
needs: build
strategy:
fail-fast: false
matrix:
test_name: ["IC", "IF", "IX", "NC", "OB", "RL", "SG", "SM", "SQ", "ST"]
os: ["ubuntu:24.04"]
uses: ./.github/workflows/test-nist.yml
with:
test-name: ${{ matrix.test_name }}
check-result: true
os: ${{ matrix.os }}

run-test-nist-utf8:
needs: build-utf8
strategy:
fail-fast: false
matrix:
test_name: ["IC", "IF", "IX", "NC", "OB", "RL", "SG", "SM", "SQ", "ST"]
os: ["ubuntu:24.04"]
Expand All @@ -68,6 +115,7 @@ jobs:
test-name: ${{ matrix.test_name }}
check-result: true
os: ${{ matrix.os }}
configure-args: --enable-utf8

run-test-nist-extra:
needs: build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-cobj-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
os:
required: true
type: string
configure-args:
required: false
type: string
default: ""

permissions:
contents: read
Expand All @@ -24,7 +28,7 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}-opt_${{ inputs.configure-args }}

- uses: actions/setup-java@v4
if: inputs.os != 'amazonlinux:2023'
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test-nist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
os:
required: true
type: string
configure-args:
required: false
type: string
default: ""

permissions:
contents: read
Expand All @@ -30,7 +34,7 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}-opt_${{ inputs.configure-args }}

- name: Install Java
uses: actions/setup-java@v4
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/test-other.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
os:
required: true
type: string
configure-args:
required: false
type: string
default: ""

permissions:
contents: read
Expand All @@ -27,7 +31,7 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}
name: opensourcecobol4j-${{ env.ARTIFACT_NAME }}-opt_${{ inputs.configure-args }}

- uses: actions/setup-java@v4
if: inputs.os != 'amazonlinux:2023'
Expand All @@ -39,19 +43,29 @@ jobs:
if: inputs.os == 'ubuntu:24.04'
run: |
apt-get update -y
apt-get install -y build-essential unzip
apt-get install -y build-essential unzip nkf

- name: Install dependencies on AlmaLinux 9
if: inputs.os == 'almalinux:9'
run: |
dnf -y update
dnf install -y gcc make diffutils glibc-gconv-extra unzip
dnf install -y gcc make diffutils glibc-gconv-extra unzip wget
wget "http://sourceforge.jp/frs/redir.php?m=jaist&f=%2Fnkf%2F59912%2Fnkf-2.1.3.tar.gz" -O nkf-2.1.3.tar.gz --no-check-certificate
tar zxf nkf-2.1.3.tar.gz
cd nkf-2.1.3
make
make install

- name: Install dependencies on Amazon Linux 2023
if: inputs.os == 'amazonlinux:2023'
run: |
dnf -y update
dnf install -y gcc make diffutils tar gzip unzip
dnf install -y gcc make diffutils tar gzip unzip wget
wget "http://sourceforge.jp/frs/redir.php?m=jaist&f=%2Fnkf%2F59912%2Fnkf-2.1.3.tar.gz" -O nkf-2.1.3.tar.gz --no-check-certificate
tar zxf nkf-2.1.3.tar.gz
cd nkf-2.1.3
make
make install

- name: Install Java
if: inputs.os == 'amazonlinux:2023'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ tests/command-line-options
tests/data-rep
tests/i18n_sjis
tests/i18n_utf8
tests/cobol_utf8
tests/jp-compat
tests/cobj-idx
tests/misc
Expand Down
52 changes: 48 additions & 4 deletions cobj/cobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ static const struct option long_options[] = {
#undef CB_WARNDEF
{NULL, 0, NULL, 0}};

#ifdef I18N_UTF8
static const char *JAVAC_ENCODING = "UTF-8";
#else
static const char *JAVAC_ENCODING = "SJIS";
#endif

static const char *cob_cc; /* gcc */
static char cob_java_flags[COB_SMALL_BUFF]; /* -I... */
static char cob_libs[COB_MEDIUM_BUFF]; /* -L... -lcob */
Expand Down Expand Up @@ -664,6 +670,43 @@ void sjis_spc_to_ascii(char *str) {
}
#endif /*I18N_UTF8*/

#ifdef I18N_UTF8
size_t utf8_calc_sjis_size(const unsigned char *p, int len) {
const unsigned char *ub = p + len;
int char_size = 0;
size_t name_size = 0;
while (p < ub) {
char_size = COB_U8BYTE_1(*p);
if (char_size == 1) {
name_size += 1;
p++;
} else if (char_size == 3 && utf8_hankaku_kana(p)) {
name_size += 1;
p += char_size;
} else {
name_size += 2;
p += char_size;
}
}
return name_size;
}

int utf8_hankaku_kana(const unsigned char *p) {
if (p[0] == 0xef) {
if (p[1] == 0xbd) {
if (p[2] >= 0xa1 && p[2] <= 0xbf) {
return 1;
}
} else if (p[1] == 0xbe) {
if (p[2] >= 0x80 && p[2] <= 0x9f) {
return 1;
}
}
}
return 0;
}
#endif /*I18N_UTF8*/

/*
* Local functions
*/
Expand Down Expand Up @@ -1772,8 +1815,9 @@ static int process_compile(struct filename *fn) {

char **program_id;
for (program_id = program_id_list; *program_id; ++program_id) {
snprintf(buff, COB_MEDIUM_BUFF, "javac %s -encoding SJIS -d %s %s/%s.java",
cob_java_flags, output_name_a, java_source_dir_a, *program_id);
snprintf(buff, COB_MEDIUM_BUFF, "javac %s -encoding %s -d %s %s/%s.java",
cob_java_flags, JAVAC_ENCODING, output_name_a, java_source_dir_a,
*program_id);
ret = process(buff);

if (ret) {
Expand Down Expand Up @@ -2044,8 +2088,8 @@ static int process_build_single_jar() {
#else
char remove_cmd[] = "rm -f";
#endif
sprintf(buff, "javac %s -encoding SJIS -d %s %s/*.java", cob_java_flags,
output_name_a, java_source_dir_a);
sprintf(buff, "javac %s -encoding %s -d %s %s/*.java", cob_java_flags,
JAVAC_ENCODING, output_name_a, java_source_dir_a);

ret = process(buff);
if (ret) {
Expand Down
2 changes: 2 additions & 0 deletions cobj/cobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ extern size_t utf8_strlen(const unsigned char *p);
extern int utf8_casecmp(const char *s1, const char *s2);
extern void utf8_spc_to_ascii(char *);
extern int utf8_national_length(const unsigned char *str, int len);
extern size_t utf8_calc_sjis_size(const unsigned char *data, int len);
extern int utf8_hankaku_kana(const unsigned char *data);
#else /*!I18N_UTF8*/
extern const unsigned char *sjis_pick(const unsigned char *);
extern size_t sjis_strlen(const unsigned char *);
Expand Down
Loading