Skip to content

Commit

Permalink
Fix SHOPT_KIA after sh_lexopen() full reset change (re: 2e000c9)
Browse files Browse the repository at this point in the history
It broke SHOPT_KIA, which (when enabled) adds its own lexer struct
data, which should not ever be reset for ksh's -R option to work.
This was not noticed sooner because SHOPT_KIA code is not compiled
in by default (it needs to be enabled in SHOPT.sh).

I could revert that commit, but I'd rather divorce the KIA stuff
from the lexer struct.

src/cmd/ksh93/include/shlex.h,
src/cmd/ksh93/sh/defs.c:
- Sepaerate all the KIA stuff into one struct type named Kia_t.
- Declare a global Kia_t variable named 'kia'.

src/cmd/ksh93/sh/{lex,parse,args}.c:
- Update all references to KIA-related lexer struct members.
McDutchie committed Nov 29, 2024
1 parent 0ebaab3 commit 26eec12
Showing 6 changed files with 95 additions and 92 deletions.
2 changes: 0 additions & 2 deletions src/cmd/ksh93/Mamfile
Original file line number Diff line number Diff line change
@@ -592,8 +592,6 @@ make install virtual
done

make sh/defs.c
prev include/timeout.h
prev include/edit.h
prev include/shlex.h
prev include/jobs.h
prev include/defs.h
31 changes: 17 additions & 14 deletions src/cmd/ksh93/include/shlex.h
Original file line number Diff line number Diff line change
@@ -61,9 +61,6 @@ struct _shlex_pvt_lexdata_
int lastc;
int lex_state;
int docextra;
#if SHOPT_KIA
off_t kiaoff;
#endif
};

/*
@@ -88,17 +85,6 @@ typedef struct _shlex_
int inlineno; /* saved value of sh.inlineno */
int firstline; /* saved value of sh.st.firstline */
int assignlevel; /* nesting level for assignment */
#if SHOPT_KIA
Sfio_t *kiafile; /* kia output file */
Sfio_t *kiatmp; /* kia reference file */
unsigned long script; /* script entity number */
unsigned long fscript; /* script file entity number */
unsigned long current; /* current entity number */
unsigned long unknown; /* <unknown> entity number */
off_t kiabegin; /* offset of first entry */
char *scriptname; /* name of script file */
Dt_t *entity_tree; /* for entity IDs */
#endif /* SHOPT_KIA */
/* The following two struct members are considered private to lex.c */
struct _shlex_pvt_lexdata_ lexd;
struct _shlex_pvt_lexstate_ lex;
@@ -181,7 +167,24 @@ extern Shnode_t *sh_dolparen(Lex_t*);
extern Lex_t *sh_lexopen(Lex_t*, int);
extern void sh_lexskip(Lex_t*,int,int,int);
extern noreturn void sh_syntax(Lex_t*, int);

#if SHOPT_KIA
typedef struct
{
off_t offset;
Sfio_t *file; /* kia output file */
Sfio_t *tmp; /* kia reference file */
unsigned long script; /* script entity number */
unsigned long fscript; /* script file entity number */
unsigned long current; /* current entity number */
unsigned long unknown; /* <unknown> entity number */
off_t begin; /* offset of first entry */
char *scriptname; /* name of script file */
Dt_t *entity_tree; /* for entity IDs */
} Kia_t;

extern Kia_t kia;

