Bug 922 - fast path in strupper_m and strlower_m is not executed.
fast path in strupper_m and strlower_m is not executed.
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: Extended Characters
3.0.1
All All
: P5 minor
: none
Assigned To: Alexander Bokovoy
:
: 978 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-12-25 23:38 UTC by YAMASAKI Hiroyuki
Modified: 2005-08-24 10:17 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description YAMASAKI Hiroyuki 2003-12-25 23:38:04 UTC
In function lib/util_str.c/struppter_m() and strlower_m(), almost execute slow 
path. almost never fast path. 

I think while loop condition,
   --------------------------------------------------
    while (*s && !(((unsigned char)s[0]) & 0x7F)) { 
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   --------------------------------------------------
is wrong. 

below code is correct?
   --------------------------------------------------
    while (*s && (((unsigned char)s[0]) <= 0x7F)) { 
   --------------------------------------------------

-------------------------------------------------------------------------
void strlower_m(char *s)
{
    /* this is quite a common operation, so we want it to be
       fast. We optimise for the ascii case, knowing that all our
       supported multi-byte character sets are ascii-compatible
       (ie. they match for the first 128 chars) */

    while (*s && !(((unsigned char)s[0]) & 0x7F)) { <---#### this ####
        *s = tolower((unsigned char)*s);
        s++;
    }

    if (!*s)
        return;

    /* I assume that lowercased string takes the same number of bytes
     * as source string even in UTF-8 encoding. (VIV) */
    unix_strlower(s,strlen(s)+1,s,strlen(s)+1);    
}
-------------------------------------------------------------------------
Comment 1 Jeremy Allison 2004-01-07 15:21:46 UTC
Applied for 3.0.2.
Jeremy.
Comment 2 Jeremy Allison 2004-01-07 15:22:01 UTC
Fixed for 3.0.2.
Jeremy.
Comment 3 Gerald (Jerry) Carter 2004-03-17 07:34:27 UTC
*** Bug 978 has been marked as a duplicate of this bug. ***
Comment 4 Gerald (Jerry) Carter 2005-08-24 10:17:39 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.