static    char    sccsid[]="%Z% %M% %I% %E% %U%";
/******************************************************************************
*                                                                             *
*      処理目的　　：  代入処理（右辺が変数の時）            　　　           *
*                                                                             *
*      関数名　　　：　int cl_gx_rep_info_set(pInfoParmO,pInfoParmI)          *
*                      (O)tdtInfoParm *pInfoParmO                             *
*                      (I)tdtInfoParm *pInfoParmI                             *
*                                                                             *
*      戻り値　　　：　ERROR                                    　            *
*                      NORMAL                                                 *
*                                                                             *
*      処理概要　　：　                                                       *
*                                                                             *
******************************************************************************/
/*	  error code : -215220101〜-215229999	*/
#include <colmn.h>
extern CLPRTBL CLprocTable;
extern tdtIterate_ctl gtIter_ctl[];

static int _rep_list_info_set();
static int _gx_rep_all_data();
static int _check_exist_mk_key(/*mcat,pInfoParm*/);

#ifdef GET_PARM_RANGE
/****************************************/
/*	01									*/
/****************************************/
static int _val_set_BINA_FLOA(p,atr,size,Val,attr,len,ix)
char *p;
int atr,size,Val[],attr,len,ix;
{
	int rc,iValue;
	char *name,*pV=(char *)Val;
	double dValue;

	name = "_val_set_BINA_FLOA";
	p += size*ix;
	pV += len*ix;
	if (ix) Val++;
	if (attr == DEF_ZOK_BINA) iValue = CL_GET_VAL_BIN(Val);
	else memcpy(&dValue,pV,sizeof(double));
	if (atr == DEF_ZOK_BINA) {
		if (attr == DEF_ZOK_FLOA) iValue = cl_chk_over_flow_d2_i(dValue,name);
		*(int *)p = iValue;
DEBUGOUTL2(151,"%s:BINA:%d",name,*(int *)p);
	}
	else {
		if (attr == DEF_ZOK_BINA) dValue = iValue;
		*(double *)p = dValue;
DEBUGOUTL2(151,"%s:FLOA:%f",name,*(double *)p);
	}
	return 0;
}

/****************************************/
/*	02									*/
/****************************************/
static int _val_set_DECI(pInfoParm,p,size,Val,attr,len,ix)
tdtInfoParm *pInfoParm;
char *p;
int size,Val[],attr,len,ix;
{
	int rc;
	char *pV=(char *)Val;
	double dValue;

	p += size*ix;
	pV += len*ix;
	if (attr == DEF_ZOK_BINA) {
		m_i2mpa(Val[ix],(MPA *)p);
	}
	else if (attr == DEF_ZOK_FLOA) {
		memcpy(&dValue,pV,len);
		m_d2mpa(dValue,(MPA *)p);
	}
	else memcpy(p,pV,len);
	if (pInfoParm->pi_hlen) {
		if ((rc=cl_mpa_scale(p,pInfoParm->pi_hlen,pInfoParm->pi_pos))<0) return rc;
	}
	return 0;
}
#endif
/****************************************/
/*	03									*/
/****************************************/
static char *_set_mem_size_zero(pInfoParm,size,im)
tdtInfoParm *pInfoParm;
int size,im;
{
	char *p;
/*
printf("_set_mem_size_zero: pInfoParm->pi_scale=%02x\n",pInfoParm->pi_scale);
*/
#if 1	/* 2021.10.6 */
	if (im==D_OPT_ALC_MALLOC && pInfoParm->pi_scale & D_DATA_MALLOC)
		p = Realloc(pInfoParm->pi_data,size);
	else p = cl_opt_malloc(im,size);
#else
	if (pInfoParm->pi_scale & D_DATA_MALLOC)
		p = Realloc(pInfoParm->pi_data,size);
	else
		p = cl_tmp_const_malloc(size);
#endif
	pInfoParm->pi_data = p;
	if (p) {
		pInfoParm->pi_data = p;
		pInfoParm->pi_paux = p;
	}
	return p;
}

/****************************************/
/*	04									*/
/****************************************/
static int _gx_rep_val_set(pInfoParm,pInfoParmW,iOpt)
tdtInfoParm *pInfoParm,*pInfoParmW;
int iOpt;
{
	static char *name = "_gx_rep_val_set";
	int *pi,rc,iValue,iRANGE,dlen1,dlen2,dlen,im,iUNSIGNED;
	int  atr,attr,size,iAttr[4],len;
	double dValue,*pd;
	char *p,w1[32],*p1,*pV,c,w2[32],*p2,c1,c2;
	tdtInfoParm tInfoParmW;
	time_t tt;
	long lValue,Valz[NMPA_LONG*2],*Val;
	struct  tm *stm;
	tdtInfoParm tInfoParm;

	p = pInfoParm->pi_paux;
	atr = pInfoParm->pi_aux[0] & ~DEF_ZOK_DATA;
	iUNSIGNED = pInfoParm->pi_scale & D_DATA_UNSIGNED;
/*
printf("%s:Enter atr=%d\n",name,atr);
*/
DEBUGOUTL2(110,"%s:Enter: atr=%d",name,atr);
	c1 = pInfoParm->pi_id;
	c2 = pInfoParmW->pi_id;
/*
printf("%s:Enter c1=[%c] c2=[%c]\n",name,c1,c2);
*/
  if (c1==' ' && c2==' ') {
	Val = cl_get_tmpMPA2(Valz,2);
	im = (iOpt & D_GX_OPT_ALC_MASK)>>12;
	if (!im) im = D_OPT_ALC_MALLOC;
	if (atr > 0) iAttr[0] = D_GX_OPT_USE_ATTR | atr;
	else iAttr[0] = 0;
	len = size = pInfoParm->pi_len;
	iRANGE = pInfoParmW->pi_alen & D_AULN_RANGE_DATA;
#ifdef GET_PARM_RANGE
	if (iRANGE = pInfoParmW->pi_alen & D_AULN_RANGE_DATA) {
		if (size>0 && atr!=DEF_ZOK_BINA) {
			if (atr == DEF_ZOK_CHAR) len++;
			len *= 2;
			p = _set_mem_size_zero(pInfoParm,len);
		}
	}
	pInfoParm->pi_alen |= iRANGE;
	pInfoParm->pi_aux[0] = atr | (pInfoParmW->pi_aux[0] & DEF_ZOK_DATA);
	pV = (char *)Val;
#endif
DEBUGOUTL4(151,"%s: atr=%d pi_paux=%08x pi_len=%d",name,atr,p,size);
#ifdef GET_PARM_RANGE
	if (atr == DEF_ZOK_BINA || atr == DEF_ZOK_FLOA) {
		if ((rc=cl_get_parm_range_double(pInfoParmW,Val,"_gx_rep_val_set.BINA/FLOA",iAttr)) < 0)
			 return rc;
		else if (rc > 0) return ECL_SCRIPT_ERROR;
		if (pInfoParm->pi_scale & 0x80) Free(pInfoParm->pi_data);
		if (rc=_val_set_BINA_FLOA(p,atr,size,Val,iAttr[0],iAttr[1],0)) return rc;
		if (iRANGE) {
			if (rc=_val_set_BINA_FLOA(p,atr,size,Val,iAttr[0],iAttr[1],1)) return rc;
		}
	}
#else
	if (atr == DEF_ZOK_BINA) {
		if (iUNSIGNED)
			rc = cl_get_parm_ulong(pInfoParmW,Val,"_gx_rep_val_set.BINA",iUNSIGNED);
		else
			rc = cl_get_parm_long(pInfoParmW,Val,"_gx_rep_val_set.BINA");
		if (rc < 0) return rc;
		else if (rc > 0) return ECL_SCRIPT_ERROR;
		if (pInfoParm->pi_scale & 0x80) Free(pInfoParm->pi_data);
#if defined(_LP64)	/* 2021.9.6 */
		if (size == sizeof(int)) {
			*(int *)p = Val[0];
DEBUGOUTL2(151,"%s:BINA:%d",name,*(int *)p);
		}
		else {
			*(long *)p = Val[0];
DEBUGOUTL2(151,"%s:BINA:%ld",name,*(long *)p);
		}
#else
		*(long *)p = Val[0];
DEBUGOUTL2(151,"%s:BINA:%d",name,*(long *)p);
#endif
	}
	else if (atr == DEF_ZOK_FLOA) {
		if ((rc=cl_get_parm_double(pInfoParmW,Val,"_gx_rep_val_set.FLOA",iAttr)) < 0)
			 return rc;
		else if (rc > 0) return ECL_SCRIPT_ERROR;
		if (pInfoParm->pi_scale & 0x80) Free(pInfoParm->pi_data);
		memcpy(&dValue,Val,sizeof(double));
		*(double *)p = dValue;
DEBUGOUTL2(151,"%s:FLOA:%f",name,*(double *)p);
	}
#endif
	else if (atr == DEF_ZOK_DECI) {
#ifdef GET_PARM_RANGE
		if ((rc=cl_get_parm_range_mpa(pInfoParmW,Val,"_gx_rep_val_set.DECI",iAttr)) < 0)
			 return rc;
		else if (rc > 0) return ECL_SCRIPT_ERROR;
		if (rc=_val_set_DECI(pInfoParm,p,size,Val,iAttr[0],iAttr[1],0)) return rc;
		if (iRANGE) {
			if (rc=_val_set_DECI(pInfoParm,p,size,Val,iAttr[0],iAttr[1],1)) return rc;
		}
#else
		if ((rc=cl_get_parm_dec(pInfoParmW,Val,"_gx_rep_val_set.DECI",iAttr)) < 0)
			 return rc;
		else if (rc > 0) return ECL_SCRIPT_ERROR;
		memcpy(p,Val,size);
		if (pInfoParm->pi_hlen) {
			if ((rc=cl_mpa_scale(p,pInfoParm->pi_hlen,pInfoParm->pi_pos))<0) return rc;
		}
#endif
	}
	else if (atr == DEF_ZOK_CHAR) {
		p1 = w1;
		if ((rc = parm_to_char(pInfoParmW,&p1,NULL)) < 0) return rc;
		if (iRANGE && size<=0) {
				dlen1 = rc;
				cl_gx_copy_info(&tInfoParmW,pInfoParmW);
				tInfoParmW.pi_aux[0] = tInfoParmW.pi_alen = 0;
				if (tInfoParmW.pi_attr == DEF_ZOK_BINA) tInfoParmW.pi_pos = tInfoParmW.pi_hlen;
				else tInfoParmW.pi_data += tInfoParmW.pi_dlen;
				p2 = w2;
				if ((rc = parm_to_char(&tInfoParmW,&p2,NULL)) < 0) return rc;
				dlen2 = rc;
				if (pInfoParmW->pi_attr == DEF_ZOK_CHAR) dlen = pInfoParmW->pi_dlen;
				else dlen = X_MAX(dlen1,dlen2) + 1;
				if (!(p=_set_mem_size_zero(pInfoParm,dlen*2,im))) return ECL_MALLOC_ERROR;
				memzcpy(p,p1,dlen1);
				memzcpy(p+dlen,p2,dlen2);
DEBUGOUTL3(151,"%s:CHAR RANGE:[%s]..[%s]",name,p,p+dlen);
				pInfoParm->pi_dlen = dlen;
				pInfoParm->pi_alen |= iRANGE;
				pInfoParm->pi_aux[0] |= pInfoParmW->pi_aux[0] & DEF_ZOK_DATA;
		}
		else {
			if (size <= 0) {
				size = rc;
				if (!(p=_set_mem_size_zero(pInfoParm,size+1,im))) return ECL_MALLOC_ERROR;
			}
			pInfoParm->pi_dlen = memnzcpy(p,p1,rc,size+1);
DEBUGOUTL2(151,"%s:CHAR:[%s]",name,p);
		}
	}
	else if (atr == DEF_ZOK_BULK) {
		if (!(p1=_to_bulk(pInfoParmW,iAttr,0))) return iAttr[0];
		if (size <= 0) {
			size = iAttr[1];
			if (!(p=_set_mem_size_zero(pInfoParm,size+sizeof(int),im))) return ECL_MALLOC_ERROR;
		}
		pInfoParm->pi_dlen = rc = X_MIN(iAttr[1],size);
		memcpy(p+size,&rc,sizeof(int));
		memcpy(p,p1,rc);
DEBUGOUTL3(151,"%s:BULK:size=%d len=%d",name,size,rc);
	}
	else if (atr == DEF_ZOK_DATE) {
		if (rc=cl_get_parm_date(pInfoParmW,p,"DATE")) return rc;
DEBUGOUT_InfoParm(151,"cl_get_parm_date: size=%d",pInfoParm,size,0);
	}
  }
  else if (c1 == 'T') {
/*	else if (atr == D_AUX0_TYPE_STRUCT) {	*/
		if (c1 == c2) {
			if ((p1=(char *)pInfoParm->pi_pos) && (p2=(char *)pInfoParmW->pi_pos)) {
				len  = cl_get_struct_name_len(p1);
				size = cl_get_struct_name_len(p2);
				if (!_memcmplen(p1,len,p2,size,0)) {
#if 1	/* 2021.2.26 */
					cl_free_info_parm(pInfoParm);
#endif
					if ((rc=_gx_rep_all_data(pInfoParm,pInfoParmW,NULL)) < 0) return rc;
				}
				else {
							/* %s: 構造体定義名が異なっています。(左辺=%s 右辺=%s) */
					ERROROUT3(FORMAT(614),name,p1,p2);
					return ECL_SCRIPT_ERROR;
				}
			}
			else {
				ERROROUT1(FORMAT(615),name);	/* %s: 構造体定義名を確認できません。*/
				return ECL_SCRIPT_ERROR;
			}
		}
		else {
					/* %s: データＩＤ(id1=%c id2=%c)が合っていません。*/
			ERROROUT3(FORMAT(613),name,c1,c2);
			return ECL_SCRIPT_ERROR;
		}
/*	}	*/
  }
  else {
  		if (c1 == ' ') {
					/* %s: データＩＤ(id1=%c id2=%c)が合っていません。*/
			ERROROUT3(FORMAT(613),name,c1,c2);
		}
		else {
			p = (char *)pInfoParm->pi_pos;
#if 1	/* 2021.8.2 */
					/* %s: %s(%s)への代入はできません。 */
			ERROROUT3(FORMAT(132),name,cl_gx_get_name_from_id(c1),nval1(p));
#else
					/* %s: %sには代入できません。*/
			ERROROUT2(FORMAT(126),name,nval1(p));
#endif
		}
  		return ECL_SCRIPT_ERROR;
  }
	pInfoParm->pi_aux[1] &= ~(D_AUX1_PROTECTED | D_AUX1_HASHED_NAME);
	pInfoParm->pi_alen |= pInfoParmW->pi_alen & D_AULN_FILE_POINTER;
/*
printf("%s:Exit\n",name);
*/
DEBUGOUTL1(110,"%s:Exit",name);
	return 0;
}

