[PATCH:xev 2/2] Use strncasecmp if available, instead of a tolower loop & strncmp

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jan 15 16:07:58 PST 2013

On 01/15/13 03:51 PM, Peter Hutterer wrote:
>>      char *cp;
>>      for (cp = s; *cp; cp++) {
>>  	if (isascii (*cp) && isupper (*cp))
>>  	    *cp = tolower (*cp);
>>      }
>> +#define strncasecmp strncmp
>> +#endif
>> -    if (strncmp (s, "notuseful", len) == 0) return (NotUseful);
>> -    if (strncmp (s, "whenmapped", len) == 0) return (WhenMapped);
>> -    if (strncmp (s, "always", len) == 0) return (Always);
>> +    if (strncasecmp (s, "notuseful", len) == 0) return (NotUseful);
>> +    if (strncasecmp (s, "whenmapped", len) == 0) return (WhenMapped);
>> +    if (strncasecmp (s, "always", len) == 0) return (Always);
> which systems do we support that don't have strncasecmp?

Good question - I remembered other Xorg configure scripts checking for it, but
I don't know why, and checking the Unix98 spec it was included there:

so it should be in our supported baseline.   Anyone know of any reason we can't
just assume strncasecmp and drop the #ifndef case above?

> the man page suggests uppercase spelling "-bs {NotUseful,WhenMapped,Always}"
> so this could break on those systems. maybe change the above to match the
> spelling in the man page?

How would it break?  They'd use the old code that does tolower on the input
before comparison - if we require strncasecmp and drop support for them, then
we could uppercase with impunity.

	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc

More information about the xorg-devel mailing list