subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From julianf...@apache.org
Subject svn commit: r1135560 - in /subversion/trunk/subversion: include/svn_dirent_uri.h libsvn_subr/dirent_uri.c tests/libsvn_subr/dirent_uri-test.c
Date Tue, 14 Jun 2011 13:26:05 GMT
Author: julianfoad
Date: Tue Jun 14 13:26:05 2011
New Revision: 1135560

URL: http://svn.apache.org/viewvc?rev=1135560&view=rev
Log:
Simplify the semantics of svn_uri_skip_ancestor() to return NULL if the
supposed child is not in fact a child.

* subversion/include/svn_dirent_uri.h,
  subversion/libsvn_subr/dirent_uri.c
  (svn_uri_skip_ancestor): Return NULL if 'child' is not a child.

* subversion/tests/libsvn_subr/dirent_uri-test.c
  (test_uri_skip_ancestor): Adjust the test accordingly.

Modified:
    subversion/trunk/subversion/include/svn_dirent_uri.h
    subversion/trunk/subversion/libsvn_subr/dirent_uri.c
    subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c

Modified: subversion/trunk/subversion/include/svn_dirent_uri.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_dirent_uri.h?rev=1135560&r1=1135559&r2=1135560&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_dirent_uri.h (original)
+++ subversion/trunk/subversion/include/svn_dirent_uri.h Tue Jun 14 13:26:05 2011
@@ -657,7 +657,7 @@ svn_relpath_skip_ancestor(const char *pa
 
 /** Return the relative path part of @a child_uri that is below
  * @a parent_uri, or just "" if @a parent_uri is equal to @a child_uri. If
- * @a child_uri is not below @a parent_uri, return @a child_uri.
+ * @a child_uri is not below or equal to @a parent_uri, return NULL.
  *
  * @since New in 1.7.
  */

Modified: subversion/trunk/subversion/libsvn_subr/dirent_uri.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/dirent_uri.c?rev=1135560&r1=1135559&r2=1135560&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/dirent_uri.c (original)
+++ subversion/trunk/subversion/libsvn_subr/dirent_uri.c Tue Jun 14 13:26:05 2011
@@ -1525,7 +1525,7 @@ svn_uri_skip_ancestor(const char *parent
   assert(svn_uri_is_canonical(child_uri, NULL));
 
   if (0 != memcmp(parent_uri, child_uri, len))
-    return child_uri; /* parent_uri is no ancestor of child_uri */
+    return NULL; /* parent_uri is no ancestor of child_uri */
 
   if (child_uri[len] == 0)
     return ""; /* parent_uri == child_uri */
@@ -1533,7 +1533,7 @@ svn_uri_skip_ancestor(const char *parent
   if (child_uri[len] == '/')
     return child_uri + len + 1;
 
-  return child_uri;
+  return NULL;
 }
 
 svn_boolean_t

Modified: subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c?rev=1135560&r1=1135559&r2=1135560&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_subr/dirent_uri-test.c Tue Jun 14 13:26:05 2011
@@ -1568,7 +1568,7 @@ test_uri_skip_ancestor(apr_pool_t *pool)
     const char *result;
   } tests[] = {
     { "http://server",   "http://server/q", "q" },
-    { "svn://server",    "http://server/q", "http://server/q" },
+    { "svn://server",    "http://server/q", NULL },
   };
 
   for (i = 0; i < COUNT_OF(tests); i++)
@@ -1576,7 +1576,9 @@ test_uri_skip_ancestor(apr_pool_t *pool)
       const char* retval;
 
       retval = svn_uri_skip_ancestor(tests[i].path1, tests[i].path2);
-      if (strcmp(tests[i].result, retval))
+      if ((tests[i].result == NULL)
+          ? (retval != NULL)
+          : (retval == NULL || strcmp(tests[i].result, retval) != 0))
         return svn_error_createf(
              SVN_ERR_TEST_FAILED, NULL,
              "svn_uri_skip_ancestor (%s, %s) returned %s instead of %s",



Mime
View raw message