/****************************************/
/*	11									*/
/****************************************/
static int _rep_list_copy(pInfoParmO,pInfoParmI,iOpt)
tdtInfoParm *pInfoParmO,*pInfoParmI;
int iOpt;
{
	tdtInfoParm *p,*pInfoParm;
	int rc=0,iCHK;
	tdtRbCtl *pCt,*pCtI;

DEBUGOUTL1(110,"_rep_list_copy:Enter: iOpt=0x%08x",iOpt);

	if (iOpt & D_GX_OPT_ALC_TMP) return _tmp_list_copy(pInfoParmO,pInfoParmI);

	if (!pInfoParmO || !pInfoParmI) return -1;
	if (pInfoParmO == pInfoParmI) return 0;
	if (!(pCt = akxs_rb_new(0,0))) return ECL_MALLOC_ERROR;
	iCHK = iOpt & D_REP_CHK_UNDEF_IN;
	pInfoParmO->pi_data = (char *)pCt;
	pInfoParmO->pi_scale = D_DATA_MALLOC;
	pCtI = (tdtRbCtl *)pInfoParmI->pi_data;
	akxs_rb_read(pCtI,0);
	while (p=(tdtInfoParm *)akxs_rb_read(pCtI,1)) {
		if (iCHK) {
			if (p->pi_id == D_DATA_ID_UNDEFVAR) {
				rc = ECL_NDEFVAR_ERROR;
				break;
			}
		}
		if (!(pInfoParm=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm))))
			return ECL_MALLOC_ERROR;
		rc = _rep_list_info_set(pInfoParm,p,iOpt);
DEBUGOUT_InfoParm(198,"_rep_list_copy: ",pInfoParm,0,0);
		if (!akxs_rb_set_n(pCt,pInfoParm)) return ECL_MALLOC_ERROR;
	}
	return rc;
}

/****************************************/
/*	12									*/
/****************************************/
static int _rep_list_info_set(pInfoParmO,pInfoParmI,iOpt)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt;
{
	char c;
	int rc;

	if (!pInfoParmO || !pInfoParmI) return -1;
	if (pInfoParmO == pInfoParmI) return 0;
	if (pInfoParmI->pi_id == 'S') {
		pInfoParmI = (tdtInfoParm *)pInfoParmI->pi_pos;
	}
	*pInfoParmO = *pInfoParmI;
	if ((c=pInfoParmO->pi_id)==D_DATA_ID_LIST || c==D_DATA_ID_NARABI) {
		if ((rc=_rep_list_copy(pInfoParmO,pInfoParmI,iOpt)) < 0) return rc;
	}
	else {
		if (rc=cl_gx_rep_info_copy_data(pInfoParmO,pInfoParmI,iOpt & 0x03)) return rc;
	}
	return 0;
}

/****************************************/
/*	16									*/
/****************************************/
int cl_gx_rep_val_set(pInfoParmO,pInfoParmI,iOpt)
tdtInfoParm *pInfoParmO,*pInfoParmI;
int iOpt;
{
	int ret,aux0,len;
	char *paux;
	tdtInfoParm tInfoParm,*pInfoParm;

DEBUGOUT_InfoParm(120,"cl_gx_rep_val_set: pInfoParmO=",pInfoParmO,0,0);
DEBUGOUT_InfoParm(120,"cl_gx_rep_val_set: pInfoParmI=",pInfoParmI,0,0);
	if (pInfoParmO->pi_paux && (pInfoParmO->pi_aux[0] & ~DEF_ZOK_DATA)) {
		ret = _gx_rep_val_set(pInfoParmO,pInfoParmI,iOpt);
	}
	else {
		tInfoParm = *pInfoParmO;
		len  = tInfoParm.pi_len;
		paux = tInfoParm.pi_paux;
		aux0 = tInfoParm.pi_aux[0];
		tInfoParm.pi_paux   = tInfoParm.pi_data;
		tInfoParm.pi_aux[0] = tInfoParm.pi_attr;
		ret = _gx_rep_val_set(&tInfoParm,pInfoParmI);
		tInfoParm.pi_len = len;
		tInfoParm.pi_paux   = paux;
		tInfoParm.pi_aux[0] = aux0;
	}
	return ret;
}

