Re: [PATCH v3 05/13] match_{base,path}name: replace strncmp_icase with memequal_icase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 12, 2013 at 8:04 PM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:
> +static inline int memequal_icase(const char *a, const char *b, int n)
> +{
> +       if (!memcmp(a, b, n))
> +               return 1;
> +
> +       if (!ignore_case)
> +               return 0;
> +
> +       /*
> +        * This assumes that ASCII is used in most repositories. We
> +        * try the ascii-only version first (i.e. Git's
> +        * toupper). Failing that, fall back to normal strncasecmp.
> +        */
> +       while (n && toupper(*a) == toupper(*b)) {
> +               a++;
> +               b++;
> +               n--;
> +       }
> +       if (!n)
> +               return 1;
> +       return !strncasecmp(a, b, n);
> +}

Note, the ignore_case == 1 codepath was not tested and measured. I
suspect that strncasecmp may be more complex to support locales and
the "LANG=C" version should suffice in most case. But it's just
guesses at this moment.
-- 
Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]