static char sccsid[]="%Z% %M% %I% %E% %U%";
/********************************************************************/
/*	<clprproc.c>													*/
/*		Proc process												*/
/********************************************************************/
#include "colmn.h"
extern condList CLcList;

/************************************/
/*	_chk_var_name					*/
/************************************/
static int _chk_var_name(name,len)
char *name;
int len;
{
	return cl_def_chk_name(name,len,"cl_process_proc",FORMAT(441));
}
#if 1	/* 2021.7.22 */
/************************************/
/*	_ProcClearVar					*/
/************************************/
static int _proc_clear_var(proc)
ProcCT  *proc;
{
	int scope;
	ScrPrCT *scrct;
	Leaf *topleaf;

	if (!(scrct=cl_search_src_ct())) return 0;
/*
printf("_proc_clear_var: varnam=[%s]\n",varnam);
*/
	scope = /*D_AUX1_GLOBAL_VAR | D_AUX1_PUBLIC_VAR | D_AUX1_PRIVATE_VAR | */D_AUX1_LOCAL_VAR;
	if (!strcmp(proc->ProcNM,"main")) scope |= D_AUX1_PRIVATE_VAR;
	topleaf = proc->ProcTop->leftleaf;
	return cl_gx_clear_var_obj2(topleaf,NULL,NULL,proc->Obj,scope);
}
#endif
/************************************/
/*	_chk_pname						*/
/************************************/
static int _chk_pname(iob0,obj,da,max_pas,tbl_pas)
int iob0,obj[],max_pas;
char *da[];
tdtInfoParm ***tbl_pas;
{
	tdtInfoParm *pInfoParm;
	int i,npa,ipa,ida,rc,iob;
	char *pnam;

	if (!obj || !da || !tbl_pas) return -1;
	rc = 0;
	for (i=1;i<=max_pas;i++) {
		if (pInfoParm = cl_get_var_ent(tbl_pas,i)) {
			if (pInfoParm->pi_id == D_DATA_ID_PNAME) {
				pnam = pInfoParm->pi_paux;
/*
printf("_chk_pname: i=%d pnam=[%s]\n",i,pnam);
*/
				iob = iob0;
				npa = obj[iob++];
				rc = ECL_SCRIPT_ERROR;
				while (npa-- > 0) {
					ipa = obj[iob++];
					ida = obj[iob++];
/*
printf("_chk_pname: ipa=%d da=[%s]\n",ipa,da[ida]);
*/
					if (!strcmp(pnam,da[ida])) {
						rc = 0;
						break;
					}
					iob += 4;
				}
				if (rc) {
					/* %s: %d 番目に指定の仮引数名[%s]がありません。 */
					ERROROUT3(FORMAT(509),"_chk_pname",i,pnam);
					break;
				}
			}
		}
	}
	return rc;
}

/************************************/
/*	_get_pname_var_ent				*/
/************************************/
static tdtInfoParm *_get_pname_var_ent(name,max_pas,tbl_pas,ippa)
char *name;
int max_pas,*ippa;
tdtInfoParm ***tbl_pas;
{
	tdtInfoParm *pInfoParmC,*pInfoParm;
	int i,ii,ipa;

	if (ippa) ipa = *ippa;
	else ipa=0;
DEBUGOUTL3(151,"_get_pname_var_ent: name=[%s] max_pas=%d ipa=%d",name,max_pas,ipa);
	pInfoParmC = NULL;
	for (i=1,ii=0;;i++) {
		if (pInfoParm = cl_get_var_ent(tbl_pas,i)) {
			if (pInfoParm->pi_id == D_DATA_ID_PNAME) {
				if (name) {
					if (!strcmp(name,pInfoParm->pi_paux)) {
						pInfoParmC = (tdtInfoParm *)pInfoParm->pi_pos;
#if 1	/* 2021.8.11 */
						if (pInfoParmC->pi_id == 'S') pInfoParmC = (tdtInfoParm *)pInfoParmC->pi_pos;
#endif
						break;
					}
				}
			}
			else if (name) {
				if (i > max_pas) break;
			}
			else if (ippa) {
				if (++ii == ipa) {
					pInfoParmC = pInfoParm;
					*ippa = ++ipa;
					break;
				}
			}
		}
	}
	return pInfoParmC;
}