/****************************************/
/*	17									*/
/****************************************/
int cl_gx_rep_info_copy_data(pInfoParmO,pInfoParmI,iOpt0)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt0;
{
	char c,id,*p;
	uchar aux0;
	int  rc,len,attr,alen,im,iOpt,iRANGE,len1,iFUNC;
	tdtInfoParm *pInfoParm;

DEBUGOUT_InfoParm(200,"cl_gx_rep_info_copy_data:Enter: iOpt0=%08x pInfoParmI=",pInfoParmI,iOpt0,0);

	if (iOpt0 < 0) {
		iOpt = -1;
		iOpt0 = 0;
	}
	else iOpt = iOpt0 & 0x03;

	pInfoParmO->pi_aux[1] &= ~(D_AUX1_PROTECTED | D_AUX1_HASHED_NAME | D_AUX1_VAR_SCOPE);

	id = pInfoParmO->pi_id;
	if ((aux0=pInfoParmO->pi_aux[0]) & ~DEF_ZOK_DATA) {
		/* aux0が、17,18,19 でなければ、クリアする */
		if (!(aux0 & 0x10)) pInfoParmO->pi_aux[0] &= (DEF_ZOK_DATA | D_AUX0_VAR_EXPORT);
		pInfoParmO->pi_alen &= (D_AULN_RANGE_DATA | D_AULN_RANGE_INTVAL);
		if (id!='A' && id!='R') pInfoParmO->pi_paux = NULL;
	}

	if (!(im=(iOpt0 & D_GX_OPT_ALC_MASK)>>12)) im = D_OPT_ALC_MALLOC;
	if (pInfoParmO->pi_scale & D_DATA_LPOSDATA) {
#if 1	/* 2021.8.6 */
		if (id == D_DATA_ID_PNAME) {
			pInfoParmO->pi_scale &= ~D_DATA_INDEX_FREE;
			if (iOpt >= 1) {
				if (!(p=cl_opt_malloc(im,sizeof(tdtInfoParm)))) {
					if (iOpt >= 2) cl_free_info_parm(pInfoParmI);
					return ECL_MALLOC_ERROR;
				}
				rc = cl_gx_rep_info_set_ign(p,pInfoParmO->pi_pos,1 | (iOpt0 & D_GX_OPT_ALC_MASK));
				if (im == D_OPT_ALC_MALLOC) pInfoParmO->pi_scale |= D_DATA_MALLOC | D_DATA_INDEX_FREE;
				pInfoParmO->pi_pos = (long)p;
			}
		}
#endif
		pInfoParmO->pi_data = (char *)&pInfoParmO->pi_pos;
	}
	else if (iOpt >= 1) {
		iRANGE = pInfoParmI->pi_alen & D_AULN_RANGE_DATA;
		pInfoParmO->pi_scale &= ~D_DATA_MALLOC;
		if (pInfoParmI->pi_dlen > 0) {
			alen = len = pInfoParmI->pi_dlen;
			iFUNC = 0;
			if ((id=pInfoParmI->pi_id)==' ' || id=='U') {
				attr = pInfoParmI->pi_attr;
				if (attr==DEF_ZOK_CHAR) alen++;
				else if (attr==DEF_ZOK_BULK) alen += sizeof(int);
				if (iRANGE) {
					len1 = alen;
					alen = len1 + len1;
					if (attr==DEF_ZOK_DATE ||
					    (attr!=DEF_ZOK_BINA && (pInfoParmI->pi_alen & D_AULN_RANGE_INTVAL))) alen += len1;
				}
			}
#if 1	/* 2021.6.30 */
			else if (strchr("FCIMO",id)) {
				alen++;
				iFUNC = 1;
			}
#else
			else if (id == 'F') alen++;
#endif
			if (!(p=cl_opt_malloc(im,alen))) {
				if (iOpt >= 2) cl_free_info_parm(pInfoParmI);
				return ECL_MALLOC_ERROR;
			}
			pInfoParmO->pi_data = p;
			if (im == D_OPT_ALC_MALLOC) pInfoParmO->pi_scale |= D_DATA_MALLOC;
/*
printf("cl_gx_rep_info_copy_data: p=%08x pInfoParmI->pi_data=%08x\n",p,pInfoParmI->pi_data);
*/
			memcpy(p,pInfoParmI->pi_data,alen);
			p += len;
			if ((id=pInfoParmO->pi_id)==' ' || id=='U') {
				if (attr==DEF_ZOK_CHAR && !iRANGE) *p = '\0';
			}
#if 1	/* 2021.6.30 */
			else if (iFUNC) *p = '\0';
#else
			else if (id == 'F') *p = '\0';
#endif
		}
#if 1	/* 2021.8.5 */
		if ((c=pInfoParmO->pi_id)=='A' || c=='R' || c=='P' || c=='T') {
			if (p=(char *)pInfoParmI->pi_pos) {
				pInfoParmO->pi_pos = (long)Strdup(p);
				pInfoParmO->pi_alen &= ~D_AULN_NO_AL_LPOS;
			}
		}
#endif
		if (iOpt >= 2) cl_free_info_parm(pInfoParmI);
	}
	if (iOpt <= 1) {
		if ((c=pInfoParmO->pi_id)=='A' || c=='R' || c=='P' || c=='T') {
		/*	pInfoParmO->pi_scale &= ~(D_DATA_MALLOC | D_DATA_INDEX_FREE);	*/
			pInfoParmO->pi_scale &= ~D_DATA_INDEX_FREE;
		/*	pInfoParmO->pi_alen |= D_AULN_NO_AL_LPOS;	del 2021.8.5 */
		}
	}
DEBUGOUT_InfoParm(200,"cl_gx_rep_info_copy_data: pInfoParmO=",pInfoParmO,0,0);
	return 0;
}
/*	18	*/
/************************************************************/
/*	iOpt0 < 0 --> iIGN=1, iOpt<0, iOpt0=0x10				*/
/*	iOpt0 = 0x7000 (D_GX_OPT_ALC_MASK) 						*/
/*	      | 0x0003 (iOpt)									*/
/*	      | 0x0010 (ignore data of pInfoParmO)				*/
/*	      | 0x0020 (check undef of pInfoParmI)				*/
/*	      | 0x0100 (データタイプ固定時の変換のみ)			*/
/*	      | 0x0200 (再帰repのみ)							*/
/*	      | 0x0400 (data repのみ)							*/
/*	iOpt = 0 : copy only									*/
/*	    >= 1 : copy & Malloc to_pi_data						*/
/*	    >= 2 : copy & Malloc to_pi_data & Free from_pi_data	*/
/************************************************************/
int cl_gx_rep_info_set_name(pInfoParmO,pInfoParmI,iOpt0,name)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt0;
char *name;
{
	char c,id,*p;
	int  rc,len,attr,alen,iOpt,iIGN,iAux0,iOpt1,iOptSel;
	ScrPrCT *scrct;
	ProcCT  *proc;
	uchar aux1_scope;
/*
printf("cl_gx_rep_info_set_name:Enter: iOpt0=%08x pInfoParmO=%08x pInfoParmI=%08x\n",iOpt0,pInfoParmO,pInfoParmI);
*/
DEBUGOUTL2(110,"cl_gx_rep_info_set_name:Enter: iOpt0=%08x name=[%s]",iOpt0,nval1(name));
DEBUGOUT_InfoParm(170,"cl_gx_rep_info_set_name:O: ",pInfoParmO,0,0);
DEBUGOUT_InfoParm(170,"cl_gx_rep_info_set_name:I: ",pInfoParmI,0,0);

	if (!pInfoParmO || !pInfoParmI) return -1;

	if (iOpt0 & D_REP_CHK_UNDEF_IN) {
		if (pInfoParmI->pi_id == D_DATA_ID_UNDEFVAR) {
			return ECL_NDEFVAR_ERROR;
		}
	}
	if (pInfoParmO == pInfoParmI) return 0;

	if (iOpt0 < 0) {
		iOpt = -1;
		iIGN = 1;
		iOpt0 = D_REP_IGN_OUT_DATA;
		iOpt1 = 0;
	}
	else {
		if (!(iOptSel = iOpt0 & D_REP_OPT_SEL_MASK)) iOptSel = D_REP_OPT_SEL_MASK;
		iOpt = iOpt0 & D_REP_OPT_CPY_MASK;
		iIGN = iOpt0 & D_REP_IGN_OUT_DATA;
		iOpt1 = iOpt;
	}
	aux1_scope = 0;
	if (!iIGN) {	/* pInfoParmOの設定を無視しないとき */
		aux1_scope = pInfoParmO->pi_aux[1] & D_AUX1_VAR_SCOPE;
	  if (iOptSel & D_REP_OPT_SEL_CNVT) {
#if 0	/* 2021.3.27 */
		iAux0 = pInfoParmO->pi_aux[0];
		if (pInfoParmO->pi_id && (iAux0 & ~DEF_ZOK_DATA) && !(iAux0 & 16)) {
#else
		/* データタイプ固定のときは、そのタイプに変換する */
	/*	if (pInfoParmO->pi_id && (pInfoParmO->pi_aux[0] & ~DEF_ZOK_DATA)) {	 *//* 2021.3.27 */
		if (pInfoParmO->pi_id==' ' && (pInfoParmO->pi_aux[0] & ~DEF_ZOK_DATA)) {
#endif
			rc = _gx_rep_val_set(pInfoParmO,pInfoParmI,iOpt0);
			if (iOpt >= 2) cl_free_info_parm(pInfoParmI);
			return rc;
		}
	  }
	}
/*
scrct = cl_search_src_ct();
if (scrct) {
DEBUGOUTL3(110,"cl_gx_rep_info_set_name:1: scrct=%08x ProCT=%08x Vary=%08x",scrct,scrct->ProCT,scrct->Vary);
DEBUGOUT_InfoParm(110,"cl_gx_rep_info_set_name:1: ",pInfoParmO,0,0);
}
*/
/*
printf("cl_gx_rep_info_set_name: iIGN=%d iOpt=%08x\n",iIGN,iOpt);
*/
	if (!iIGN && (iOpt>=0)) cl_free_info_parm(pInfoParmO);

	*pInfoParmO = *pInfoParmI;
	if (!(id=pInfoParmO->pi_id)) return 0;

	pInfoParmO->pi_alen &= ~D_AULN_DATA_NARABI;
	if (!iIGN) {
		if ((pInfoParmI->pi_aux[0] & DEF_ZOK_DATA) ||
		    id==D_DATA_ID_LIST || id==D_DATA_ID_NARABI) pInfoParmO->pi_aux[1] = aux1_scope;
	}
  if (iOptSel & D_REP_OPT_SEL_RCSV) {
	if (id==D_DATA_ID_LIST || id==D_DATA_ID_NARABI ||
	    ((id==D_DATA_ID_MAPEDARY || id==D_DATA_ID_ARRAY || id==D_DATA_ID_STRUCT) &&
	      ((pInfoParmI->pi_aux[0] & DEF_ZOK_DATA) ||
		   (pInfoParmI->pi_scale & D_DATA_INDEX_TMP)))) {	/* add 2021.9.9 */
/*
printf("cl_gx_rep_info_set_name: uc=%02x\n",uc);
*/
		if (id==D_DATA_ID_LIST || id==D_DATA_ID_NARABI)
			rc = _rep_list_copy(pInfoParmO,pInfoParmI,iOpt1 | (iOpt0 & (D_REP_CHK_UNDEF_IN | D_GX_OPT_ALC_TMP)));
		else
			rc = _gx_rep_all_data(pInfoParmO,pInfoParmI,name);
		if (!rc) {
			if (aux1_scope & D_AUX1_LOCAL_VAR) {
				if (proc=cl_search_proc_ct()) pInfoParmO->pi_hlen = proc->ProcGid;
			}
			else if (aux1_scope & D_AUX1_PRIVATE_VAR) {
				if (scrct=cl_search_src_ct()) pInfoParmO->pi_hlen = scrct->ScrGid;
			}
			pInfoParmO->pi_paux = (char *)pInfoParmO;	/* コピーされたときに、この配列が有効化をチェックするために保存する */
		}
		return rc;
	}
  }
  if (iOptSel & D_REP_OPT_SEL_DATA) {
	if (rc=cl_gx_rep_info_copy_data(pInfoParmO,pInfoParmI,iOpt0)) return rc;
	pInfoParmO->pi_aux[1] |= aux1_scope;	/* add 2021.9.14 */

	if (pInfoParmO->pi_id=='I' && iOpt>0 && name) {
		Free(pInfoParmO->pi_data);
		pInfoParmO->pi_data = Strdup(name);
		pInfoParmO->pi_dlen = strlen(name);
	}
/*
if (scrct) {
DEBUGOUTL3(110,"cl_gx_rep_info_set_name:2: scrct=%08x ProCT=%08x Vary=%08x",scrct,scrct->ProCT,scrct->Vary);
}
*/
DEBUGOUT_InfoParm(110,"cl_gx_rep_info_set_name:Exit: O:",pInfoParmO,0,0);
/*
printf("cl_gx_rep_info_set_name:Exit ret=0\n");
*/
DEBUGOUTL(110,"cl_gx_rep_info_set_name:Exit ret=0");
  }
	return NORMAL;
}

/****************************************/
/*	19									*/
/****************************************/
int cl_gx_rep_info_set(pInfoParmO ,pInfoParmI ,iOpt)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt;
{
	return cl_gx_rep_info_set_name(pInfoParmO,pInfoParmI,iOpt,NULL);
}

/****************************************/
/*	20									*/
/****************************************/
int cl_gx_rep_info_set_alloc(pvParmO,pInfoParmI,opt)
tdtInfoParm **pvParmO,*pInfoParmI;
int opt;
{
	tdtInfoParm *pParm;

#if 1	/* 2021.9.9 */
	if (!(pParm=(tdtInfoParm *)cl_tmp_const_malloc(sizeof(tdtInfoParm)))) return -1;
#else
	if (!(pParm=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm)))) return -1;
