RE: ANSI standards


Subject: RE: ANSI standards
From: James Montgomerie (jamie@montgomerie.net)
Date: Sun Jan 23 2000 - 18:26:17 CST


> -----Original Message-----
> From: Rui Silva - Webmaster [mailto:rms@ssi.aaum.pt]
> Subject: Re: ANSI standards
>
> if you try to compare a string with someother and at least one
> of them is not null terminated, you might have unexpected results.
>
> there are 2 approaches:
> a) be sure that all of the arguments are clean before calling
> b) compare only so many characters.
>
> that was what I was saying. strdup has that problem and anybody
> using strdup is encoraged to use strndup for safety reasons.
> since I am very careul with my strings, I haven't checket what
> happened, but maybe something wich was not desired.
>

Ah! I see what you mean. Is there any way around it though? If I check
the length of the string, either by using strlen(), or a routine of my own
making, won't it break on non-null-terminated strings too (the only way I
can see of doing it is to loop through the string until I find a NULL)?

> if there's no problem, great... I am totally in favour regarding
> simplification of code :) but one must not forget stability.

I totally agree with this. Perhaps I'm missing something obvious here - I
think I need to go to bed :-)

Jamie.



This archive was generated by hypermail 2b25 : Sun Jan 23 2000 - 18:23:21 CST