Skip to content

Commit 7101a8f

Browse files
committed
Merge pull request #27 from opensourcecobol/bugfixFileHandler
ファイルハンドラ呼び出しのバグ修正
2 parents dae244a + 0159da8 commit 7101a8f

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

libcob/fileio.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,29 +4119,41 @@ cob_invoke_fun (int operate, char *f, cob_field *key, char *rec,
41194119
char ret = '0';
41204120
char oper[OPENMODESIZE];
41214121
char excpcode[EXCPTCODESIZE];
4122+
char *p_excpcode = excpcode;
4123+
char tmpfnstatus[2];
4124+
char *p_tmpfnstatus = tmpfnstatus;
4125+
int status1 = 0;
41224126
int (*funcint)();
41234127

41244128
sprintf (excpcode, "%05d", 0);
41254129
sprintf (oper, "%02d", operate);
4130+
sprintf (tmpfnstatus, "%02d", 0);
41264131
s = getenv (TIS_DEFINE_USERFH);
41274132
if (s != NULL) {
41284133
strcpy (funname, s);
41294134
funcint = cob_resolve_1 (funname);
41304135
if (funcint) {
41314136
if (fnstatus == NULL) {
4132-
funcint (oper, f, key, rec, NULL, openMode,
4133-
startCond, read_opts, &excpcode, (char*)&ret);
4137+
funcint (oper, f, key, rec, &p_tmpfnstatus, openMode,
4138+
startCond, read_opts, &p_excpcode, (char*)&ret);
41344139
} else {
41354140
funcint (oper, f, key, rec, fnstatus->data, openMode,
4136-
startCond, read_opts, &excpcode, (char*)&ret);
4141+
startCond, read_opts, &p_excpcode, (char*)&ret);
41374142
}
41384143
if (ret == '1') {
41394144
iRet = 1;
41404145
} else if (ret == '0') {
41414146
iRet = 0;
41424147
}
4143-
if (excpcode != NULL) {
4144-
cob_exception_code = atoi (excpcode);
4148+
cob_exception_code = atoi (p_excpcode);
4149+
//ascii [0]->0x30 [9]->0x39
4150+
if (fnstatus != NULL) {
4151+
status1 = fnstatus->data[0] - 0x30;
4152+
} else {
4153+
status1 = p_tmpfnstatus[0] - 0x30;
4154+
}
4155+
if ((status1 > 0 && status1 <= 9) && cob_exception_code == 0) {
4156+
cob_set_exception (status_exception[status1]);
41454157
}
41464158
}
41474159
}

0 commit comments

Comments
 (0)