1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

nv_associative(): finally use proper check for enum (re: b98e32fc)

As of the previous commit, I finally know how to properly check for
a variable of a type created by 'enum'. We need to check for both
the NV_UINT16 attribute and the ENUM_disc discipline.

Also:
- regression test tweaks
- add missing tests for previous commit (f600a5ea)
This commit is contained in:
Martijn Dekker 2021-11-24 01:11:55 +01:00
parent a66cd72f7d
commit e3d91ffa90
3 changed files with 25 additions and 10 deletions

View file

@ -1777,11 +1777,11 @@ void *nv_associative(register Namval_t *np,const char *sp,int mode)
if(sh.subshell)
np = sh_assignok(np,1);
/*
* type == NV_UINT16 (16-bit unsigned integer, see include/nval.h) indicates an
* associative array of a type created by the enum command. nelem should not be
* increased in that case or 'unset' will fail to completely unset such an array.
* For enum types (NV_UINT16 with discipline ENUM_disc), nelem should not
* not increased or 'unset' will fail to completely unset such an array.
*/
if(type != NV_UINT16 && (!ap->header.scope || !nv_search(sp,dtvnext(ap->header.table),0)))
if((!ap->header.scope || !nv_search(sp,dtvnext(ap->header.table),0))
&& !(type==NV_UINT16 && nv_hasdisc(np, &ENUM_disc)))
ap->header.nelem++;
if(nv_isnull(mp))
{