This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/4] Use pointers for traversing arrays in strstr, strcasestrand memmem.


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



Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]