From 60d7067110d778731018eba975b536f4f0cd27f9 Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Thu, 30 Oct 2025 07:25:11 +0000 Subject: [PATCH 1/3] fix: PRGRAM-STATUS --- cobj/codegen.c | 24 +++++++++++++++++++++--- tests/jp-compat.src/spl-registers.at | 1 - 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cobj/codegen.c b/cobj/codegen.c index 8770cc13..af92276a 100644 --- a/cobj/codegen.c +++ b/cobj/codegen.c @@ -5545,10 +5545,18 @@ static void joutput_declare_member_variables(struct cb_program *prog, joutput_prefix(); joutput("/* PROGRAM-ID : %s */\n", prevprog); joutput_prefix(); - joutput("private CobolDataStorage %s;", base_name, blp->f->memory_size); + if (strcmp(blp->f->name, "RETURN-CODE") == 0) { + joutput("public CobolDataStorage %s;", base_name); + } else { + joutput("private CobolDataStorage %s;", base_name); + } } else { joutput_prefix(); - joutput("private CobolDataStorage %s;", base_name, blp->f->memory_size); + if (strcmp(blp->f->name, "RETURN-CODE") == 0) { + joutput("public CobolDataStorage %s;", base_name); + } else { + joutput("private CobolDataStorage %s;", base_name); + } } free(base_name); joutput("\t/* %s */\n", blp->f->name); @@ -6237,8 +6245,18 @@ void codegen(struct cb_program *prog, const int nested, char **program_id_list, //} joutput_line("CobolDecimal.cobInitNumeric();"); - joutput_line("new %s().%s_(0);", prog->program_id, prog->program_id); + if (cb_enable_program_status_register) { + joutput_line("%s $module$ = new %s();", prog->program_id, prog->program_id); + joutput_line("$module$.%s_(0);", prog->program_id); + } else { + joutput_line("new %s().%s_(0);", prog->program_id, prog->program_id); + } joutput_line("CobolStopRunException.stopRun();"); + + if (cb_enable_program_status_register) { + joutput_line("System.exit($module$.b_RETURN_CODE.intValue());"); + } + joutput_indent_level -= 2; joutput_line("}\n"); diff --git a/tests/jp-compat.src/spl-registers.at b/tests/jp-compat.src/spl-registers.at index 27327097..602ba436 100644 --- a/tests/jp-compat.src/spl-registers.at +++ b/tests/jp-compat.src/spl-registers.at @@ -1,5 +1,4 @@ AT_SETUP([PROGRAM-STATUS]) -AT_CHECK([${SKIP_TEST}]) AT_DATA([prog.cob], [ IDENTIFICATION DIVISION. From acad4c7251886835c92910065255ee314f0ef91d Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Thu, 30 Oct 2025 08:14:46 +0000 Subject: [PATCH 2/3] test: fix the test of COB_DATE func --- tests/jp-compat.src/job-date.at | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/jp-compat.src/job-date.at b/tests/jp-compat.src/job-date.at index a0f2026d..bf5a69c7 100644 --- a/tests/jp-compat.src/job-date.at +++ b/tests/jp-compat.src/job-date.at @@ -240,7 +240,7 @@ AT_DATA([prog.cob], [ ]) AT_CHECK([${COMPILE_JP_COMPAT} prog.cob]) -AT_CHECK([COB_DATE=`date +%Y/%m/%d` java prog], [0], [0 +AT_CHECK([COB_DATE=`date +%Y/%m/%d` java prog || true], [0], [0 ]) AT_CLEANUP From 355ae92d9ec1b637270ec5205b3ea181411a93cd Mon Sep 17 00:00:00 2001 From: Yutaro Sakamoto Date: Thu, 30 Oct 2025 23:54:23 +0900 Subject: [PATCH 3/3] refactor: simplify codegen.c --- cobj/codegen.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/cobj/codegen.c b/cobj/codegen.c index af92276a..cb220af8 100644 --- a/cobj/codegen.c +++ b/cobj/codegen.c @@ -5544,19 +5544,12 @@ static void joutput_declare_member_variables(struct cb_program *prog, prevprog = blp->curr_prog; joutput_prefix(); joutput("/* PROGRAM-ID : %s */\n", prevprog); - joutput_prefix(); - if (strcmp(blp->f->name, "RETURN-CODE") == 0) { - joutput("public CobolDataStorage %s;", base_name); - } else { - joutput("private CobolDataStorage %s;", base_name); - } + } + joutput_prefix(); + if (strcmp(blp->f->name, "RETURN-CODE") == 0) { + joutput("public CobolDataStorage %s;", base_name); } else { - joutput_prefix(); - if (strcmp(blp->f->name, "RETURN-CODE") == 0) { - joutput("public CobolDataStorage %s;", base_name); - } else { - joutput("private CobolDataStorage %s;", base_name); - } + joutput("private CobolDataStorage %s;", base_name); } free(base_name); joutput("\t/* %s */\n", blp->f->name);