[GRASS5] Re: NVIZ + CELL map + gcc >=3.2.2 = SegFault

Glynn Clements glynn.clements at virgin.net
Tue Sep 16 14:16:11 EDT 2003


Hamish wrote:

> It apparently breaks while somewhere in this statement in
>  src/libes/gis/nme_in_mps.c:
> 
> if(strchr(name, '@'))
>         sprintf (fullname, "%s", name);
>     else
>         sprintf (fullname, "%s@%s", name, mapset);
> 
> 
> --
> Looking up strchr:
> 
> char *strchr(const char *s, int c);
> 
> Description
> This function returns a pointer to the first occurrence of c in s. Note
> that if c is NULL, this will return a pointer to the end of the string.
> 
> Return Value
> A pointer to the character, or NULL if it wasn't found. 
> 
> 
> 
> So "if()" is testing either a pointer or NULL.
> 
> Is that kosher?

Yes. NULL is false, anything else is true.

If strchr() segfaults, it means that name is bogus (either the pointer
itself is invalid or the data to which it points doesn't have a
terminating NUL).

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list