#endif
	*pvParmO = pParm;
	return cl_gx_rep_info_set_ign(pParm,pInfoParmI,opt|D_GX_OPT_ALC_TMP);
}

/****************************************/
/*	21									*/
/****************************************/
int cl_gx_rep_info_set_ign(pInfoParmO,pInfoParmI,iOpt)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt;
{
	cl_parm_set0(pInfoParmO);
	return cl_gx_rep_info_set(pInfoParmO,pInfoParmI,iOpt|D_REP_IGN_OUT_DATA);
}

/****************************************/
/*	22									*/
/****************************************/
int cl_gx_rep_info_convert(pInfoParmO,pInfoParmI,iOpt0)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt0;
{
	iOpt0 = (iOpt0 & ~D_REP_OPT_SEL_MASK) | D_REP_OPT_SEL_CNVT;
	return cl_gx_rep_info_set(pInfoParmO,pInfoParmI,iOpt0);
}

/****************************************/
/*	23									*/
/****************************************/
int cl_gx_rep_info_als(pInfoParmO,pInfoParmI,iOpt0)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt0;
{
#if 1
	gtIter_ctl[0].itc_circ_ref = NULL;
#else
	if (!(gtIter_ctl[0].itc_circ_ref=akxs_layer_new(10,cl_tmp_const_malloc,NULL))) return -215212104;
#endif
	return cl_gx_rep_info_set(pInfoParmO,pInfoParmI,iOpt0);
}

/****************************************/
/*	24									*/
/****************************************/
int cl_gx_rep_info_als_name(pInfoParmO,pInfoParmI,iOpt0,name)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt0;
char *name;
{
	gtIter_ctl[0].itc_circ_ref = NULL;
	return cl_gx_rep_info_set_name(pInfoParmO,pInfoParmI,iOpt0,name);
}

/****************************************/
/*	25									*/
/****************************************/
int cl_gx_rep_info_data(pInfoParmO,pInfoParmI,iOpt0)
tdtInfoParm  *pInfoParmO, *pInfoParmI;
int iOpt0;
{
	iOpt0 = (iOpt0 & ~D_REP_OPT_SEL_MASK) | D_REP_OPT_SEL_DATA;
	return cl_gx_rep_info_set(pInfoParmO,pInfoParmI,iOpt0);
}

/****************************************/
/*	26									*/
/****************************************/
tdtInfoParm *cl_gx_copy_info_opt(pInfoParmO,pInfoParmI,opt)
tdtInfoParm *pInfoParmO, *pInfoParmI;
int opt;
{
	if (!pInfoParmO || !pInfoParmI) return NULL;
	if (pInfoParmO != pInfoParmI) {
		*pInfoParmO = *pInfoParmI;
		if (pInfoParmO->pi_scale & D_DATA_LPOSDATA)
			pInfoParmO->pi_data = (char *)&pInfoParmO->pi_pos;
		if (opt & 0x01) pInfoParmO->pi_scale &= ~D_DATA_MALLOC;	/* add 2022.6.14 */
	}
	return pInfoParmO;
}

/*	27	*/
/********1*********2*********3*********4*********5*********6*/
/* 機能 : pi_data以外のInfoをコピーし、データをコピーする	*/
/* 引数 : pInfoParmO : コピー先Info							*/
/*			NULLのときは、tmp_mallocし、これを返す			*/
/*			O.pi_dataがNULLか、O.pi_dlen<I.pi_dlenのときは	*/
/*			O.pi_dataをtmp_mallocする						*/
/*		  pInfoParmI : コピー元Info							*/
/*			NULLのときは、NULLを返す						*/
/*		  opt        : 	addrオプション						*/
/*			= 0 : 上記機能									*/
/*			= 1 : pInfoParmO<>NULL							*/
/*					pInfoParmO=NULLのときは、エラー			*/
/*			= 2 : pInfoParmO->pi_data<>NULL (opt=1を含む)	*/
/*					pInfoParmO->pi_data=NULLのときは、エラー*/
/*			= 3 : pInfoParmO->pi_dlen>=pInfoParmI->pi_dlen	*/
/*											(opt=1,2を含む)	*/
/*					pInfoParmO->pi_dlen<pInfoParmI->pi_dlen	*/
/*					のときは、エラー						*/
/* 返却 : pInfoParmO										*/
/************************************************************/
tdtInfoParm *cl_gx_copy_info2_opt(pInfoParmO,pInfoParmI,opt)
tdtInfoParm *pInfoParmO, *pInfoParmI;
int opt;
{
	char *p;
	int ret,len,alen;

	ret = 0;
	if (!pInfoParmI) {
		return NULL;
	}
	if (opt < 0) opt = 0;
	if (!pInfoParmO) {
		if (opt) {
			return NULL;
		}
		if (!(pInfoParmO=(tdtInfoParm *)cl_tmp_const_malloc(sizeof(tdtInfoParm)))) {
			return NULL;
		}
		memset(pInfoParmO,0,sizeof(tdtInfoParm));
	}
	if (pInfoParmO != pInfoParmI) {
		if (pInfoParmI->pi_scale & D_DATA_LPOSDATA) {
			*pInfoParmO = *pInfoParmI;
			pInfoParmO->pi_data = (char *)&pInfoParmO->pi_pos;
/*
printf("cl_gx_copy_info2: O.pos=%d\n",pInfoParmO->pi_pos);
*/
		}
		else {
			p   = pInfoParmO->pi_data;
			len = pInfoParmI->pi_dlen;
/*
printf("cl_gx_copy_info2: O.data=%08x O.dlen=%d I.data=%08x I.dlen=%d\n",p,pInfoParmO->pi_dlen,pInfoParmI->pi_data,len);
*/
			if (opt>=2 && !p) {
				return NULL;
			}
			else if (opt>=3 && pInfoParmO->pi_dlen<len) {
				return NULL;
			}
			else if (!p || (pInfoParmO->pi_dlen<len)) {
				alen = len;
				if (pInfoParmI->pi_attr == DEF_ZOK_CHAR) alen++;
				if (!(p=cl_tmp_const_malloc(alen))) {
					return NULL;
				}
			}
			*pInfoParmO = *pInfoParmI;
			memcpy(p,pInfoParmI->pi_data,len);
			if (pInfoParmO->pi_attr == DEF_ZOK_CHAR) *(p+len) = '\0';
			pInfoParmO->pi_data = p;
		}
	}
	return pInfoParmO;
}

/****************************************/
/*	28									*/
/****************************************/
tdtInfoParm *cl_gx_copy_info2(pInfoParmO,pInfoParmI)
tdtInfoParm *pInfoParmO, *pInfoParmI;
{
	return cl_gx_copy_info2_opt(pInfoParmO,pInfoParmI,0);
}

/****************************************/
/*	29									*/
/****************************************/
tdtInfoParm *cl_gx_copy_info(pInfoParmO,pInfoParmI)
tdtInfoParm *pInfoParmO, *pInfoParmI;
{
	return cl_gx_copy_info_opt(pInfoParmO,pInfoParmI,0);
}

/****************************************/
/*	31									*/
/****************************************/
static int _array_get_info_parm_opt(ppParmI,pIndex1,pTBL1,i,ix1,opt)
tdtInfoParm **ppParmI;
tdtArrayIndex *pIndex1;
tdtInfoParm ***pTBL1;
int i,ix1;
char opt;
{
	if (pIndex1->xhp) ix1 = i;
	return cl_array_get_info_parm(ppParmI,pIndex1,pTBL1,ix1,opt);
}