/************************************/
/*	cl_process_proc					*/
/* function; check command of this  */
/*          leaf then call functions*/
/************************************/
int cl_process_proc(leaf, proc)
Leaf   *leaf;
ProcCT *proc;
{
	static char *_fn_="cl_process_proc";
	static char *sep=" \t,()='";
	static char *attr_sep=" \t()[],'=";
	int   rc,nparm,len,atr,per_flg,ipa,ix,*pSize,max_pas,iMAIN,iParm[4],cmnd,*index;
	int   sp_save,is,kk_level,lenw,line_len,iSET,atr1,lend;
	parmList *prmp[4],qprmp[4],**cmd_prmp,*parmp;
	char  buf[512],w[16],*name,wrk0[256],c,c0,*pp,*line,*dflt,*wrk,*p;
	SSPL_S ssp;
	tdtInfoParm	*pInfoParmC,*pInfoParmW,tInfoParm,*pInfoParmT;
	tdtInfoParm ***tbl_pas,***tbl_vnm;
	GXObject *pbxObj;
	XHASHB *pha_vnm;
	tdtArrayIndex *pIndex;
	int i,npr,npa,inpa,iob,ida,ipr,*obj,*jParm,iPNAME,iPN;
	char **da;
	CMDObject *cmdobj;
	parmList pList;

	if (!leaf || !proc) return ECL_SYSTEM_ERROR;

	/* このノード(leaf)が実行しようとしているproc/funcでないとき
	  (実行しようとしているproc/func内のproc/funcのとき)は、スキップする */
	if (proc->ProcTop != leaf) {
		proc->Nextleaf = leaf->rightleaf;
		return 0;
	}

#ifdef CMDOBJECT
	cmdobj = leaf->cmd.cmdobj;
/*	cmdobj->cid = leaf->cmd.cid;	*/
#endif

	if (!(proc->Nextleaf=leaf->leftleaf)) {
		if ((cmnd=leaf->cmd.cid) == C_PROC) name = FORMAT(114);	/* 手続き */
		else if (cmnd == C_FUNCTION) name = FORMAT(115);	/* 関数 */
		else name = FORMAT(120);	/* クラス */
		ERROROUT2(FORMAT(501),_fn_,name);	/* %s: %s内に文がありません。 */
		return ECL_SCRIPT_ERROR;
	}

	if (rc=cl_mk_pr_var_set(proc)) return rc;

	pha_vnm = proc->pha_vnam;
	tbl_vnm = proc->pTBL_vnam;

	nparm = leaf->cmd.prmnum;
	cmd_prmp = leaf->cmd.prmp;
	iMAIN = 0;
	if ((cmnd=leaf->cmd.cid) == C_FUNCTION) {
		pInfoParmC = proc->Retval;
DEBUGOUT_InfoParm(161,"cl_process_proc: name=[%s]",pInfoParmC,proc->ProcNM,0);
		if (pInfoParmT=(tdtInfoParm *)pInfoParmC->pi_paux) {
			if ((c=pInfoParmT->pi_id)=='I' || c=='T') {
				if ((ix=cl_gx_chk_vnam('s',pha_vnm,"My",2)) <= 0) {
					/* %s: %sのエントリ用の空きがありません。rc=%d */
					ERROROUT3(FORMAT(502),_fn_,"My",ix);
					return ECL_SCRIPT_ERROR;
				}
				pInfoParmW = cl_get_var_ent(tbl_vnm,ix);
#if 1	/* 2021.10.27 */
				if (cl_gx_rep_info_als(pInfoParmW,pInfoParmT,1)) return -1;
#else
				if (cl_gx_rep_info_set(pInfoParmW,pInfoParmT,1)) return -1;
#endif
DEBUGOUT_InfoParm(194,"cl_process_proc: name=%s",pInfoParmW,"My",0);
			}
		}
	}
	else if (cmnd==C_PROC && !strcmp(proc->ProcNM,"main")) {
		if (rc=cl_prparmset(/*NULL,*/NULL,proc->ProcNM)) return rc;
		iMAIN = 1;
#ifdef CMDOBJECT
		cmdobj->option = iMAIN;
#endif
	}

DEBUGOUTL1(120,"cl_process_proc:1 proc->ProcPath=[%s]",nval1(proc->ProcPath));

	parmp = cmd_prmp[0];

DEBUGOUTL1(120,"cl_process_proc: parmp->bxobj=%08x",parmp->bxobj);

	if (pbxObj=parmp->bxobj) {
		if (p = proc->ProcPath) {
/*
printf("cl_process_proc:2 proc->ProcPath=[%s]\n",p);
*/
			if (*p != '*') p = NULL;
		}
		if (!p) {
			if (pbxObj->da) proc->ProcPath = pbxObj->da[0];

DEBUGOUTL1(120,"cl_process_proc:3 proc->ProcPath=[%s]",nval1(proc->ProcPath));

		}
	}
	_proc_clear_var(proc);	/* proc開始時に、Objのobj0はclearされるが、
							   leafのobj0はclearされないので、これは必要 */
	if (cmnd == C_CLASS) return 0;
	if (nparm <= 1) return 0;

	max_pas = proc->varnam_pasento;
	tbl_pas = proc->pTBL_pasento;
	pSize = (int *)tbl_pas[0];
/*
printf("cl_process_proc: max_pas=%d\n",max_pas);
*/
	iPNAME = 0;
	for (i=1;i<=max_pas;i++) {
		if (pInfoParmC = cl_get_var_ent(tbl_pas,i)) {
DEBUGOUT_InfoParm(151,"cl_process_proc:PNAME: i=%d",pInfoParmC,i,0);
			if (pInfoParmC->pi_id == D_DATA_ID_PNAME) {
				iPNAME = 1;
				break;
			}
		}
	}
#ifdef CMDOBJECT
/*
printf("cl_process_proc: cmdobj->opt=%08x\n",cmdobj->opt);
*/
	if (cmdobj->nobj > 0) {
		if (npr=cmdobj->exobj[1]) goto Exobj;
		return 0;
	}
	cl_im_expand(CLcList.mcat_obj,2,&obj);
	cl_im_expand(CLcList.mcat_da,1,&da);
	npr = npa = 0;
	da[0] = clstrdup(proc->ProcNM,0);
	ida = 1;
	obj[0] = 0;
	obj[1] = 0;
	iob = 2;
#endif
	line = cmd_prmp[1]->prp;
	line_len = cmd_prmp[1]->prmlen;
	memset(&ssp,0,sizeof(SSPL_S));
	wrk0[0] = '$';
	wrk = wrk0 + 1;
	ssp.wd = wrk;
	ssp.wdmax = sizeof(wrk0) - 2;
	pInfoParmW = NULL;
	rc = 0;
	c = ',';
	per_flg = ipa = kk_level = is = atr1 = 0;
	while ((len=akxtgwnsl(line,line_len,&ssp,sep,0x01)) > 0) {
		c0 = c;
		atr = ssp.attr[0];
		c = *wrk;
/*
printf("cl_process_proc: c0=%c sp=%d atr=%d wrk=[%s]\n",c0,ssp.sp,atr,wrk);
printf("                 per_flg=%d kk_level=%d is=%d atr1=%d\n",per_flg,kk_level,is,atr1);
*/
		if (per_flg == 1) {
			if (c == '(') kk_level++;
			else if (c==',' || c==')') {
				iSET = 0;
				if (c == ')') {
					if (--kk_level < 0) break;
					else if (!kk_level) {
						per_flg = 2;
						if (atr1) iSET = 1;
						else ipa++;
					}
				}
				else {	/* ',' */
					if (kk_level == 1) {
						if (atr1) iSET = 1;
						else {
							ipa++;
							is = ssp.sp;
						}
					}
				}
				if (iSET) {
					atr1 = 0;
					ipa++;
/*
printf("cl_process_proc: set param. ipa=%d\n",ipa);
*/
						sp_save = ssp.sp;
						lenw = ssp.sp - is -1;
						pp = line + is;
						ssp.sp = 0;
						if (rc=cl_get_def_attr_SSP_opt(pp,lenw,&ssp,attr_sep,iParm,0x05,NULL,NULL)) return rc;
/*
printf("cl_process_proc:get_def_attr: sp=%d wrk=[%s]\n",ssp.sp,wrk);
*/
						if (!iParm[0]) ssp.sp = 0;
						if ((len=akxtgwnsl(pp,lenw,&ssp,sep,0x01)) <= 0) {
							/* %s: 仮引数名がありません。 */
							ERROROUT2(FORMAT(500),_fn_,strmem(pp,lenw));
							return ECL_SCRIPT_ERROR;
						}
/*
printf("cl_process_proc:akxtgwnsl: sp=%d wrk=[%s]\n",ssp.sp,wrk);
*/
						name = clstrdup(wrk,0);
#ifdef CMDOBJECT
						npa++;
						cl_im_expand(CLcList.mcat_obj,iob+1,&obj);
						obj[iob++] = ipa;
						obj[iob++] = ida;
						cl_im_expand(CLcList.mcat_da,ida,&da);
						da[ida++] = name;
#endif
						if (rc=_chk_var_name(name,len)) return rc;
						dflt = NULL;
						if (akxtgwnsl(pp,lenw,&ssp,sep,0x01) > 0) {
							c = wrk[0];
							if ((iParm[0] || stricmp(wrk,"AS")) && (c!='=')) {
								/* %s: 仮引数名(%s)の後に余分な文字(%s)があります。 */
								ERROROUT3(FORMAT(504),_fn_,name,wrk);
								return ECL_SCRIPT_ERROR;
							}
							if (c != '=') {
								if (rc=cl_get_def_attr_SSP_opt(pp,lenw,&ssp,attr_sep,iParm,0x09,NULL,NULL)) return rc;
								akxtgwnsl(pp,lenw,&ssp,sep,0x01);
								c = wrk[0];
							}
							if (c) {
								if (c != '=') {
									/* %s: 仮引数(%s)の属性の後に余分な文字(%s)があります。 */
									ERROROUT3(FORMAT(525),_fn_,name,wrk);
									return ECL_SCRIPT_ERROR;
								}
								if ((lend=akxtgwnsl(pp,lenw,&ssp,sep,0x01)) <= 0) {
									/* %s: 仮引数(%s)のデフォルト値がありません。 */
									ERROROUT2(FORMAT(524),_fn_,name);
									return ECL_SCRIPT_ERROR;
								}
								else {
									if (cl_chk_parm(wrk,lend) == NAME_CONST) p = wrk0;
									else p = wrk;
									dflt = clstrdup(p,0);
/*
printf("cl_process_proc: dflt=[%s]\n",dflt);
*/
									if (ssp.attr[0] > 10) {
										/* %s: デフォルト値(%s)が誤っています。 */
										ERROROUT2(FORMAT(538),_fn_,wrk);
										return ECL_SCRIPT_ERROR;
									}
									if (clpeeksl(pp,lenw,&ssp,sep,0x01) > 0) {
										/* %s: デフォルト値の後に余分な文字(%s)があります。 */
										ERROROUT2(FORMAT(539),_fn_,wrk);
										return ECL_SCRIPT_ERROR;
									}
								}
							}
						}
						ssp.sp = sp_save;
						is = ssp.sp;
#ifdef CMDOBJECT
						cl_im_expand(CLcList.mcat_obj,iob+4,&obj);
						memcpy(&obj[iob],iParm,sizeof(int)*4);
						iob += 4;
						cl_im_expand(CLcList.mcat_da,ida,&da);
/*
printf("cl_process_proc: ida=%d\n",ida);
*/
						da[ida++] = dflt;
#endif
				}
#ifdef CMDOBJECT
				if (!kk_level) {
					if (npa) {
						obj[inpa] = npa;
						npr++;
					}
					else iob -= 2;
				}
#endif
			}
			else {
				if (kk_level>1 && !stricmp(wrk,"AS")) {
					/* %s: ＡＳの位置が不正です。 */
					ERROROUT1(FORMAT(526),_fn_);
					return ECL_SCRIPT_ERROR;
				}
				atr1 = 1;
			}
		}
		else {
			if (!stricmp(wrk,"AS")) {
				if (leaf->cmd.cid==C_FUNCTION) {
					if (rc=cl_get_def_attr_SSP_opt(line,line_len,&ssp,attr_sep,iParm,0x09,NULL,NULL)) return rc;
					if (iParm[0] != DEF_ZOK_VARI) {
#ifdef CMDOBJECT
						npr++;
						cl_im_expand(CLcList.mcat_obj,iob+5,&obj);
						obj[iob++] = 4;
						memcpy(&obj[iob],iParm,sizeof(int)*4);
						iob += 4;
#endif
					}
					per_flg = 3;
				}
				else {
					/* %s: 戻り値の属性は、関数以外では指定できません。 */
					ERROROUT1(FORMAT(528),_fn_);
					return ECL_SCRIPT_ERROR;
				}
			}
			else if (per_flg == 2) {
				/* s: [%s]の前にＡＳが必要です。 */
				ERROROUT2(FORMAT(566),_fn_,wrk);
				return ECL_SCRIPT_ERROR;
			}
			else if (per_flg == 3) {
				/* %s: 余分な文字(%s)があります。 */
				ERROROUT2(FORMAT(567),_fn_,wrk);
				return ECL_SCRIPT_ERROR;
			}
			else if (atr <= 6) {
				ipa++;
				if (ipa <= 2) {
					if (rc=_chk_var_name(wrk,len)) return rc;
				}
				else {
					/* %s: 余分な変数(%s)があります。 */
					ERROROUT2(FORMAT(505),_fn_,wrk);
					return ECL_SCRIPT_ERROR;
				}
				if (ipa == 1) {
#ifdef CMDOBJECT
					npr++;
					cl_im_expand(CLcList.mcat_obj,iob+1,&obj);
					obj[iob++] = 1;
					obj[iob++] = ida;
					cl_im_expand(CLcList.mcat_da,ida,&da);
					da[ida++] = clstrdup(wrk,0);
#endif
				}
				else if (ipa == 2) {
#ifdef CMDOBJECT
					npr++;
					cl_im_expand(CLcList.mcat_obj,iob+1,&obj);
					obj[iob++] = 2;
					obj[iob++] = ida;
					cl_im_expand(CLcList.mcat_da,ida,&da);
					da[ida++] = clstrdup(wrk,0);
#endif
				}
			}
			else {
				if (c=='(') {
					per_flg = kk_level = 1;
					ipa = 0;
					is = ssp.sp;
#ifdef CMDOBJECT
					cl_im_expand(CLcList.mcat_obj,iob,&obj);
					obj[iob++] = 3;
					inpa = iob++;
#endif
				}
				else if (c==')') {
					if (--kk_level < 0) break;
				}
				else if (c==',' && c0==',') {
					ipa++;
				}
			}
		}
	}
	if (!rc && kk_level) {
		/* %s: システム・エラー、括弧の対応が取れていません。kk_level=%d */
		ERROROUT2(FORMAT(529),_fn_,kk_level);
		rc = ECL_SCRIPT_ERROR;
	}
#ifdef CMDOBJECT
	if (rc) return rc;
	obj[1] = npr;
/*
	for (i=0;i<iob;i++) printf("obj[%d]=%d\n",i,obj[i]);
	for (i=0;i<ida;i++) printf("da[%d]=[%s]\n",i,da[i]);
*/
	cmdobj->nobj = iob;
	cmdobj->nda = ida;
	cmdobj->exobj = (int *)clmemdup(obj,iob*sizeof(int),0);
	cmdobj->da = (char **)clmemdup(da,ida*sizeof(char *),0);
Exobj:
	obj = cmdobj->exobj;
	da = cmdobj->da;
	npr = obj[1];
	iob = 2;
	while (npr-- > 0) {
		ipr = obj[iob++];
DEBUGOUTL3(120,"%s: npr=%d ipr=%d",_fn_,npr,ipr);
		if (ipr == 1) {
			ida = obj[iob++];
			sprintf(buf,"%s = %d",da[ida],max_pas);
/*
printf("cl_process_proc: ipr=%d buf=[%s]\n",ipr,buf);
*/
			if (rc=cl_set_scalar_var_info(buf,NULL,
			        D_GX_OPT_SET_LOCAL,&pInfoParmW)) break;
		/*	        D_GX_OPT_SET_LOCAL|D_GX_OPT_SET_CONST,&pInfoParmW)) break;	2022.6.24 */
			/* shift local したときに、値が連動するように、pInfoParmCのpi_dataを
			   見るようにする。 */
			pInfoParmC = cl_var_size_parm(pSize);
			*pInfoParmW = *pInfoParmC;
			pInfoParmW->pi_scale &= ~D_DATA_LPOSDATA;
			pInfoParmW->pi_aux[0] = pInfoParmW->pi_attr;
		/*	pInfoParmW->pi_aux[1]|= D_AUX1_PROTECTED;	del 2022.6.24 */
			pInfoParmW->pi_paux   = pInfoParmW->pi_data;	/* ==pInfoParmC->pi_data */
		}
		else if (ipr == 2) {
			ida = obj[iob++];
			name = da[ida];
			if (!(ix=max_pas) || iMAIN) ix = pSize[2];
			sprintf(buf,"%%%s 1 %d",name,ix);
			memset(&qprmp[0],0,sizeof(parmList)*2);
			prmp[0] = &qprmp[0];
#if 1	/* 2021.5.5 */
			qprmp[0].prmlen = strlen(buf);
			qprmp[0].prp = buf;
			qprmp[0].opt = D_GX_OPT_NO_USE_OBJ;
			prmp[0] = &qprmp[0];
#else
			qprmp[1].prmlen = strlen(buf);
			qprmp[1].prp = buf;
			qprmp[1].opt = D_GX_OPT_NO_USE_OBJ;
			prmp[1] = &qprmp[1];
#endif
/*
printf("cl_process_proc: ipr=%d buf=[%s]\n",ipr,buf);
*/
#if 1	/* 2021.5.5 */
			if (rc=cl_pr_ex_def_map_ary(1,prmp,NULL,proc,D_GX_OPT_SET_LOCAL)) break;
#else
			if (rc=cl_pr_ex_def_map_ary(2,prmp,NULL,proc,D_GX_OPT_SET_LOCAL)) break;
#endif
			if (!max_pas && !iMAIN) {
				strcpy(buf+1,name);
#if 1	/* 2021.6.14 */
				qprmp[0].prmlen = strlen(buf);
				if (rc=cl_conv_parm_opt(&qprmp[0],&tInfoParm,D_GX_OPT_SET_LOCAL|D_GX_OPT_SET_ADDR)) break;
#else
				qprmp[1].prmlen = strlen(buf);
				if (rc=cl_conv_parm_opt(&qprmp[1],&tInfoParm,D_GX_OPT_SET_LOCAL|D_GX_OPT_SET_ADDR)) break;
#endif
				if (tInfoParm.pi_id == D_DATA_ID_STOREVAR) {
					if (pInfoParmW = (tdtInfoParm *)tInfoParm.pi_pos) {
						if (pInfoParmW->pi_id=='A' && pInfoParmW->pi_dlen==sizeof(tdtArrayIndex)) {
							pIndex = (tdtArrayIndex *)pInfoParmW->pi_data;
/*
index = pIndex->index;
printf("cl_process_proc: index=%d %d %d %d %d %d\n",
index[0],index[1],index[2],index[3],index[4],index[5]);
*/
							pIndex->index[4] = 0;
						}
					}
				}
			}
		}
		else if (ipr == 3) {
			if (iPNAME) {
				if (rc=_chk_pname(iob,obj,da,max_pas,tbl_pas)) return rc;
			}
			npa = obj[iob++];
			iPN = 1;
			while (npa-- > 0) {
				ipa = obj[iob++];
				ida = obj[iob++];
				name = da[ida++];
				dflt = da[ida];
/*
printf("cl_process_proc: ida=%d dflt=[%s]\n",ida,dflt);
*/
				len = strlen(name);
				if ((ix=cl_gx_chk_vnam('s',pha_vnm,name,len)) <= 0) {
					/* %s: %sのエントリ用の空きがありません。rc=%d */
					ERROROUT3(FORMAT(502),_fn_,name,ix);
					return ECL_SCRIPT_ERROR;
				}
				pInfoParmW = cl_get_var_ent(tbl_vnm,ix);
				jParm = &obj[iob];
				if (jParm[0] && jParm[0]!=DEF_ZOK_VARI) {
					if (rc=cl_set_parm_init(pInfoParmW,jParm,0x01)) {
						/* %s: 仮引数の属性指定(attr=%d size=%d precision=%d scale=%d)が不正です。 */
						ERROROUT5(FORMAT(530),_fn_,jParm[0],jParm[1],jParm[2],jParm[3]);
						return ECL_SCRIPT_ERROR;
					}
				}
				iob += 4;
				if (iPNAME) {
					pInfoParmC = _get_pname_var_ent(name,max_pas,tbl_pas,NULL);
					if (!pInfoParmC) pInfoParmC = _get_pname_var_ent(NULL,max_pas,tbl_pas,&iPN);
				}
				else {
					pInfoParmC = cl_get_var_ent(tbl_pas,ipa);
				}
DEBUGOUT_InfoParm(151,"cl_process_proc:C: ipr=%d",pInfoParmC,ipa,0);
				if (!pInfoParmC) {
					/* "%s: 引数の設定が誤っています。ipa=%d" */
					ERROROUT2(FORMAT(510),_fn_,ipa);
					return ECL_SCRIPT_ERROR;
				}
				if (cl_is_undef_parm(pInfoParmC)) {
					if (dflt) {
						pList.prp = dflt;
						pList.prmlen = strlen(dflt);
						if ((rc=cl_conv_arg(&pList,pInfoParmC)) < 0) return rc;
						rc = 0;
					}
					else cl_null_parm(pInfoParmC);
				}
#if 1	/* 2021.10.27 */
				if (cl_gx_rep_info_als(pInfoParmW,pInfoParmC,1)) {
#else
				if (cl_gx_rep_info_set(pInfoParmW,pInfoParmC,1)) {
#endif
					return ECL_SCRIPT_ERROR;
				}
DEBUGOUT_InfoParm(194,"cl_process_proc:W: name=%s",pInfoParmW,wrk,0);
			}
		}
		else if (ipr == 4) {
			pInfoParmC = proc->Retval;
			jParm = &obj[iob];
			if (rc=cl_set_parm_init(pInfoParmC,jParm,D_GX_OPT_ALC_TMP | 0x01)) {
				/* %s: 返却値の属性指定(attr=%d size=%d precision=%d scale=%d)が不正です。 */
				ERROROUT5(FORMAT(499),_fn_,jParm[0],jParm[1],jParm[2],jParm[3]);
				return ECL_SCRIPT_ERROR;
			}
			iob += 4;
		}
	}
#endif
	return rc;
}

/************************************/
/* cl_process_end_proc              */
/* function; check command of this  */
/*          leaf then call functions*/
/************************************/
int cl_process_end_proc(leaf, proc)
Leaf    *leaf;
ProcCT  *proc;
{
	char *name;
	int cmnd;

	if (leaf == NULL) return(ECL_SYSTEM_ERROR);
	if (proc == NULL) return(ECL_SYSTEM_ERROR);
/*
printf("cl_process_end_proc: proc=%08x name[%s]\n",proc,proc->ProcNM);
*/
	if (!(proc->pFlag & D_PFLAG_CONSTRUCT)) {
		if ((cmnd=leaf->cmd.cid) == C_ENDPROC) name = FORMAT(506);	/* ＥＮＤＰＲＯＣ */
		else if (cmnd == C_ENDFUNC) name = FORMAT(507);	/* ＥＮＤＦＵＮＣ */
		else name=NULL;
				/* %s: %s文に達しました。ＲＥＴＵＲＮします。 */
		if (name) ERROROUT2(FORMAT(508),"cl_process_end_proc",name);
	}
	cmn_set_stat(RET_PR,&proc->ptype,L_ON);
	return 0;
}