extern int kiaclose(Lex_t *);
extern unsigned long kiaentity(Lex_t*, const char*,int,int,int,int,unsigned long,int,int,const char*);
#endif /* SHOPT_KIA */
22 changes: 11 additions & 11 deletions src/cmd/ksh93/sh/args.c
Original file line number Diff line number Diff line change
@@ -336,25 +336,25 @@ int sh_argopts(int argc,char *argv[])
errormsg(SH_DICT,ERROR_usage(2),"-R requires scriptname");
UNREACHABLE();
}
if(!(lp->kiafile=sfopen(NULL,ap->kiafile,"w+")))
if(!(kia.file=sfopen(NULL,ap->kiafile,"w+")))
{
errormsg(SH_DICT,ERROR_system(3),e_create,ap->kiafile);
UNREACHABLE();
}
if(!(lp->kiatmp=sftmp(2*SFIO_BUFSIZE)))
if(!(kia.tmp=sftmp(2*SFIO_BUFSIZE)))
{
errormsg(SH_DICT,ERROR_system(3),e_tmpcreate);
UNREACHABLE();
}
sfputr(lp->kiafile,";vdb;CIAO/ksh",'\n');
lp->kiabegin = sftell(lp->kiafile);
lp->entity_tree = dtopen(&_Nvdisc,Dtbag);
lp->scriptname = sh_strdup(sh_fmtq(argv[0]));
lp->script=kiaentity(lp,lp->scriptname,-1,'p',-1,0,0,'s',0,"");
lp->fscript=kiaentity(lp,lp->scriptname,-1,'f',-1,0,0,'s',0,"");
lp->unknown=kiaentity(lp,"<unknown>",-1,'p',-1,0,0,'0',0,"");
kiaentity(lp,"<unknown>",-1,'p',0,0,lp->unknown,'0',0,"");
lp->current = lp->script;
sfputr(kia.file,";vdb;CIAO/ksh",'\n');
kia.begin = sftell(kia.file);
kia.entity_tree = dtopen(&_Nvdisc,Dtbag);
kia.scriptname = sh_strdup(sh_fmtq(argv[0]));
kia.script=kiaentity(lp,kia.scriptname,-1,'p',-1,0,0,'s',0,"");
kia.fscript=kiaentity(lp,kia.scriptname,-1,'f',-1,0,0,'s',0,"");
kia.unknown=kiaentity(lp,"<unknown>",-1,'p',-1,0,0,'0',0,"");
kiaentity(lp,"<unknown>",-1,'p',0,0,kia.unknown,'0',0,"");
kia.current = kia.script;
ap->kiafile = 0;
}
#endif /* SHOPT_KIA */
8 changes: 5 additions & 3 deletions src/cmd/ksh93/sh/defs.c
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* Copyright (c) 2020-2024 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 2.0 *
* *
@@ -25,8 +25,6 @@
#include "defs.h"
#include "jobs.h"
#include "shlex.h"
#include "edit.h"
#include "timeout.h"

Shell_t sh = {0};

@@ -40,3 +38,7 @@ char *sh_lexstates[ST_NONE] = {0};

struct jobs job = {0};
int32_t sh_mailchk = 600;

#if SHOPT_KIA
Kia_t kia;
#endif
32 changes: 16 additions & 16 deletions src/cmd/ksh93/sh/lex.c
Original file line number Diff line number Diff line change
@@ -89,33 +89,33 @@ static void refvar(Lex_t *lp, int type)
if(lp->lexd.first)
{
off = (fcseek(0)-(type+1)) - lp->lexd.first;
r=kiaentity(lp,lp->lexd.first+lp->lexd.kiaoff+type,off-lp->lexd.kiaoff,'v',-1,-1,lp->current,'v',0,"");
r=kiaentity(lp,lp->lexd.first+kia.offset+type,off-kia.offset,'v',-1,-1,kia.current,'v',0,"");
}
else
{
int n,offset = stktell(sh.stk);
void *savptr;
char *begin;
off = offset + (fcseek(0)-(type+1)) - fcfirst();
if(lp->lexd.kiaoff < offset)
if(kia.offset < offset)
{
/* variable starts on stack, copy remainder */
if(off>offset)
sfwrite(sh.stk,fcfirst()+type,off-offset);
n = stktell(sh.stk)-lp->lexd.kiaoff;
begin = stkptr(sh.stk,lp->lexd.kiaoff);
n = stktell(sh.stk)-kia.offset;
begin = stkptr(sh.stk,kia.offset);
}
else
{
/* variable in data buffer */
begin = fcfirst()+(type+lp->lexd.kiaoff-offset);
n = off-lp->lexd.kiaoff;
begin = fcfirst()+(type+kia.offset-offset);
n = off-kia.offset;
}
savptr = stkfreeze(sh.stk,0);
r=kiaentity(lp,begin,n,'v',-1,-1,lp->current,'v',0,"");
r=kiaentity(lp,begin,n,'v',-1,-1,kia.current,'v',0,"");
stkset(sh.stk,savptr,offset);
}
sfprintf(lp->kiatmp,"p;%..64d;v;%..64d;%d;%d;r;\n",lp->current,r,sh.inlineno,sh.inlineno);
sfprintf(kia.tmp,"p;%..64d;v;%..64d;%d;%d;r;\n",kia.current,r,sh.inlineno,sh.inlineno);
}
#endif /* SHOPT_KIA */