/****************************************/
/*	32									*/
/****************************************/
static int _array_get_info_parm(ppParmI,pIndex1,pTBL1,i,ix1)
tdtInfoParm **ppParmI;
tdtArrayIndex *pIndex1;
tdtInfoParm ***pTBL1;
int i,ix1;
{
	return _array_get_info_parm_opt(ppParmI,pIndex1,pTBL1,i,ix1,'s');
}

/****************************************/
/*	33									*/
/****************************************/
static int _gx_rep_all_hash(xhpO,xhpI,iOpt)
XHASHB *xhpI,*xhpO;
int iOpt;
{
	tdtInfoParm *pParmI,*pParmO;
	char *cpKey,*cpDat;
	int rc,i,n;

	n = akxs_xhash2(xhpI,'M',NULL,NULL);
	for (i=1;i<=n;i++) {
		xhpI->xha_xhix = i;
		if ((rc=akxs_xhash2(xhpI,'P',&cpKey,&cpDat)) > 0) {
/*
printf("_gx_rep_all_array: i=%d key=[%s]\n",i,cpKey);
*/
			memcpy(&pParmI,cpDat,sizeof(tdtInfoParm *));
			if (iOpt & D_GX_OPT_ALC_TMP)
				pParmO=(tdtInfoParm *)cl_tmp_const_malloc(sizeof(tdtInfoParm));
			else
				pParmO=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm));
			if (!pParmO) return ECL_MALLOC_ERROR;
			if (rc = cl_gx_rep_info_set_ign(pParmO,pParmI,1|iOpt)) return rc;
			if ((rc=akxs_xhash2(xhpO,'S',cpKey,&pParmO)) < 0) return  rc;
			else if (!rc) return -12;
		}
		else if (rc < 0) return rc;
	}
	return 0;
}

/****************************************/
/*	34									*/
/****************************************/
static int _gx_rep_all_array(pInfoParmO,pInfoParmI)
tdtInfoParm *pInfoParmO,*pInfoParmI;
{
	tdtArrayIndex *pIndexO,*pIndexI,tIndex;
	int *index,attr,size,len,n,i,rc,opti,i0,iParm[4],ix,ndim;
	tdtInfoParm **pvParmI,**pvParmO,*pParmI,*pParmO;
	tdtInfoParm ***pTBL;
	char *name,*cpKey,*cpDat,*pVal;
	ScrPrCT *pScCT;
	XHASHB *xhpI,*xhpO;

DEBUGOUT_InfoParm(120,"_gx_rep_all_array:pInfoParmO:",pInfoParmO,0,0);
DEBUGOUT_InfoParm(120,"_gx_rep_all_array:pInfoParmI:",pInfoParmI,0,0);

	pIndexI = (tdtArrayIndex *)pInfoParmI->pi_data;
	pIndexO = (tdtArrayIndex *)pInfoParmO->pi_data;
	if (rc=_get_array_info(1,&pInfoParmI,&tIndex,&pTBL,iParm,1)) {
		if (rc == 2000) xhpI = tIndex.xhp;
		else return rc;
	}
	else xhpI = NULL;

	/* 循環参照初期化チェック */
	if (!gtIter_ctl[0].itc_circ_ref) {
		if (!(gtIter_ctl[0].itc_circ_ref=akxs_layer_new(10,cl_tmp_const_malloc,NULL))) return -215212104;
	}
	/* 循環参照をチェック */
	pVal = cl_get_circ_addr(&tIndex,pTBL);
	if ((rc=_iterate_circ_ref(&gtIter_ctl[0],pVal,(char *)pInfoParmI->pi_pos)) == 1) return 0;
	else if (rc < 0) return rc;

	n  = iParm[1];
	ix = iParm[2];
	if (xhpI) {
		if (!(pIndexO->xhp = xhpO =
		        akxs_xhash_new2(0,pIndexO->index[4],0,pIndexO->size))) return -9;
		if (rc=_gx_rep_all_hash(xhpO,xhpI,0)) return rc;
		pInfoParmO->pi_paux = (char *)pInfoParmO;	/* コピーされたときに、この配列が有効化をチェックするために保存する */
	}
	else {
		index = pIndexO->index;
		size = pIndexO->size;
		if ((attr=pIndexO->uAttr[0]) == DEF_ZOK_CHAR) size++;
		else if (attr == DEF_ZOK_BULK) size += sizeof(int);
		len = n*size;
/*
printf("_gx_rep_all_array: size=%d attr=%d n=%d\n",size,attr,n);
*/
		if (!(pIndexO->pVarIndex=(tdtInfoParm **)Malloc(len))) return -10;
		if (pIndexI->pVarIndex) {
			if (attr == DEF_ZOK_VARI) {
				memset(pIndexO->pVarIndex,0,len);
				pvParmI = pIndexI->pVarIndex;
				pvParmO = pIndexO->pVarIndex;
				for (i=0;i<n;i++) {
					if (pParmI=*pvParmI) {
/*
printf("_gx_rep_all_array: i=%d\n",i);
*/
						if (!(pParmO=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm)))) return -1;
						memset(pParmO,0,sizeof(tdtInfoParm));
						*pvParmO = pParmO;
						pParmI->pi_aux[0] |= DEF_ZOK_DATA;	/* add 2021.11.23 */
						if (rc = cl_gx_rep_info_set_ign(pParmO,pParmI,1)) return rc;
					}
					pvParmO++;
					pvParmI++;
				}
			}
			else memcpy(pIndexO->pVarIndex,pIndexI->pVarIndex,len);
			pInfoParmO->pi_paux = (char *)pInfoParmO;	/* コピーされたときに、この配列が有効化をチェックするために保存する */
		}
		else {	/* MAPPEDARRAY */
			memset(pIndexO->pVarIndex,0,len);
			index[3] = 1;
			pvParmO = pIndexO->pVarIndex;
			for (i=0;i<n;i++) {
				pParmI = cl_get_array_and_var_ent(&tIndex,pTBL,ix);
				ix++;
				if (pParmI && !cl_is_undef_parm(pParmI) && !cl_is_null_parm(pParmI)) {
					if (!(pParmO=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm)))) return -1;
					memset(pParmO,0,sizeof(tdtInfoParm));
					*pvParmO = pParmO;
					if (rc=cl_gx_rep_info_set_ign(pParmO,pParmI,1)) return rc;
/*
DEBUGOUT_InfoParm(0,"_gx_rep_all_array:pParmI: i+i0=%d",pParmI,i+i0,0);
DEBUGOUT_InfoParm(0,"_gx_rep_all_array:pParmO: i=%d",pParmO,i,0);
*/
				}
				pvParmO++;
			}
		}
	}
	pInfoParmO->pi_scale |= D_DATA_INDEX_FREE;
	return 0;
}

/****************************************/
/*	36									*/
/****************************************/
static int _gx_rep_all_struct(pInfoParmO,pInfoParmI)
tdtInfoParm *pInfoParmO,*pInfoParmI;
{
	int  j,rc,ntype,attr,size;
	char *p,id;
	tdtInfoParm *pParmO,*pParmI;
	tdtDefType *pDeftypeO,*pDeftypeI;

DEBUGOUTL(110,"_gx_rep_all_struct:Enter");
DEBUGOUT_InfoParm(120,"_gx_rep_all_struct:pInfoParmO:",pInfoParmO,0,0);
DEBUGOUT_InfoParm(120,"_gx_rep_all_struct:pInfoParmI:",pInfoParmI,0,0);

/*	pInfoParmO->pi_aux[0] = D_AUX0_TYPE_STRUCT;	2021.2.17 */

	pDeftypeO = (tdtDefType *)pInfoParmO->pi_data;
	pDeftypeI = (tdtDefType *)pInfoParmI->pi_data;
	ntype = pDeftypeI->ntype;
/*
printf("_gx_rep_all_struct: ntype=%d\n",ntype);
*/
	/* 循環参照初期化チェック */
	if (!gtIter_ctl[0].itc_circ_ref) {
		if (!(gtIter_ctl[0].itc_circ_ref=akxs_layer_new(10,cl_tmp_const_malloc,NULL))) return -215212104;
	}
	/* 循環参照をチェック */
	if ((rc=_iterate_circ_ref(&gtIter_ctl[0],(char *)pDeftypeI,(char *)pInfoParmI->pi_pos)) == 1) return 0;
	else if (rc < 0) return rc;

	if (!(pDeftypeO->pType=(tdtInfoParm **)Malloc(ntype*sizeof(tdtInfoParm *)))) return -1;
	for (j=0;j<ntype;j++) {
		if (!(pParmO=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm)))) return -1;
		pDeftypeO->pType[j] = pParmO;
		pParmI = pDeftypeI->pType[j];
/*
printf("_gx_rep_all_struct: i=%d pi_id=[%c]\n",j,pParmI->pi_id);
*/
		if ((id=pParmI->pi_id)==' ' && (attr=(pParmI->pi_aux[0] & ~DEF_ZOK_DATA))) {
/*
printf("_gx_rep_all_struct: attr=%d\n",attr);
*/
			cl_gx_copy_info(pParmO,pParmI);
			pParmO->pi_scale &= ~D_DATA_MALLOC;
			if (attr!=DEF_ZOK_BINA && attr!=DEF_ZOK_FLOA) {
				size = pParmI->pi_len;
				if (attr == DEF_ZOK_CHAR) size++;
				else if (attr == DEF_ZOK_BULK)
					size += sizeof(int);
				if (p = Malloc(size)) {
					if (attr == DEF_ZOK_DECI) memcpy(p,pParmI->pi_data,size);
					else strcpy(p,pParmI->pi_data);
					pParmO->pi_scale |= D_DATA_MALLOC;
				}
				else rc = -1;
				pParmO->pi_data = p;
			}
			pParmO->pi_paux = pParmO->pi_data;
			pParmO->pi_aux[1] &= ~D_AUX1_PROTECTED;
		}
		else {
			if (rc=cl_gx_rep_info_set_ign(pParmO,pParmI,1)) return rc;
			if (id=='A' || id=='R') {
				if (rc = _gx_rep_all_array(pParmO,pParmI)) return rc;
			}
		}
