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

Re: svn commit: r10143 - in trunk/subversion: libsvn_subr tests/libsvn_subr

From: Klaus Rennecke <klaus_at_rennecke.de>
Date: 2004-07-05 18:16:01 CEST

Greg Hudson wrote:

> [...]
>
>All Subversion path functions except for a few special cases are assumed
>to accept canonicalized internal paths, if I understand right.
>
>

Well then it's probably best to remove that check lest it gives the
impression to the contrary.

/Klaus

Index: D:/kre/workspace/svn/subversion/libsvn_subr/path.c
===================================================================
--- D:/kre/workspace/svn/subversion/libsvn_subr/path.c (revision 10143)
+++ D:/kre/workspace/svn/subversion/libsvn_subr/path.c (working copy)
@@ -264,6 +264,22 @@
 
 
 
+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 len + 1;
+ else
+ return len;
+}
+
 void
 svn_path_add_component (svn_stringbuf_t *path,
                         const char *component)
@@ -291,16 +307,8 @@
 {
   assert (is_canonical (path->data, path->len));
 
- while (path->len > 0 && path->data[path->len] != '/')
- --path->len;
-
- if (path->len == 0 && path->data[0] == '/')
- path->len++;
-
+ path->len = previous_segment(path->data, path->len);
   path->data[path->len] = '\0';
-
- if (SVN_PATH_IS_PLATFORM_EMPTY (path->data, path->len))
- svn_stringbuf_set (path, SVN_EMPTY_PATH);
 }
 
 
@@ -311,16 +319,7 @@
 
   assert (is_canonical (path, len));
 
- while (len > 0 && path[len] != '/')
- --len;
-
- if (len == 0 && path[0] == '/')
- ++len;
-
- if (SVN_PATH_IS_PLATFORM_EMPTY (path, len))
- return apr_pmemdup (pool, SVN_EMPTY_PATH, sizeof (SVN_EMPTY_PATH));
-
- return apr_pstrmemdup (pool, path, len);
+ return apr_pstrmemdup (pool, path, previous_segment(path, len));
 }
 
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jul 5 18:35:23 2004

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.