[GRASS5] g.region G_usage() commented out?
Glynn Clements
glynn.clements at virgin.net
Mon May 20 10:56:52 EDT 2002
Russell Nelson wrote:
> > AFAICT, the code appears to be ensuring that the code processes the
> > entire string, and not just some initial portion of it.
>
> But tbuf[] is filled by copying characters from buf up to the first
> null. Therefore, buf cannot contain any embedded nulls, and
> strlen(buf) is going to be equal to strchr(tbuf, MARKER) - tbuf every
> time. So why not just run up to the null? The only reason I can see
> to have MARKER would be if you wanted to safely look at buf[i] and
> buf[i+1] without first checking to see if buf[i] is a '\0'. The
> original code didn't do that, but ahhhh, I see that I have introduced
> a potential segfault. Revised patch, which actually is simpler and
> easier to understand:
It still changes the semantics of the function. The existing version
will reject strings which contain trailing whitespace, due to:
if (h[1] != MARKER)
return 0;
If the marker is removed, G_strip() will strip any trailing whitespace
before the test is performed.
I'm not suggesting that I have a personal preference for the existing
behaviour; I'm just asking you (or, for that matter, anyone else)
whether you are sure that it's safe to change it.
My *suspicion* is that it *probably* is safe.
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev
mailing list