[GRASS-dev] using G_parser() --script in the wild

Hamish hamish_nospam at yahoo.com
Wed Feb 28 23:31:12 EST 2007


Glynn Clements wrote:
> NULL and "" aren't the same thing. Modules which test whether an
> optional (non-required) option was used normally test whether
> "opt->answer == NULL". The only way to create this situation is to not
> specify the option in the command line. You can't pass NULL as an
> option value, and passing an empty value (i.e. "opt=") will result in
> opt->answer not being equal to NULL.


what are they equal to then?

as all opt->answer are stored as strings regardless of TYPE_* setting,
and C strings are null terminated, a string with nothing in it (opt="")
becomes opt->answer[0]=='\0', right? 

Oh, I see now, it's a pointer and the mem address is no longer NULL even
though the content found at that memory address is.


slowly catching on,
Hamish




More information about the grass-dev mailing list