Skip to content

Commit 819c427

Browse files
committed
ファイルハンドラ呼び出しのバグ修正
* EXCEPTION_CODEの引き渡しが不正だったため修正 * INVALIDチェック等で必要な内部コードを自動で設定するよう修正 * ファイルステータスが指定されていない場合でもINVALIDチェックができるよう修正
1 parent 38331ec commit 819c427

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
@@ -4107,29 +4107,41 @@ cob_invoke_fun (int operate, char *f, cob_field *key, char *rec,
41074107
char ret = '0';
41084108
char oper[OPENMODESIZE];
41094109
char excpcode[EXCPTCODESIZE];
4110+
char *p_excpcode = excpcode;
4111+
char tmpfnstatus[2];
4112+
char *p_tmpfnstatus = tmpfnstatus;
4113+
int status1 = 0;
41104114
int (*funcint)();
41114115

41124116
sprintf (excpcode, "%05d", 0);
41134117
sprintf (oper, "%02d", operate);
4118+
sprintf (tmpfnstatus, "%02d", 0);
41144119
s = getenv (TIS_DEFINE_USERFH);
41154120
if (s != NULL) {
41164121
strcpy (funname, s);
41174122
funcint = cob_resolve_1 (funname);
41184123
if (funcint) {
41194124
if (fnstatus == NULL) {
4120-
funcint (oper, f, key, rec, NULL, openMode,
4121-
startCond, read_opts, &excpcode, (char*)&ret);
4125+
funcint (oper, f, key, rec, &p_tmpfnstatus, openMode,
4126+
startCond, read_opts, &p_excpcode, (char*)&ret);
41224127
} else {
41234128
funcint (oper, f, key, rec, fnstatus->data, openMode,
4124-
startCond, read_opts, &excpcode, (char*)&ret);
4129+
startCond, read_opts, &p_excpcode, (char*)&ret);
41254130
}
41264131
if (ret == '1') {
41274132
iRet = 1;
41284133
} else if (ret == '0') {
41294134
iRet = 0;
41304135
}
4131-
if (excpcode != NULL) {
4132-
cob_exception_code = atoi (excpcode);
4136+
cob_exception_code = atoi(p_excpcode);
4137+
//ascii [0]->0x30 [9]->0x39
4138+
if(fnstatus != NULL){
4139+
status1 = fnstatus->data[0] - 0x30;
4140+
}else{
4141+
status1 = p_tmpfnstatus[0] - 0x30;
4142+
}
4143+
if ((status1 > 0 && status1 <= 9) && cob_exception_code == 0){
4144+
cob_set_exception(status_exception[status1]);
41334145
}
41344146
}
41354147
}

0 commit comments

Comments
 (0)