[PATCH 3/4] Use pointers for traversing arrays in strstr, strcasestr and memmem.
Eric Blake
eblake@redhat.com
Thu Jun 28 14:00:00 GMT 2012
On 05/30/2012 03:11 AM, Maxim Kuvyrkov wrote:
> [PATCH 3/4] Use pointers for traversing arrays in strstr, strcasestr and memmem.
>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>
>
> * string/str-two-way.h (two_way_short_needle): Use pointers instead of
> array references.
> * string/strcasestr.c (TOLOWER): Make side-effect safe.
> +++ b/string/strcasestr.c
> @@ -36,7 +36,7 @@
> #include <stdbool.h>
> #include <strings.h>
>
> -#define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
> +#define TOLOWER(Ch) tolower (Ch)
This optimization may work for glibc, but it violates POSIX. I intended
for the C implementation of strcasestr to be copied to other platforms
(that is, gnulib intends to sync with glibc, and gnulib compiles this
file as a replacement on other platforms where libc's strcasestr is
sub-optimal). For me to ack this part of the patch, you will need to
use preprocessor guards to validate that you are compiling against a
version of tolower() that has stronger guarantees about behavior than
what POSIX states about out-of-range input.
--
Eric Blake eblake@redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120628/d096e97a/attachment.sig>
More information about the Libc-alpha
mailing list