bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module c-strstr


From: Bruno Haible
Subject: Re: new module c-strstr
Date: Mon, 28 Aug 2006 14:55:56 +0200
User-agent: KMail/1.9.1

Paul Eggert wrote:
> > But it's important to know that   c_strstr (s, "x")  is not safe and
> > c_strstr (s, "123")  is also not safe. The programmer needs to have the
> > precise criteria.
> 
> I don't quite follow this. c_strstr (S, "x") is safe in all cases; it
> never has undefined behavior.  It's true that the result might not
> be the same as strstr (S, "x"), but that's the point of having
> c_strstr, right?

No no, this is a misunderstanding based on the earlier comments. I _don't_
want to offer a function that yields different results than the
internationalized strstr(). Noone really uses NUL-terminated 'char *' strings
for datastructures that are not strings, in a way that c_strstr would have
a useful meaning.

> /* The functions defined in this file act on null-terminated byte
>    strings, without regard to locale.  */

If a comment were to say this, people not understanding i18n or who are
simply confused would use c_strstr when it's not safe to.

> and this:
> 
> >    This function is safe to be called, even in a multibyte locale, if NEEDLE
> >    ...
> 
> to this:
> 
> >    This function is safe to be called, even in all known multibyte locales
> >    derived from ASCII, if NEEDLE ...

The earlier comments already say that an ASCII based encoding is assumed. If
you worry about EBCDIC or DBCS encodings, don't use this function at all.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]