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

> I'm trying to teach me to write my own shell using libshell but hit
> two questions:
> 1. How can I create an enum variable of type _Bool (i.e. the builtin
> "bool" type) from C code using the nv* functions and without resorting
> to using b_eval()?
In ksh93u+, you can do
        enum _Bool=(false true)
In ksh93v- this is predefined and there is a preset alias bool=_Bool.
If you are asking how to do this in C, the simplist way is with an
eval which is what ksh93v- uses.  Otherwise, you need to create an
array of true and false, and apply the discipline function as is done
in bltins/enum.c.  You should be able to call b_enum() to do this.

> 2. How can I test whether a variable opened with nv_open is of type _Bool?
print ${@var}
If you are asking how to do this from C code, use nv_type(np) where np
is a pointer to a variable.  It returns a pointer to the type of NULL
if there is no type.
> 
> Simon
> 

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

Reply via email to