bug-gnulib
[Top][All Lists]
Advanced

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

Re: strstr, strcase, strcasestr, and i18n


From: Paul Eggert
Subject: Re: strstr, strcase, strcasestr, and i18n
Date: Fri, 02 Feb 2007 01:01:16 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

>   - strstr: This function's behaviour is not clearly defined. POSIX says
>     that it compares a "string" with a "sequence of bytes". Which a priori
>     is nonsense, since the elements of strings are characters.

No, elements of "character strings" are characters.  Elements of "strings"
are bytes.  See:

http://www.opengroup.org/susv3/basedefs/xbd_chap03.html#tag_03_92
http://www.opengroup.org/susv3/basedefs/xbd_chap03.html#tag_03_367

So strstr's behavior is clearly defined: it operates on strings (i.e.,
byte strings), not character strings.

>   - strcase (strcasecmp, strncasecmp): Here POSIX talks about two strings,
>     but doesn't mention LC_CTYPE explicitly. Rather it says the results are
>     "unspecified" in real locales.

This also makes sense, once one realizes that plain "string" means
byte string in POSIX.  These functions are well-defined on byte
strings only (and in the POSIX locale to boot).  The results are
unspecified if you use a multibyte locale.

> It was tempting to make a clear API nomenclature: c-str* for the C locale
> emulation, str* for the internationalized functions. But if you're right
> with strstr, then we should find new names for the internationalized versions
> of these functions.

I think we have to find new names, yes.




reply via email to

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