[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r33148 - in trunk/subversion: include include/private libsvn_fs libsvn_subr

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: Wed, 17 Sep 2008 21:20:28 -0400

Greg Stein wrote:
> On Wed, Sep 17, 2008 at 2:41 PM, <danielsh_at_tigris.org> wrote:
>> ...
>> +++ trunk/subversion/libsvn_subr/path.c Wed Sep 17 14:41:28 2008 (r33148)
>> @@ -842,6 +842,26 @@ svn_path_is_single_path_component(const
>>
>>
>> svn_boolean_t
>> +svn_path_is_dotpath_present(const char *path)
>> +{
>> + int len = strlen(path);
>> +
>> + if (! strcmp(path, "."))
>> + return TRUE;
>> +
>> + if (! strncmp(path, "./", 2))
>> + return TRUE;
>> +
>> + if (strstr(path, "/./") != NULL)
>> + return TRUE;
>> +
>> + if (path[len - 2] == '/' && path[len - 1] == '.')
>> + return TRUE;
>
> if len==1, then the above statement will choke. i.e. pass "a"
>
> I'd suggest changing the first two tests to something like:
>
> if (len == 1)
> {
> return path[0] == '.';
> }
> if (path[0] == '.' && path[1] == '/')
> return TRUE;
> ... rest of function

How about delaying that strlen() as long as possible, too:

  int len;

  if (path[0] != '\0' && path[1] == '\0')
    return path[0] == '.';

  if (path[0] == '.' && path[1] == '/')
    return TRUE;

  if (strstr(path, "/./") != NULL)
    return TRUE;

  len = strlen(path);
  if (path[len - 2] == '/' && path[len - 1] == '.')
    return TRUE;

-- 
C. Michael Pilato <cmpilato_at_collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Received on 2008-09-18 03:50:24 CEST

This is an archived mail posted to the Subversion Dev mailing list.