You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2019/01/31 16:51:48 UTC
svn commit: r1852616 - in /subversion/trunk/subversion: include/svn_delta.h
libsvn_delta/deprecated.c
Author: julianfoad
Date: Thu Jan 31 16:51:48 2019
New Revision: 1852616
URL: http://svn.apache.org/viewvc?rev=1852616&view=rev
Log:
Improve backward compatibility for svn_delta_path_driver2().
This ensures the input array is not modified, and changes the behaviour to
be less surprising.
* subversion/include/svn_delta.h,
subversion/libsvn_delta/deprecated.c
(svn_delta_path_driver2): Add back slash prefixes if any, rather than the
first, of the inputs had one. Duplicate the array if modifying it.
Modified:
subversion/trunk/subversion/include/svn_delta.h
subversion/trunk/subversion/libsvn_delta/deprecated.c
Modified: subversion/trunk/subversion/include/svn_delta.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_delta.h?rev=1852616&r1=1852615&r2=1852616&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_delta.h (original)
+++ subversion/trunk/subversion/include/svn_delta.h Thu Jan 31 16:51:48 2019
@@ -1374,12 +1374,13 @@ svn_delta_path_driver3(const svn_delta_e
/** Like svn_delta_path_driver3() but with a different callback function
* signature.
*
- * Optionally, all the paths in @a paths could have a '/' prefix instead of
- * being relpaths. In that case, all paths sent to the callback will have
- * a '/' prefix.
+ * Optionally, paths in @a paths could have a '/' prefix instead of being
+ * relpaths. If any of them do, then (since 1.12) ALL paths sent to the
+ * callback will have a '/' prefix.
*
* @deprecated Provided for backward compatibility with the 1.11 API.
- * @since New in 1.8.
+ * @since New in 1.8. Before 1.12, paths sent to the callback were the
+ * exact paths passed in @a paths.
*/
svn_error_t *
svn_delta_path_driver2(const svn_delta_editor_t *editor,
Modified: subversion/trunk/subversion/libsvn_delta/deprecated.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/deprecated.c?rev=1852616&r1=1852615&r2=1852616&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_delta/deprecated.c (original)
+++ subversion/trunk/subversion/libsvn_delta/deprecated.c Thu Jan 31 16:51:48 2019
@@ -70,30 +70,30 @@ svn_delta_path_driver2(const svn_delta_e
apr_pool_t *pool)
{
struct path_driver_2_to_3_baton_t b;
+ int i;
b.callback_func = callback_func;
b.callback_baton = callback_baton;
+ b.slash_prefix = FALSE;
- /* Remove any '/' prefix from incoming paths and arrange to add it back
- when calling the callback. We assume the first path is representative
- of all paths. */
- if (paths->nelts >= 1
- && APR_ARRAY_IDX(paths, 0, const char *)[0] == '/')
+ /* Remove any '/' prefix from incoming paths. Arrange to add a '/'
+ prefix to all paths for the callback, if any incoming path had one. */
+ for (i = 0; i < paths->nelts; i++)
{
- int i;
+ const char *path = APR_ARRAY_IDX(paths, i, const char *);
- for (i = 0; i < paths->nelts; i++)
+ if (path[0] == '/')
{
- const char *path = APR_ARRAY_IDX(paths, i, const char *);
+ /* Re-allocate the array and note that we found a '/' prefix. */
+ if (!b.slash_prefix)
+ {
+ paths = apr_array_copy(pool, paths);
+ b.slash_prefix = TRUE;
+ }
- if (path[0] == '/')
- APR_ARRAY_IDX(paths, i, const char *) = path + 1;
+ /* Modify each array element that had a '/' prefix */
+ APR_ARRAY_IDX(paths, i, const char *) = path + 1;
}
- b.slash_prefix = TRUE;
- }
- else
- {
- b.slash_prefix = FALSE;
}
SVN_ERR(svn_delta_path_driver3(editor, edit_baton,