/*
DEBUGOUT_InfoParm(0,"_gx_rep_all_struct:pParmI: i=%d",pParmI,j,0);
DEBUGOUT_InfoParm(0,"_gx_rep_all_struct:pParmO: i=%d",pParmO,j,0);
*/
	}
	pInfoParmO->pi_scale |= D_DATA_MALLOC | D_DATA_INDEX_FREE;
	rc = cl_set_struct_name(pInfoParmO,(char *)pInfoParmI->pi_pos);
DEBUGOUTL2(110,"_gx_rep_all_struct:Exit: rc=%d struct_name=[%s]",rc,(char *)pInfoParmO->pi_pos);
	return rc;
}

/****************************************/
/*	37									*/
/****************************************/
static int _gx_rep_all_data(pInfoParmO,pInfoParmI,name)
tdtInfoParm *pInfoParmO,*pInfoParmI;
char *name;
{
	tdtInfoParm rInfoParmI;
	char id,c;
	int rc;

DEBUGOUTL1(110,"_gx_rep_all_data:Enter: name=[%s]",name);
DEBUGOUT_InfoParm(120,"_gx_rep_all_data:pInfoParmO: name=[%s]",pInfoParmO,name,0);
DEBUGOUT_InfoParm(120,"_gx_rep_all_data:pInfoParmI:",pInfoParmI,0,0);

	rInfoParmI = *pInfoParmI;
	rInfoParmI.pi_aux[0] = '\0';
	rInfoParmI.pi_scale &= ~D_DATA_INDEX_TMP;	/* add 2021.9.9 */
	if (rc=cl_gx_rep_info_set_ign(pInfoParmO,&rInfoParmI,1)) return rc;
	if (!name) name = "";
	else {
		if (*name=='<') name += D_LEN_SCOPE_MARK;
		if ((c=*name)=='$' || c=='%' || c=='#') name++;
	}
	pInfoParmO->pi_pos = (long)Strdup(name);
	pInfoParmO->pi_alen &= ~D_AULN_NO_AL_LPOS;
/*
printf("_gx_rep_all_data: id=[%c]\n",pInfoParmI->pi_id);
*/
	if ((id=pInfoParmI->pi_id)==D_DATA_ID_MAPEDARY || id==D_DATA_ID_ARRAY) {
		pInfoParmO->pi_id = D_DATA_ID_ARRAY;	/* 配列のデータもコピーするときは、通常の配列にする */
		return _gx_rep_all_array(pInfoParmO,pInfoParmI);
	}
	else if(id==D_DATA_ID_STRUCT) {
		return _gx_rep_all_struct(pInfoParmO,pInfoParmI);
	}

DEBUGOUTL(110,"_gx_rep_all_data:Exit");
	return 0;
}

/****************************************/
/*	41									*/
/****************************************/
static int _check_mk_key(pInfoParm,ppKey)
tdtInfoParm *pInfoParm;
char **ppKey;
{
	static char *p=NULL;
	int len,len2,n;
	char *key,*p1;

	key = pInfoParm->pi_data;
	if (ppKey) *ppKey = key;
	len = pInfoParm->pi_dlen;
	if (pInfoParm->pi_id == ' ' ) {
		p1 = NULL;
		if (pInfoParm->pi_attr != DEF_ZOK_CHAR) {
			if ((len=parm_to_char(pInfoParm,&p1,NULL)) < 0) return len;
			key = p1;
		}
	}
	else {
		len2 = len*2 + 1;
		if (p) p = Realloc(p,len2);
		else p = Malloc(len2);
		if (!p) return -1;
		n = akxcxtoc(key,len,p);
		*(p+n) = '\0';
		key = p;
		len = n;
	}
	if (ppKey) *ppKey = key;
/*
printf("_check_mk_key: key=[%s]\n",key);
*/
	return len;
}

/****************************************/
/*	42									*/
/****************************************/
static int _check_exist_mk_key(mcat,pInfoParm)
MCAT *mcat;
tdtInfoParm *pInfoParm;
{
	tdtInfoParm *pInfo;
	tdtRbCtl *pCt;
	int len,n;
	char c,*key;

	if ((c=pInfoParm->pi_id)=='L' || c=='N') {
		pCt = (tdtRbCtl *)pInfoParm->pi_data;
		akxs_rb_read(pCt,0);
		while (pInfo=(tdtInfoParm *)akxs_rb_read(pCt,1)) {
			if ((len=_check_exist_mk_key(mcat,pInfo)) < 0) return len;
		}
	}
	else {
		if ((len=_check_mk_key(pInfoParm,&key)) < 0) return len;
		if (mcat->mc_ipos > 0) akxtmcatz(mcat,"`",1);
		akxtmcatz(mcat,key,len);
	}
	return 0;
}

/****************************************/
/*	43									*/
/****************************************/
static int _check_exist(xhpS,pInfoParm)
XHASHB *xhpS;
tdtInfoParm *pInfoParm;
{
	MCAT mcat;
	int len,n,ix;
	char *key;

#if 1	/* 2021.4.7 */
	memset(&mcat,0,sizeof(MCAT));
	mcat.mc_extlen = 256;
	if ((ix=_check_exist_mk_key(&mcat,pInfoParm)) < 0) return ix;
	key = mcat.mc_bufp;
#else
	if ((len=_check_mk_key(pInfoParm,&key)) < 0) return len;
#endif

	if (!(ix=akxs_xhash(xhpS,'R',key))) {
		if ((n=akxs_xhash(xhpS,'S',key))<0) ix = n;
		else if (!n) ix = -1;
	}
/*
printf("_check_exist: key=[%s] ix=%d\n",key,ix);
*/
	return ix;
}

/****************************************/
/*	44									*/
/****************************************/
static int _check_exist_all(xhpS,pInfoParm)
XHASHB *xhpS;
tdtInfoParm *pInfoParm;
{
	MCAT mcat;
	int n,ix;
	char *key;

	memset(&mcat,0,sizeof(MCAT));
	mcat.mc_extlen = 256;
	if ((ix=_check_exist_mk_key(&mcat,pInfoParm)) < 0) return ix;
	key = mcat.mc_bufp;
	if (!ix) {
		if (!(ix=akxs_xhash(xhpS,'R',key))) {
			if ((n=akxs_xhash(xhpS,'S',key))<0) ix = n;
			else if (!n) ix = -1;
		}
	}
/*
printf("_check_exist_all: key=[%s] ix=%d\n",key,ix);
*/
	if (key) Free(key);
	return ix;
}

/****************************************/
/*	45									*/
/****************************************/
static int _array_add_sub(pvParmO,pos,pInfoParm1,pIndex1,pTBL1,ix1,nm1,xhpS)
int pos;
tdtArrayIndex *pIndex1;
tdtInfoParm **pvParmO,*pInfoParm1,***pTBL1;
int ix1,nm1;
XHASHB *xhpS;
{
	tdtInfoParm **pvParm,*pParmI;
	int iRc,i,count,iA;

	pvParm = pvParmO + pos;
	count = pos;
	if (pInfoParm1->pi_id == ' ') {
		pParmI = pInfoParm1;
		iA = 0;
	}
	else {
		iA = 1;
	}
	for (i=0;i<nm1;i++,ix1++) {
		if (iA) {
			if ((iRc=cl_array_get_info_parm(&pParmI,pIndex1,pTBL1,ix1,'r')) < 0) return iRc;
			else if (!iRc) continue;
		}
		if (pParmI && !cl_is_undef_parm(pParmI) && !cl_is_null_parm(pParmI)) {
			if (xhpS) {
				if ((iRc=_check_exist(xhpS,pParmI))<0) return iRc;
				else if (iRc > 0) continue;
			}
			if (iRc=cl_gx_rep_info_set_alloc(pvParm,pParmI,1)) return iRc;
#if 1	/* 2021.8.14 */
			pvParm++;
			count++;
		}
#else
		}
		else if (xhpS) continue;
		pvParm++;
		count++;
#endif
	}
	return count;
}

