mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix 'typeset -p' output of compound array types (#453)
This bugfix was backported from ksh93v- 2012-10-04. The bug fixed by this change is one that causes 'typeset -p' to omit the -C flag when listing compound arrays belonging to a type: $ typeset -T Foo_t=(compound -a bar) $ Foo_t baz $ typeset -p baz.bar typeset -a baz.bar='' # This should be 'typeset -C -a' src/cmd/ksh93/sh/nvtype.c: - Backport change from 93v- 2012-10-04 that sets the array nvalue to a pointer named Null (which is "") in nv_mktype(), then to Empty in fixnode(). - Change the Null name from the 93v- code to AltEmpty to avoid misleading code readers into thinking that it's a null pointer. src/cmd/ksh93/tests/types.sh: - Backport the relevant 93v- changes to the types regression tests. Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
parent
787058bdbf
commit
7d4c7d9156
3 changed files with 25 additions and 6 deletions
|
|
@ -139,6 +139,8 @@ static const Namdisc_t type_disc =
|
|||
0,
|
||||
};
|
||||
|
||||
static char *AltEmpty = "";
|
||||
|
||||
size_t nv_datasize(Namval_t *np, size_t *offset)
|
||||
{
|
||||
size_t s=0, a=0;
|
||||
|
|
@ -333,6 +335,8 @@ static int fixnode(Namtype_t *dp, Namtype_t *pp, int i, struct Namref *nrp,int f
|
|||
nv_offattr(nq,NV_NOFREE);
|
||||
}
|
||||
}
|
||||
else if(nq->nvalue.cp==AltEmpty)
|
||||
nq->nvalue.cp = Empty;
|
||||
else if(nq->nvalue.cp==Empty)
|
||||
nv_offattr(nq,NV_NOFREE);
|
||||
|
||||
|
|
@ -1159,7 +1163,12 @@ Namval_t *nv_mktype(Namval_t **nodes, int numnodes)
|
|||
free((void*)np->nvalue.cp);
|
||||
}
|
||||
if(!nq->nvalue.cp && nq->nvfun== &pp->childfun.fun)
|
||||
nq->nvalue.cp = Empty;
|
||||
{
|
||||
if(nv_isattr(np,NV_ARRAY|NV_NOFREE)==(NV_ARRAY|NV_NOFREE))
|
||||
nq->nvalue.cp = AltEmpty;
|
||||
else
|
||||
nq->nvalue.cp = Empty;
|
||||
}
|
||||
np->nvalue.cp = 0;
|
||||
offset += (dsize?dsize:4);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue