Re: [PATCH v3 04/13] match_basename: use strncmp instead of strcmp

2013-03-12 Thread Antoine Pelisse
 --- a/dir.c
 +++ b/dir.c
 @@ -636,12 +636,14 @@ int match_basename(const char *basename, int 
 basenamelen,
int flags)
  {
 if (prefix == patternlen) {
 -   if (!strcmp_icase(pattern, basename))
 +   if (patternlen == basenamelen 
 +   !strncmp_icase(pattern, basename, patternlen))
 return 1;
 } else if (flags  EXC_FLAG_ENDSWITH) {
 if (patternlen - 1 = basenamelen 
 -   !strcmp_icase(pattern + 1,
 - basename + basenamelen - patternlen + 1))
 +   !strncmp_icase(pattern + 1,
 +  basename + basenamelen - patternlen + 1,
 +  patternlen - 1))
 return 1;


I can see that you kept strncmp(), was it worse with memcmp() ?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 04/13] match_basename: use strncmp instead of strcmp

2013-03-12 Thread Duy Nguyen
On Wed, Mar 13, 2013 at 12:40 AM, Antoine Pelisse apeli...@gmail.com wrote:
 --- a/dir.c
 +++ b/dir.c
 @@ -636,12 +636,14 @@ int match_basename(const char *basename, int 
 basenamelen,
int flags)
  {
 if (prefix == patternlen) {
 -   if (!strcmp_icase(pattern, basename))
 +   if (patternlen == basenamelen 
 +   !strncmp_icase(pattern, basename, patternlen))
 return 1;
 } else if (flags  EXC_FLAG_ENDSWITH) {
 if (patternlen - 1 = basenamelen 
 -   !strcmp_icase(pattern + 1,
 - basename + basenamelen - patternlen + 1))
 +   !strncmp_icase(pattern + 1,
 +  basename + basenamelen - patternlen + 1,
 +  patternlen - 1))
 return 1;


 I can see that you kept strncmp(), was it worse with memcmp() ?

One step at a time. 05/13 replace strncmp_icase with memcmp (for when
ignore_case == 0).
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html