/****************************************/
/*	46									*/
/****************************************/
int cl_gx_array_add(pInfoParmW,op,pInfoParm1,pInfoParm2)
tdtInfoParm *pInfoParmW;
char       op;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
{
	static XHASHB *xhpS=NULL;
	XHASHB *xhp1,*xhp2,*xhpO;
	tdtInfoParm ***pTBL1,***pTBL2,**pvParmO;
	int iRc,ix1,ix2,nm1,nm2,len,iParm[4],*index,size;
	tdtArrayIndex tIndex1,tIndex2,*pIndex,*pIndexO;

	xhp1 = xhp2 = NULL;
	nm1 = nm2 = 1;
	if (pInfoParm1->pi_id != ' ') {
		if (iRc = _get_array_info(1,&pInfoParm1,&tIndex1,&pTBL1,iParm,1)) {
			if (iRc == 2000) xhp1 = tIndex1.xhp;
			else return iRc;
		}
		nm1  = iParm[3] - iParm[2] + 1;	/*iParm[1]; 2021.1.15 */
		ix1  = iParm[2];
	}

	if (pInfoParm2->pi_id != ' ') {
		if (iRc = _get_array_info(1,&pInfoParm2,&tIndex2,&pTBL2,iParm,1)) {
			if (iRc == 2000) xhp2 = tIndex2.xhp;
			else return iRc;
		}
		nm2  = iParm[3] - iParm[2] + 1;	/*iParm[1]; 2021.1.15 */
		ix2  = iParm[2];
	}

	info_parm_clear(pInfoParmW);
	pInfoParmW->pi_id   = 'R';
/*	pInfoParmW->pi_scale = D_DATA_MALLOC | D_DATA_INDEX_FREE;	*/
	pInfoParmW->pi_scale = D_DATA_INDEX_TMP/* | D_DATA_INDEX_FREE*/;
	pInfoParmW->pi_attr = DEF_ZOK_BULK;
	pInfoParmW->pi_dlen  = sizeof(tdtArrayIndex);
#if 1	/* 2021.8.14 */
	if (!(pIndexO = (tdtArrayIndex *)cl_tmp_const_malloc(sizeof(tdtArrayIndex)))) return -1;
#else
	pInfoParmW->pi_pos  = (long)Strdup("");
	if (!(pIndexO = (tdtArrayIndex *)Malloc(sizeof(tdtArrayIndex)))) return -1;
#endif
	memset(pIndexO,0,sizeof(tdtArrayIndex));
	pInfoParmW->pi_data    = (char *)pIndexO;
	index = pIndexO->index;
	pIndexO->size = size = sizeof(tdtInfoParm *);
	pIndexO->uAttr[0] = DEF_ZOK_VARI;

	if (xhp1 && xhp2) {
		index[4] = tIndex1.index[4];
#if 1	/* 2021.9.9 */
		if (!(pIndexO->xhp=xhpO=akxs_xhashm_new2(0,index[4],0,size,0,cl_tmp_const_malloc,NULL))) return -9;
#else
		if (!(pIndexO->xhp=xhpO=akxs_xhash_new2(0,index[4],0,size))) return -9;
#endif
		if (iRc=_gx_rep_all_hash(xhpO,xhp1,D_GX_OPT_ALC_TMP)) return iRc;
		if (iRc=_gx_rep_all_hash(xhpO,xhp2,D_GX_OPT_ALC_TMP)) return iRc;
	}
	else {
		if (xhpS) akxs_xhash_free(xhpS);
		xhpS = NULL;
		if (op == '|') {
			if (!(xhpS=akxs_xhash_new(0,10,0))) return -9;
		}
		index[0] = 1;
		index[2] = 0;
		index[3] = 1;
		index[4] = nm1+nm2;
		index[1] = index[4];
		index[5] = 0;
		len = index[4]*pIndexO->size;
#if 1	/* 2021.9.9 */
		if (!(pvParmO=(tdtInfoParm **)cl_tmp_const_malloc(len))) return -10;
#else
		if (!(pvParmO=(tdtInfoParm **)Malloc(len))) return -10;
#endif
		memset(pvParmO,0,len);
		pIndexO->pVarIndex = pvParmO;
		if ((iRc=_array_add_sub(pvParmO,0,pInfoParm1,&tIndex1,pTBL1,ix1,nm1,xhpS))<0) return iRc;
		if ((iRc=_array_add_sub(pvParmO,iRc,pInfoParm2,&tIndex2,pTBL2,ix2,nm2,xhpS))<0) return iRc;
		index[2] = iRc;
		if (iRc > 0) {
			index[1] = index[4] = iRc;
		}
	}
	return 0;
}

/****************************************/
/*	51 pInfoParm1 - pInfoParm2			*/
/****************************************/
static int _list_minus_sub(pCt,iOpt,pInfoParm1,pInfoParm2)
tdtRbCtl *pCt;
int iOpt;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
{
	static XHASHB *xhpS=NULL;
	tdtInfoParm *p,*pInfoParm;
	int rc,iL;
	tdtRbCtl *pCt1,*pCt2;
	char c1,c2;

	if (xhpS) akxs_xhash_free(xhpS);
	xhpS = NULL;
	if (!(xhpS=akxs_xhash_new(0,10,0))) return -9;

#if 1	/* 2021.4.7 */
	c1 = pInfoParm1->pi_id;
	c2 = pInfoParm2->pi_id;
	if (c1!='L' && c1!='N') c1 = c2;
	if ((c2=='L' || c2=='N') && c1==c2) {
#else
	if ((c2=pInfoParm2->pi_id)=='L' || c2=='N') {
#endif
		pCt2 = (tdtRbCtl *)pInfoParm2->pi_data;
		akxs_rb_read(pCt2,0);
		while (p=(tdtInfoParm *)akxs_rb_read(pCt2,1)) {
			if ((rc=_check_exist_all(xhpS,p))<0) return rc;
		}
	}
	else {
		if ((rc=_check_exist(xhpS,pInfoParm2))<0) return rc;
	}

	if ((c1=pInfoParm1->pi_id)=='L' || c1=='N') {
		pCt1 = (tdtRbCtl *)pInfoParm1->pi_data;
		akxs_rb_read(pCt1,0);
		iL = 1;
	}
	else {
		iL = 0;
		p = pInfoParm1;
	}

	for (;;) {
		if (iL) {
			if (!(p=(tdtInfoParm *)akxs_rb_read(pCt1,1))) break;
		}
		if (!cl_is_null_parm(p)) {
			if ((rc=_check_exist_all(xhpS,p))<0) return rc;
			else if ((iOpt && !rc)||(!iOpt && rc)) {
#if 1	/* 2021.9.9 */
				if (!(pInfoParm=(tdtInfoParm *)cl_tmp_const_malloc(sizeof(tdtInfoParm))))
#else
				if (!(pInfoParm=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm))))
#endif
					return ECL_MALLOC_ERROR;
#if 1	/* 2021.9.10 */
				if (rc=_tmp_list_info_set(pInfoParm,p,0)) return rc;
#else
				if (rc=_rep_list_info_set(pInfoParm,p,0)) return rc;
#endif
				if (!akxs_rb_set_n(pCt,pInfoParm)) return ECL_MALLOC_ERROR;
			}
		}
		if (!iL) break;
	}
	return 0;
}

/****************************************/
/*	52									*/
/****************************************/
int cl_gx_list_minus(pInfoParmW,op,pInfoParm1,pInfoParm2)
tdtInfoParm *pInfoParmW;
char       op;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
{
	int rc,iOpt;
	tdtRbCtl *pCt,*pCt1,*pCt2;
	char c1,c2;

	if ((c2=pInfoParm2->pi_id)=='L' || c2=='N') {
		*pInfoParmW = *pInfoParm2;
	/*	pInfoParmW->pi_scale &= ~D_DATA_MALLOC;	必要かどうかは未確認 */
	}
	if ((c1=pInfoParm1->pi_id)=='L' || c1=='N') {
		pCt1 = (tdtRbCtl *)pInfoParm1->pi_data;
		if (akxs_rb_used(pCt1) <= 0) {
/*
printf("cl_gx_list_minus: 1 nil\n");
*/
			return cl_gx_rep_info_set(pInfoParmW,pInfoParm1,1);
		}
		*pInfoParmW = *pInfoParm1;
	/*	pInfoParmW->pi_scale &= ~D_DATA_MALLOC;	必要かどうかは未確認 */
	}

	if (op == '&') iOpt = 0;
	else if (op == '-') iOpt = 1;
	else iOpt = 2;

#if 1	/* 2021.9.9 */
	if (!(pCt = cl_tmp_rb_new(0,0,NULL))) return ECL_MALLOC_ERROR;
#else
	if (!(pCt = akxs_rb_new(0,0))) return ECL_MALLOC_ERROR;
#endif
/*
printf("cl_gx_list_minus: op=[%c] iOpt=%d\n",op,iOpt);
*/
	if ((rc=_list_minus_sub(pCt,iOpt,pInfoParm1,pInfoParm2)) < 0) return rc;
	if (iOpt == 2) {
		if ((rc=_list_minus_sub(pCt,iOpt,pInfoParm2,pInfoParm1)) < 0) return rc;
	}

	pInfoParmW->pi_data = (char *)pCt;
/*	pInfoParmW->pi_scale = D_DATA_DATA_FREE;	*/
	return 0;
}

/****************************************/
/*	53									*/
/****************************************/
int cl_gx_list_add(pInfoParmW,op,pInfoParm1,pInfoParm2)
tdtInfoParm *pInfoParmW;
char       op;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
{
	tdtInfoParm *ppParm[2];
	int ret;
	char c1,c2;

	ppParm[0] = pInfoParm1;
	if (op == '+') {
		ppParm[1] = pInfoParm2;
		ret = cl_cons_list(pInfoParmW,2,ppParm);
	}
	else {
#if 1	/* 2021.4.7 */
		c1 = pInfoParm1->pi_id;
		c2 = pInfoParm2->pi_id;
#endif
		if (!(ret=cl_cons_list(pInfoParmW,1,ppParm))) {
			ret = _list_minus_sub(pInfoParmW->pi_data,1,pInfoParm2,pInfoParm1);
#if 1	/* 2021.4.7 */
			if (c1!=D_DATA_ID_LIST && c1!=D_DATA_ID_NARABI &&
			    (c2==D_DATA_ID_LIST || c2==D_DATA_ID_NARABI))
				pInfoParmW->pi_id = c2;
#endif
		}
	}
/*	pInfoParmW->pi_scale = D_DATA_DATA_FREE;	*/
	return ret;
}

/****************************************/
/*	56									*/
/****************************************/
static int _array_minus_hash(iOpt,nm1,xhp1,xhp2,xhpO)
int iOpt,nm1;
XHASHB *xhp1,*xhp2,*xhpO;
{
	int i,iRc;
	tdtInfoParm *pParmI;
	char *cpKey,*cpDat;

	iRc = 0;
	for (i=1;i<=nm1;i++) {
		xhp1->xha_xhix = i;
		if ((iRc=akxs_xhash2(xhp1,'P',&cpKey,&cpDat)) > 0) {
/*
printf("_array_minus_hash: i=%d key=[%s]\n",i,cpKey);
*/
			memcpy(&pParmI,cpDat,sizeof(tdtInfoParm *));
			if ((iRc=akxs_xhash(xhp2,'R',cpKey)) < 0) break;
			else if ((iOpt && !iRc)||(!iOpt && iRc)) {
				if ((iRc=akxs_xhash2(xhpO,'S',cpKey,&pParmI)) <= 0) {
					if (!iRc) iRc = -100;
					break;
				}
			}
		}
		else if (iRc < 0) break;
		iRc = 0;
	}
	xhp1->xha_xhix = 0;
/*
printf("_array_minus_hash: iRc=%d\n",iRc);
*/
	return iRc;
}

/****************************************/
/*	57									*/
/****************************************/
static int _array_minus_sub(pvParmO,pos,iOpt,
	pInfoParm1,pIndex1,pTBL1,ix1,nm1,
	pInfoParm2,pIndex2,pTBL2,ix2,nm2)
