cc: [email protected]
Subject: Re: Re: Re: Re: [ast-developers] Create _Bool variable from C code?
--------

> >> How can I figure out if the type is of type _Bool when I have the
> >> pointer returned by nv_type(np)?
> >>
> >>
> >         nv_type(np)->nvname
If np is not a type then nv_type() returns NULL so you can't get the
name witout first checking for the type.
> 
> I tried the suggestion and was granted a SEGV ;(
> 
> Does this look correct to you?
> 
> bt=nv_search("_Bool",shp->bltin_tree,0);
> np = nv_open(shp->var_tree,...);
> nv_settype(np, bt, 0);
> 
> The code gives me this SEGV:
> (gdb) where
> #0  0x0000000000803200 in sh ()
> #1  0x0000000000495e91 in clone_all_disc (np=0x7ffff7ee2700,
> mp=0x7ffff7f29ca0, flags=512) at src/cmd/ksh93/sh/nvdisc.c:893
> #2  0x00000000004960d0 in nv_clone (np=0x7ffff7ee2700,
> mp=0x7ffff7f29ca0, flags=512) at src/cmd/ksh93/sh/nvdisc.c:944
> #3  0x000000000049cd16 in nv_settype (np=0x7ffff7f29ca0,
> tp=0x7ffff7ee2700, flags=0) at src/cmd/ksh93/sh/nvtype.c:1437
> 
> Simon
> 

This is not correct.
bt=nv_search("_Bool",shp->bltin_tree,0);

will give a pointer the the built-in that creates an instance of bool.
        bt = nv_open(".sh.type._Bool",shp->var_base,NV_NOADD|NV_VARNAME);
should give you a pointer to the type _Bool if it exists.

David Korn
[email protected]
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to