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

Bug in function previous_segment of subversion/libsvn_subr/path.c on trunk 36335

From: Marc Haesen <marc.haesen_at_oneaccess-net.com>
Date: Thu, 5 Mar 2009 12:33:58 +0100

When running the attached batch file in windows at the root dir of a
drive, I discovered a problem in the previous_segment routine of
subversion/libsvn_subr/path.c.

static apr_size_t
previous_segment(const char *path,
                 apr_size_t len)
{
  if (len == 0)
    return 0;

  while (len > 0 && path[--len] != '/')
    ;

  if (len == 0 && path[0] == '/')
    return 1;
  else
    return len;
}

The case of an absolute path with no previous segments is handled
correctly on unix but not on windows.

For windows it should be changed to:

static apr_size_t
previous_segment(const char *path,
                 apr_size_t len)
{
  if (len == 0)
    return 0;

  while (len > 0 && path[--len] != '/')
    ;

  if (len == 0 && path[0] == '/')
    return 1;
  else
  {
    #ifdef WIN32
    if (len==2 && path[1]==':')
      return 3;
    #endif
    return len;
  }
}

With this fix, the attached batch file is running fine.

Regards,
Marc

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=1271821

Received on 2009-03-05 12:34:21 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.