apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject Re: Provide our own impl of str[n]casecmp()?
Date Mon, 23 Nov 2015 15:44:53 GMT
Should we then adjust docs and usage to remove the "greater/less than"
criteria and just say equal strings return 0 and non 0 means that
the strings don't compare/are different?

> On Nov 23, 2015, at 10:19 AM, William A Rowe Jr <wrowe@rowe-clan.net> wrote:
> 
> On Mon, Nov 23, 2015 at 2:11 AM, Branko ─îibej <brane@apache.org> wrote:
> 
> +1 to apr_casecmpstr[n]() with a big fat warning in the docstring that
> it works for ASCII only.
> 
> Well, it 'works' (does not segfault, does not case fold them) for high bit 
> characters, but sorts them in a potentially meaningless way.  The Current
> implementation has already drifted; the currently accepted flavor looks like;
> 
> 2441	
> /**
> 
> 2442	
>  * Known-fast version of strcasecmp(): ASCII case-folding, POSIX compliant
> 
> 2443	
>  * @param s1 The 1st string to compare
> 
> 2444	
>  * @param s2 The 2nd string to compare
> 
> 2445	
>  * @return integer greater than, equal to, or less than 0, depending on
> 
> 2446	
>  *         if s1 is lexicographically greater than, equal to, or less
> 
> 2447	
>  *         than s2 ignoring case.
> 
> 2448	
>  */
> 
> 2449	
> AP_DECLARE(int) ap_casecmpstr(const char *s1, const char *s2);
> 
> 2450	
> 2451	
> /**
> 
> 2452	
>  * Known-fast version of strncasecmp(): ASCII case-folding, POSIX compliant
> 
> 2453	
>  * @param s1 The 1st string to compare
> 
> 2454	
>  * @param s2 The 2nd string to compare
> 
> 2455	
>  * @param n  Maximum number of characters in the strings to compare
> 
> 2456	
>  * @return integer greater than, equal to, or less than 0, depending on
> 
> 2457	
>  *         if s1 is lexicographically greater than, equal to, or less
> 
> 2458	
>  *         than s2 ignoring case.
> 
> 2459	
>  */
> 
> 2460	
> AP_DECLARE(int) ap_casecmpstrn(const char *s1, const char *s2, apr_size_t n);
> 
> 
> 
> and is implemented here;
> 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?view=markup&pathrev=1715736#l3175
> 
>  
> 


Mime
View raw message