tdtInfoParm **pvParmO;
int pos,iOpt;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
tdtInfoParm ***pTBL1,***pTBL2;
int ix1,ix2,nm1,nm2;
tdtArrayIndex *pIndex1,*pIndex2;
{
	static XHASHB *xhpS=NULL;
	tdtInfoParm *pParmI,**pvParm;
	int iRc,i,iA,count;
/*
printf("_array_minus_sub:Enter pos=%d iopt=%d ix1=%d nm1=%d ix2=%d nm2=%d\n",pos,iOpt,ix1,nm1,ix2,nm2);
*/
	if (xhpS) akxs_xhash_free(xhpS);
	xhpS = NULL;
	if (!(xhpS=akxs_xhash_new(0,10,0))) return -9;

	if (pInfoParm2->pi_id == ' ') {
		if ((iRc=_check_exist(xhpS,pInfoParm2))<0) return iRc;
	}
	else {
		for (i=0;i<nm2;i++,ix2++) {
			if ((iRc=cl_array_get_info_parm(&pParmI,pIndex2,pTBL2,ix2,'r')) < 0) return iRc;
			if (pParmI) {
				if (cl_is_undef_parm(pParmI) || cl_is_null_parm(pParmI)) continue;
				else if ((iRc=_check_exist(xhpS,pParmI))<0) return iRc;
				else if (iRc > 0) continue;
			}
		}
	}

	if (pInfoParm1->pi_id == ' ') {
		iA = 0;
		pParmI = pInfoParm1;
		nm1 = 1;
	}
	else {
		iA = 1;
	}

	pvParm = pvParmO + pos;
	count = pos;
	for (i=0;i<nm1;i++,ix1++) {
		if (iA) {
			if ((iRc=cl_array_get_info_parm(&pParmI,pIndex1,pTBL1,ix1,'r')) < 0) return iRc;
		}
		if (pParmI && !cl_is_undef_parm(pParmI) && !cl_is_null_parm(pParmI)) {
			if ((iRc=_check_exist(xhpS,pParmI)) < 0) return iRc;
			else if ((iOpt && !iRc)||(!iOpt && iRc)) {
				if (iRc=cl_gx_rep_info_set_alloc(pvParm,pParmI,1)) return iRc;
#if 1	/* 2021.8.14 */
				pvParm++;
				count++;
			}
		}
#else
			}
			else if (iOpt != 1) continue;
		}
		else if (iOpt != 1) continue;
		pvParm++;
		count++;
#endif
	}
/*
printf("_array_minus_sub:Exit count=%d\n",count);
*/
	return count;
}

/****************************************/
/*	58									*/
/****************************************/
int cl_gx_array_minus(pInfoParmW,op,pInfoParm1,pInfoParm2)
tdtInfoParm *pInfoParmW;
char       op;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
{
	static XHASHB *xhpS=NULL;
	XHASHB *xhp1,*xhp2,*xhpO;
	tdtInfoParm ***pTBL1,***pTBL2,**pvParmO,*pParmI;
	int iRc,i,nm1,nm2,ix1,ix2,len,iParm[4],*index,size,iA,iOpt;
	tdtArrayIndex tIndex1,tIndex2,*pIndexO;

	if (op == '&') iOpt = 0;
	else if (op == '-') iOpt = 1;
	else iOpt = 2;

	xhp1 = xhp2 = NULL;
	nm1 = nm2 = 1;
	if (pInfoParm1->pi_id != ' ') {
		if (iRc = _get_array_info(1,&pInfoParm1,&tIndex1,&pTBL1,iParm,1)) {
			if (iRc == 2000) xhp1 = tIndex1.xhp;
			else return iRc;
		}
	/*	nm1  = iParm[1];	*/
		nm1  = iParm[3] - iParm[2] + 1;
		ix1  = iParm[2];
	}

	if (pInfoParm2->pi_id != ' ') {
		if (iRc = _get_array_info(1,&pInfoParm2,&tIndex2,&pTBL2,iParm,1)) {
			if (iRc == 2000) xhp2 = tIndex2.xhp;
			else return iRc;
		}
	/*	nm2  = iParm[1];	*/
		nm2  = iParm[3] - iParm[2] + 1;
		ix2  = iParm[2];
	}
/*
printf("cl_gx_array_minus: xhp1=%08x nm1=%d ix1=%d\n",xhp1,nm1,ix1);
printf("cl_gx_array_minus: xhp2=%08x nm2=%d ix2=%d\n",xhp2,nm2,ix2);
*/
	info_parm_clear(pInfoParmW);
	pInfoParmW->pi_id   = 'R';
/*	pInfoParmW->pi_scale = D_DATA_MALLOC | D_DATA_INDEX_FREE;	*/
	pInfoParmW->pi_scale = D_DATA_INDEX_TMP/* | D_DATA_INDEX_FREE*/;
	pInfoParmW->pi_attr = DEF_ZOK_BULK;
	pInfoParmW->pi_dlen  = sizeof(tdtArrayIndex);
#if 1	/* 2021.8.14 */
	if (!(pIndexO = (tdtArrayIndex *)cl_tmp_const_malloc(sizeof(tdtArrayIndex)))) return -1;
#else
	pInfoParmW->pi_pos  = (long)Strdup("");
	if (!(pIndexO = (tdtArrayIndex *)Malloc(sizeof(tdtArrayIndex)))) return -1;
#endif
	memset(pIndexO,0,sizeof(tdtArrayIndex));
	pInfoParmW->pi_data    = (char *)pIndexO;
	index = pIndexO->index;
	pIndexO->size = size = sizeof(tdtInfoParm *);
	pIndexO->uAttr[0] = DEF_ZOK_VARI;

	if (xhp1 && xhp2) {
		index[4] = tIndex1.index[4];
#if 1	/* 2021.9.9 */
		if (!(pIndexO->xhp=xhpO=akxs_xhashm_new2(0,index[4],0,size,cl_tmp_const_malloc,NULL))) return -9;
#else
		if (!(pIndexO->xhp=xhpO=akxs_xhash_new2(0,index[4],0,size))) return -9;
#endif
		if ((iRc=_array_minus_hash(iOpt,nm1,xhp1,xhp2,xhpO)) < 0) return iRc;
		if (iOpt == 2) {
			if ((iRc=_array_minus_hash(iOpt,nm2,xhp2,xhp1,xhpO)) < 0) return iRc;
		}
		return 0;
	}

	index[0] = 1;
	index[2] = 0;
	index[3] = 1;
	if (iOpt == 2) index[4] = nm1 + nm2;
	else index[4] = X_MAX(nm1,nm2);
	index[1] = index[4];	/* 2020.4.30 */
	index[5] = 0;
	len = index[4]*pIndexO->size;
#if 1	/* 2021.9.9 */
	if (!(pvParmO=(tdtInfoParm **)cl_tmp_const_malloc(len))) return -10;
#else
	if (!(pvParmO=(tdtInfoParm **)Malloc(len))) return -10;
#endif
	memset(pvParmO,0,len);
	pIndexO->pVarIndex = pvParmO;

	if ((iRc=_array_minus_sub(pvParmO,0,iOpt,
	                        pInfoParm1,&tIndex1,pTBL1,ix1,nm1,
	                        pInfoParm2,&tIndex2,pTBL2,ix2,nm2)) < 0) return iRc;
	if (iOpt == 2) {
		if ((iRc=_array_minus_sub(pvParmO,iRc,iOpt,
		                        pInfoParm2,&tIndex2,pTBL2,ix2,nm2,
		                        pInfoParm1,&tIndex1,pTBL1,ix1,nm1)) < 0) return iRc;
	}
	index[2] = iRc;
	if (iRc > 0) {
		index[1] = index[4] = iRc;
	}
	return 0;
}

/****************************************/
/*	61									*/
/****************************************/
int cl_set_struct(pWork,pInfoParm,nparm,ppParm)
tdtInfoParm *pInfoParm,*ppParm[];
int *pWork,nparm;
{
	int  j,rc,ntype,size,count;
	char id;
	tdtInfoParm *pParmO,**ppParmW,tInfoParm;
	tdtDefType *pDeftype;

	count = 0;
	*pWork = 0;
	pDeftype = (tdtDefType *)pInfoParm->pi_data;
	ntype = X_MIN(pDeftype->ntype,nparm);
/*
printf("cl_set_struct: ntype=%d\n",ntype);
*/
	for (j=0;j<ntype;j++) {
		pParmO = pDeftype->pType[j];
DEBUGOUT_InfoParm(161,"cl_set_struct:pParmIO: j=%d",pParmO,j,0);
		id = pParmO->pi_id;
		if (id=='R' || id=='A') {
			if (!(ppParmW=(tdtInfoParm **)cl_tmp_const_malloc(sizeof(tdtInfoParm *)*(nparm-j+2)))) return ECL_MALLOC_ERROR;
			ppParmW[0] = pParmO;
			ppParmW[1] = &tInfoParm;
			cl_set_parm_bin(&tInfoParm,0);
			mem_cpy_addr(&ppParmW[2],&ppParm[j],nparm-j);
			rc = cl_set_array(&size,nparm-j+2,ppParmW);
			count += size;
		}
		else if (id == 'T') {
			rc = cl_set_struct(&size,pParmO,nparm-j,&ppParm[j]);
			count += size;
		}
		else {	/*if ((id=pParmO->pi_id) == ' ') {*/
			if (!cl_is_null_parm(pInfoParm)) {
				rc = cl_gx_rep_info_set(pParmO,ppParm[j],1);
				count++;
			}
		}
	}
	*pWork = count;
	return rc;
}

/****************************************/
/*	62									*/
/****************************************/
int cl_func_set_struct(pWork,nparm,ppParm)
char *pWork;
int  nparm;
tdtInfoParm *ppParm[];
{
	int rc;

	rc = cl_check_data_id(ppParm[0],~0x10);
	if (rc < 0) {
		rc = ECL_SCRIPT_ERROR;
	}
	else {
		rc = cl_set_struct(pWork,ppParm[0],nparm-1,&ppParm[1]);
	}
	return rc;
}
