On Wed, Nov 08, 2000 at 04:01:13PM +0100, Richard Levitte - VMS Whacker wrote:
> So, either:
> 
>     const char *correct_strstr(const char *s1, const char *s2)
>     {
>       return strstr(s1, s2);
>     }
> 
> or:
> 
>     char *correct_strstr(char *s1, const char *s2)
>     {
>       return strstr(s1, s2);
>     }
> 
> Is that right?  Both of those have problems.  The first because you
> can't manipulate the result even if the strings you gave from the
> start are non-const, and the second because you can't give it a 'const
> char *' as first argument...

HP-UX says:
char *strstr(const char *s1, const char *s2);

I read this: s1 and s2 are passed to strstr(). strstr() will not modify
the locations s1 and s2 are pointing to, so the optimizer may safely
assume that they have not been changed after the call to strstr().

That does not make any statement about what the calling function does
with s1 (and hence the return value _must_not_ be "const char *").

Sorry, couldn't resist :-)
        Lutz
-- 
Lutz Jaenicke                             [EMAIL PROTECTED]
BTU Cottbus               http://www.aet.TU-Cottbus.DE/personen/jaenicke/
Lehrstuhl Allgemeine Elektrotechnik                  Tel. +49 355 69-4129
Universitaetsplatz 3-4, D-03044 Cottbus              Fax. +49 355 69-4153
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to