@@ -153,7 +153,7 @@ static void lex_advance(Sfio_t *iop, const char *buff, int size, void *context)
if(!lp->lexd.inlexskip)
lp->arg = stkseek(sh.stk,ARGVAL);
#if SHOPT_KIA
lp->lexd.kiaoff += ARGVAL;
kia.offset += ARGVAL;
#endif /* SHOPT_KIA */
}
if(size>0 && (lp->arg||lp->lexd.inlexskip))
@@ -814,9 +814,9 @@ int sh_lex(Lex_t* lp)
continue;
#if SHOPT_KIA
if(lp->lexd.first)
lp->lexd.kiaoff = fcseek(0)-lp->lexd.first;
kia.offset = fcseek(0)-lp->lexd.first;
else
lp->lexd.kiaoff = stktell(sh.stk)+fcseek(0)-fcfirst();
kia.offset = stktell(sh.stk)+fcseek(0)-fcfirst();
#endif /* SHOPT_KIA */
pushlevel(lp,'$',mode);
mode = ST_DOL;
@@ -843,7 +843,7 @@ int sh_lex(Lex_t* lp)
case S_EDOL:
/* end $identifier */
#if SHOPT_KIA
if(lp->kiafile)
if(kia.file)
refvar(lp,0);
#endif /* SHOPT_KIA */
if(lp->lexd.warn && c==LBRACT && !lp->lex.intest && !lp->lexd.arith && oldmode(lp)!= ST_NESTED)
@@ -960,7 +960,7 @@ int sh_lex(Lex_t* lp)
continue;
case S_MOD2:
#if SHOPT_KIA
if(lp->kiafile)
if(kia.file)
refvar(lp,1);
#endif /* SHOPT_KIA */
if(c!=':' && fcgetc(n)>0)
@@ -2465,11 +2465,11 @@ static void setupalias(Lex_t *lp, const char *string,Namval_t *np)
if(ap->np = np)
{
#if SHOPT_KIA
if(lp->kiafile)
if(kia.file)
{
unsigned long r;
r=kiaentity(lp,nv_name(np),-1,'p',0,0,lp->current,'a',0,"");
sfprintf(lp->kiatmp,"p;%..64d;p;%..64d;%d;%d;e;\n",lp->current,r,sh.inlineno,sh.inlineno);
r=kiaentity(lp,nv_name(np),-1,'p',0,0,kia.current,'a',0,"");
sfprintf(kia.tmp,"p;%..64d;p;%..64d;%d;%d;e;\n",kia.current,r,sh.inlineno,sh.inlineno);
}
#endif /* SHOPT_KIA */
if((ap->nextc=fcget())==0)
92 changes: 46 additions & 46 deletions src/cmd/ksh93/sh/parse.c
Original file line number Diff line number Diff line change
@@ -85,10 +85,10 @@ static unsigned long writedefs(Lex_t *lexp,struct argnod *arglist, int line, int
static char atbuff[20];
int justify=0;
char *attribute = atbuff;
unsigned long parent=lexp->script;
unsigned long parent=kia.script;
if(type==0)
{
parent = lexp->current;
parent = kia.current;
type = 'v';
switch(*argp->argval)
{
@@ -123,7 +123,7 @@ static unsigned long writedefs(Lex_t *lexp,struct argnod *arglist, int line, int
}
}
else if(cmd)
parent=kiaentity(lexp,sh_argstr(cmd),-1,'p',-1,-1,lexp->unknown,'b',0,"");
parent=kiaentity(lexp,sh_argstr(cmd),-1,'p',-1,-1,kia.unknown,'b',0,"");
*attribute = 0;
while(argp)
{
@@ -133,7 +133,7 @@ static unsigned long writedefs(Lex_t *lexp,struct argnod *arglist, int line, int
n = strlen(argp->argval);
eline = sh.inlineno-(lexp->token==NL);
r=kiaentity(lexp,argp->argval,n,type,line,eline,parent,justify,width,atbuff);
sfprintf(lexp->kiatmp,"p;%..64d;v;%..64d;%d;%d;s;\n",lexp->current,r,line,eline);
sfprintf(kia.tmp,"p;%..64d;v;%..64d;%d;%d;s;\n",kia.current,r,line,eline);
argp = argp->argnxt.ap;
}
return r;
@@ -815,7 +815,7 @@ static Shnode_t *funct(Lex_t *lexp)
struct functnod *volatile fp;
Sfio_t *iop;
#if SHOPT_KIA
unsigned long current = lexp->current;
unsigned long current = kia.current;
#endif /* SHOPT_KIA */
int nargs=0,size=0,jmpval;
struct checkpt buff;
@@ -839,8 +839,8 @@ static Shnode_t *funct(Lex_t *lexp)
}
t->funct.functnam= (char*)lexp->arg->argval;
#if SHOPT_KIA
if(lexp->kiafile)
lexp->current = kiaentity(lexp,t->funct.functnam,-1,'p',-1,-1,lexp->script,'p',0,"");
if(kia.file)
kia.current = kiaentity(lexp,t->funct.functnam,-1,'p',-1,-1,kia.script,'p',0,"");
#endif /* SHOPT_KIA */
if(flag)
lexp->token = sh_lex(lexp);
@@ -939,7 +939,7 @@ static Shnode_t *funct(Lex_t *lexp)
slp->slchild = sh.st.staklist;
}
#if SHOPT_KIA
lexp->current = current;
kia.current = current;
#endif /* SHOPT_KIA */
if(jmpval)
{
@@ -956,8 +956,8 @@ static Shnode_t *funct(Lex_t *lexp)
fp->functtre = t;
sh.mktype = in_mktype;
#if SHOPT_KIA
if(lexp->kiafile)
kiaentity(lexp,t->funct.functnam,-1,'p',t->funct.functline,sh.inlineno-1,lexp->current,'p',0,"");
if(kia.file)
kiaentity(lexp,t->funct.functnam,-1,'p',t->funct.functline,sh.inlineno-1,kia.current,'p',0,"");
#endif /* SHOPT_KIA */
t->funct.functtyp |= opt_get;
opt_get = save_optget;
@@ -1283,7 +1283,7 @@ static Shnode_t *item(Lex_t *lexp,int flag)
t->for_.fornam=(char*) lexp->arg->argval;
t->for_.fortyp |= FLINENO;
#if SHOPT_KIA
if(lexp->kiafile)
if(kia.file)
writedefs(lexp,lexp->arg,sh.inlineno,'v',NULL);
#endif /* SHOPT_KIA */
while((tok=sh_lex(lexp))==NL);
@@ -1597,18 +1597,18 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
*argtail = 0;
t->comtyp = TCOM;
#if SHOPT_KIA
if(lexp->kiafile && !(flag&SH_NOIO))
if(kia.file && !(flag&SH_NOIO))
{
Namval_t *np=(Namval_t*)t->comnamp;
unsigned long r=0;
int line = t->comline;
argp = t->comarg.ap;
if(np)
r = kiaentity(lexp,nv_name(np),-1,'p',-1,0,lexp->unknown,'b',0,"");
r = kiaentity(lexp,nv_name(np),-1,'p',-1,0,kia.unknown,'b',0,"");
else if(argp)
r = kiaentity(lexp,sh_argstr(argp),-1,'p',-1,0,lexp->unknown,'c',0,"");
r = kiaentity(lexp,sh_argstr(argp),-1,'p',-1,0,kia.unknown,'c',0,"");
if(r>0)
sfprintf(lexp->kiatmp,"p;%..64d;p;%..64d;%d;%d;c;\n",lexp->current,r,line,line);
sfprintf(kia.tmp,"p;%..64d;p;%..64d;%d;%d;c;\n",kia.current,r,line,line);
if(t->comset && argno==0)
writedefs(lexp,t->comset,line,'v',t->comarg.ap);
else if(np && nv_isattr(np,BLT_DCL))
@@ -1617,8 +1617,8 @@ static Shnode_t *simple(Lex_t *lexp,int flag, struct ionod *io)
writedefs(lexp,argp,line,0,NULL);
else if(argp && *argp->argval=='.' && argp->argval[1]==0 && (argp=argp->argnxt.ap))
{
r = kiaentity(lexp,sh_argstr(argp),-1,'p',0,0,lexp->script,'d',0,"");
sfprintf(lexp->kiatmp,"p;%..64d;p;%..64d;%d;%d;d;\n",lexp->current,r,line,line);
r = kiaentity(lexp,sh_argstr(argp),-1,'p',0,0,kia.script,'d',0,"");
sfprintf(kia.tmp,"p;%..64d;p;%..64d;%d;%d;d;\n",kia.current,r,line,line);
}
}
#endif /* SHOPT_KIA */
@@ -1773,13 +1773,13 @@ static struct ionod *inout(Lex_t *lexp,struct ionod *lastio,int flag)
/* allow alias substitutions and parameter assignments */
lexp->aliasok = lexp->assignok = 1;
#if SHOPT_KIA
if(lexp->kiafile)
if(kia.file)
{
int n = sh.inlineno-(lexp->token=='\n');
if(!(iof&IOMOV))
{
unsigned long r=kiaentity(lexp,(iof&IORAW)?sh_fmtq(iop->ioname):iop->ioname,-1,'f',0,0,lexp->script,'f',0,"");
sfprintf(lexp->kiatmp,"p;%..64d;f;%..64d;%d;%d;%c;%d\n",lexp->current,r,n,n,(iof&IOPUT)?((iof&IOAPP)?'a':'w'):((iof&IODOC)?'h':'r'),iof&IOUFD);
unsigned long r=kiaentity(lexp,(iof&IORAW)?sh_fmtq(iop->ioname):iop->ioname,-1,'f',0,0,kia.script,'f',0,"");
sfprintf(kia.tmp,"p;%..64d;f;%..64d;%d;%d;%c;%d\n",kia.current,r,n,n,(iof&IOPUT)?((iof&IOAPP)?'a':'w'):((iof&IODOC)?'h':'r'),iof&IOUFD);
}
}
#endif /* SHOPT_KIA */
@@ -1936,12 +1936,12 @@ static Shnode_t *test_primary(Lex_t *lexp)
if(sh_lex(lexp))
sh_syntax(lexp,0);
#if SHOPT_KIA
if(lexp->kiafile && !strchr("sntzoOG",num))
if(kia.file && !strchr("sntzoOG",num))
{
int line = sh.inlineno- (lexp->token==NL);
unsigned long r;
r=kiaentity(lexp,sh_argstr(lexp->arg),-1,'f',0,0,lexp->script,'t',0,"");
sfprintf(lexp->kiatmp,"p;%..64d;f;%..64d;%d;%d;t;\n",lexp->current,r,line,line);
r=kiaentity(lexp,sh_argstr(lexp->arg),-1,'f',0,0,kia.script,'t',0,"");
sfprintf(kia.tmp,"p;%..64d;f;%..64d;%d;%d;t;\n",kia.current,r,line,line);
}
#endif /* SHOPT_KIA */
t = makelist(lexp,TTST|TTEST|TUNARY|(num<<TSHIFT),
@@ -1974,12 +1974,12 @@ static Shnode_t *test_primary(Lex_t *lexp)
else
sh_syntax(lexp,0);
#if SHOPT_KIA
if(lexp->kiafile && (num==TEST_EF||num==TEST_NT||num==TEST_OT))
if(kia.file && (num==TEST_EF||num==TEST_NT||num==TEST_OT))
{
int line = sh.inlineno- (lexp->token==NL);
unsigned long r;
r=kiaentity(lexp,sh_argstr(lexp->arg),-1,'f',0,0,lexp->current,'t',0,"");
sfprintf(lexp->kiatmp,"p;%..64d;f;%..64d;%d;%d;t;\n",lexp->current,r,line,line);
r=kiaentity(lexp,sh_argstr(lexp->arg),-1,'f',0,0,kia.current,'t',0,"");
sfprintf(kia.tmp,"p;%..64d;f;%..64d;%d;%d;t;\n",kia.current,r,line,line);
}
#endif /* SHOPT_KIA */
if(sh_lex(lexp))
@@ -1996,12 +1996,12 @@ static Shnode_t *test_primary(Lex_t *lexp)
t->lst.lstrit = (Shnode_t*)lexp->arg;
t->tst.tstline = sh.inlineno;
#if SHOPT_KIA
if(lexp->kiafile && (num==TEST_EF||num==TEST_NT||num==TEST_OT))
if(kia.file && (num==TEST_EF||num==TEST_NT||num==TEST_OT))
{
int line = sh.inlineno-(lexp->token==NL);
unsigned long r;
r=kiaentity(lexp,sh_argstr(lexp->arg),-1,'f',0,0,lexp->current,'t',0,"");
sfprintf(lexp->kiatmp,"p;%..64d;f;%..64d;%d;%d;t;\n",lexp->current,r,line,line);
r=kiaentity(lexp,sh_argstr(lexp->arg),-1,'f',0,0,kia.current,'t',0,"");
sfprintf(kia.tmp,"p;%..64d;f;%..64d;%d;%d;t;\n",kia.current,r,line,line);
}
#endif /* SHOPT_KIA */
break;
@@ -2041,7 +2041,7 @@ unsigned long kiaentity(Lex_t *lexp,const char *name,int len,int type,int first,
sfputr(sh.stk,name,0);
}
sfputc(sh.stk,'\0'); /* terminate name while writing database output */
np = nv_search(stkptr(sh.stk,offset),lexp->entity_tree,NV_ADD);
np = nv_search(stkptr(sh.stk,offset),kia.entity_tree,NV_ADD);
stkseek(sh.stk,offset);
np->nvalue.i = pkind;
nv_setsize(np,width);
@@ -2051,9 +2051,9 @@ unsigned long kiaentity(Lex_t *lexp,const char *name,int len,int type,int first,
if(!pkind)
pkind = '0';
if(len>0)
sfprintf(lexp->kiafile,"%..64d;%c;%.*s;%d;%d;%..64d;%..64d;%c;%d;%s\n",np->hash,type,len,name,first,last,parent,lexp->fscript,pkind,width,attr);
sfprintf(kia.file,"%..64d;%c;%.*s;%d;%d;%..64d;%..64d;%c;%d;%s\n",np->hash,type,len,name,first,last,parent,kia.fscript,pkind,width,attr);
else
sfprintf(lexp->kiafile,"%..64d;%c;%s;%d;%d;%..64d;%..64d;%c;%d;%s\n",np->hash,type,name,first,last,parent,lexp->fscript,pkind,width,attr);
sfprintf(kia.file,"%..64d;%c;%s;%d;%d;%..64d;%..64d;%c;%d;%s\n",np->hash,type,name,first,last,parent,kia.fscript,pkind,width,attr);
}
return np->hash;
}
@@ -2064,31 +2064,31 @@ static void kia_add(Namval_t *np, void *data)
char *name = nv_name(np);
Lex_t *lp = (Lex_t*)data;
NOT_USED(data);
kiaentity(lp,name+1,-1,*name,0,-1,(*name=='p'?lp->unknown:lp->script),np->nvalue.i,nv_size(np),"");
kiaentity(lp,name+1,-1,*name,0,-1,(*name=='p'?kia.unknown:kia.script),np->nvalue.i,nv_size(np),"");
}

int kiaclose(Lex_t *lexp)
{
off_t off1,off2;
int n;
if(lexp->kiafile)
if(kia.file)
{
unsigned long r = kiaentity(lexp,lexp->scriptname,-1,'p',-1,sh.inlineno-1,0,'s',0,"");
kiaentity(lexp,lexp->scriptname,-1,'p',1,sh.inlineno-1,r,'s',0,"");
kiaentity(lexp,lexp->scriptname,-1,'f',1,sh.inlineno-1,r,'s',0,"");
nv_scan(lexp->entity_tree,kia_add,lexp,NV_TAGGED,0);
off1 = sfseek(lexp->kiafile,0,SEEK_END);
sfseek(lexp->kiatmp,0,SEEK_SET);
sfmove(lexp->kiatmp,lexp->kiafile,SFIO_UNBOUND,-1);
off2 = sfseek(lexp->kiafile,0,SEEK_END);
unsigned long r = kiaentity(lexp,kia.scriptname,-1,'p',-1,sh.inlineno-1,0,'s',0,"");
kiaentity(lexp,kia.scriptname,-1,'p',1,sh.inlineno-1,r,'s',0,"");
kiaentity(lexp,kia.scriptname,-1,'f',1,sh.inlineno-1,r,'s',0,"");
nv_scan(kia.entity_tree,kia_add,lexp,NV_TAGGED,0);
off1 = sfseek(kia.file,0,SEEK_END);
sfseek(kia.tmp,0,SEEK_SET);
sfmove(kia.tmp,kia.file,SFIO_UNBOUND,-1);
off2 = sfseek(kia.file,0,SEEK_END);
if(off2==off1)
n= sfprintf(lexp->kiafile,"DIRECTORY\nENTITY;%lld;%d\nDIRECTORY;",(Sflong_t)lexp->kiabegin,(size_t)(off1-lexp->kiabegin));
n= sfprintf(kia.file,"DIRECTORY\nENTITY;%lld;%d\nDIRECTORY;",(Sflong_t)kia.begin,(size_t)(off1-kia.begin));
else
n= sfprintf(lexp->kiafile,"DIRECTORY\nENTITY;%lld;%d\nRELATIONSHIP;%lld;%d\nDIRECTORY;",(Sflong_t)lexp->kiabegin,(size_t)(off1-lexp->kiabegin),(Sflong_t)off1,(size_t)(off2-off1));
n= sfprintf(kia.file,"DIRECTORY\nENTITY;%lld;%d\nRELATIONSHIP;%lld;%d\nDIRECTORY;",(Sflong_t)kia.begin,(size_t)(off1-kia.begin),(Sflong_t)off1,(size_t)(off2-off1));
if(off2 >= INT_MAX)
off2 = -(n+12);
sfprintf(lexp->kiafile,"%010.10lld;%010d\n",(Sflong_t)off2+10, n+12);
sfprintf(kia.file,"%010.10lld;%010d\n",(Sflong_t)off2+10, n+12);
}
return sfclose(lexp->kiafile);
return sfclose(kia.file);
}
#endif /* SHOPT_KIA */

0 comments on commit 26eec12

Please sign in to comment.