Skip to content

Commit a20956e

Browse files
Fix program status (#735)
* fix: PRGRAM-STATUS * test: fix the test of COB_DATE func * refactor: simplify codegen.c
1 parent 6499742 commit a20956e

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

cobj/codegen.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5544,11 +5544,12 @@ static void joutput_declare_member_variables(struct cb_program *prog,
55445544
prevprog = blp->curr_prog;
55455545
joutput_prefix();
55465546
joutput("/* PROGRAM-ID : %s */\n", prevprog);
5547-
joutput_prefix();
5548-
joutput("private CobolDataStorage %s;", base_name, blp->f->memory_size);
5547+
}
5548+
joutput_prefix();
5549+
if (strcmp(blp->f->name, "RETURN-CODE") == 0) {
5550+
joutput("public CobolDataStorage %s;", base_name);
55495551
} else {
5550-
joutput_prefix();
5551-
joutput("private CobolDataStorage %s;", base_name, blp->f->memory_size);
5552+
joutput("private CobolDataStorage %s;", base_name);
55525553
}
55535554
free(base_name);
55545555
joutput("\t/* %s */\n", blp->f->name);
@@ -6237,8 +6238,18 @@ void codegen(struct cb_program *prog, const int nested, char **program_id_list,
62376238
//}
62386239

62396240
joutput_line("CobolDecimal.cobInitNumeric();");
6240-
joutput_line("new %s().%s_(0);", prog->program_id, prog->program_id);
6241+
if (cb_enable_program_status_register) {
6242+
joutput_line("%s $module$ = new %s();", prog->program_id, prog->program_id);
6243+
joutput_line("$module$.%s_(0);", prog->program_id);
6244+
} else {
6245+
joutput_line("new %s().%s_(0);", prog->program_id, prog->program_id);
6246+
}
62416247
joutput_line("CobolStopRunException.stopRun();");
6248+
6249+
if (cb_enable_program_status_register) {
6250+
joutput_line("System.exit($module$.b_RETURN_CODE.intValue());");
6251+
}
6252+
62426253
joutput_indent_level -= 2;
62436254
joutput_line("}\n");
62446255

tests/jp-compat.src/job-date.at

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ AT_DATA([prog.cob], [
240240
])
241241

242242
AT_CHECK([${COMPILE_JP_COMPAT} prog.cob])
243-
AT_CHECK([COB_DATE=`date +%Y/%m/%d` java prog], [0], [0
243+
AT_CHECK([COB_DATE=`date +%Y/%m/%d` java prog || true], [0], [0
244244
])
245245

246246
AT_CLEANUP

tests/jp-compat.src/spl-registers.at

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
AT_SETUP([PROGRAM-STATUS])
2-
AT_CHECK([${SKIP_TEST}])
32

43
AT_DATA([prog.cob], [
54
IDENTIFICATION DIVISION.

0 commit comments

Comments
 (0)