On Fri, Mar 22, 2013 at 6:42 PM, David Korn <[email protected]> wrote:
> 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.
I want to do this with ksh93v- only. I want to create a *variable* of
type _Bool, i.e. the C equivalent of this shell code:
bool myboolean=true
Of course this is translated to:
_Bool myboolean=true
How do I do that from C?
>
>> 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.
if I have the type pointer from nv_type(np), how can I figure out if
the type is of type _Bool?
>>
>> Simon
>>
>
> David Korn
> [email protected]
Simon
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers