diff options
Diffstat (limited to 'tdeioslave/svn/svn.cpp')
-rw-r--r-- | tdeioslave/svn/svn.cpp | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/tdeioslave/svn/svn.cpp b/tdeioslave/svn/svn.cpp index 755541c4..cac709c3 100644 --- a/tdeioslave/svn/svn.cpp +++ b/tdeioslave/svn/svn.cpp @@ -46,6 +46,7 @@ #include <subversion-1/svn_utf.h> #include <subversion-1/svn_ra.h> #include <subversion-1/svn_time.h> +#include <subversion-1/svn_version.h> #include <kmimetype.h> #include <tqfile.h> @@ -106,10 +107,60 @@ static svn_error_t *write_to_string(void *baton, const char *data, apr_size_t *l return SVN_NO_ERROR; } -static int -compare_items_as_paths (const svn_sort__item_t*a, const svn_sort__item_t*b) { - return svn_path_compare_paths ((const char *)a->key, (const char *)b->key); +#if (SVN_VER_MAJOR == 1 && SVN_VER_MINOR <= 8) +typedef svn_sort__item_t svn_sort_item_type; +#else +// Taken from subversion 1.8.10 source code and modified where needed + +// Same as svn_sort__item_t +typedef struct svn_sort_item_type { + const void *key; // pointer to the key + apr_ssize_t klen; // size of the key + void *value; // pointer to the value +} svn_sort_item_type; + +apr_array_header_t* svn_sort__hash(apr_hash_t *ht, + int (*comparison_func)(const svn_sort__item_t*, const svn_sort__item_t*), apr_pool_t *pool) +{ + apr_hash_index_t *hi; + apr_array_header_t *ary; + svn_boolean_t sorted; + svn_sort_item_type *prev_item; + + /* allocate an array with enough elements to hold all the keys. */ + ary = apr_array_make(pool, apr_hash_count(ht), sizeof(svn_sort_item_type)); + + /* loop over hash table and push all keys into the array */ + sorted = TRUE; + prev_item = NULL; + for (hi = apr_hash_first(pool, ht); hi; hi = apr_hash_next(hi)) + { + svn_sort_item_type *item = (svn_sort_item_type*)apr_array_push(ary); + apr_hash_this(hi, &item->key, &item->klen, &item->value); + + if (prev_item == NULL) + { + prev_item = item; + continue; + } + + if (sorted) + { + sorted = (comparison_func((svn_sort__item_t*)prev_item, (svn_sort__item_t*)item) < 0); + prev_item = item; + } + } + + /* quicksort the array if it isn't already sorted. */ + if (!sorted) + { + qsort(ary->elts, ary->nelts, ary->elt_size, + (int (*)(const void*, const void*))comparison_func); + } + + return ary; } +#endif tdeio_svnProtocol::tdeio_svnProtocol(const TQCString &pool_socket, const TQCString &app_socket) : SlaveBase("tdeio_svn", pool_socket, app_socket) { @@ -447,16 +498,16 @@ void tdeio_svnProtocol::listDir(const KURL& url){ apr_array_header_t *array; int i; - array = svn_sort__hash (dirents, compare_items_as_paths, subpool); - + array = svn_sort__hash (dirents, svn_sort_compare_items_as_paths, subpool); + UDSEntry entry; for (i = 0; i < array->nelts; ++i) { entry.clear(); const char *utf8_entryname, *native_entryname; svn_dirent_t *dirent; - svn_sort__item_t *item; - - item = &APR_ARRAY_IDX (array, i, svn_sort__item_t); + svn_sort_item_type *item; + + item = &APR_ARRAY_IDX (array, i, svn_sort_item_type); utf8_entryname = (const char*)item->key; |