php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #71025
Patch support-subversion-1.9.x revision 2016-03-23 10:19 UTC by pterjan at google dot com
Patch initial-support-of-subversion-1.9 revision 2016-03-18 02:18 UTC by pterjan at google dot com

Patch initial-support-of-subversion-1.9 for svn Bug #71025

Patch version 2016-03-18 02:18 UTC

Return to Bug #71025 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: pterjan@google.com

--- svn.c.orig	2016-03-18 01:26:42.445815819 +0000
+++ svn-1.0.2/svn.c	2016-03-18 02:08:25.082558472 +0000
@@ -856,6 +856,19 @@
 }
 /* }}} */
 
+ static int php_array_key_compare_string(const void *a, const void *b) /* {{{ */
+{
+	Bucket *f = (Bucket *) a;
+	Bucket *s = (Bucket *) b;
+	char *s1, *s2;
+	size_t l1, l2;
+	s1 = f->arKey;
+	l1 = f->nKeyLength;
+	s2 = s->arKey;
+	l2 = s->nKeyLength;
+	return zend_binary_strcmp(s1, l1, s2, l2);
+}
+/* }}} */
 
 /* {{{ proto array svn_ls(string repository_url [, int revision [, bool recurse [, bool peg]]])
 	Returns a list of a directory in a working copy or repository, optionally at revision_no. */
@@ -868,8 +881,6 @@
 	svn_error_t *err;
 	svn_opt_revision_t revision = { 0 };
 	apr_hash_t *dirents;
-	apr_array_header_t *array;
-	int i;
 	apr_pool_t *subpool;
 	svn_opt_revision_t peg_revision;
 	const char *true_path;
@@ -916,14 +927,11 @@
 		goto cleanup;
 	}
 
-	array = svn_sort__hash (dirents, svn_sort_compare_items_as_paths, subpool);
 	array_init(return_value);
 
-	for (i = 0; i < array->nelts; ++i)
-	{
+	for (apr_hash_index_t *hi = apr_hash_first(subpool, dirents); hi; hi = apr_hash_next(hi)) {
 		const char *utf8_entryname;
 		svn_dirent_t *dirent;
-		svn_sort__item_t *item;
 		apr_time_t now = apr_time_now();
 		apr_time_exp_t exp_time;
 		apr_status_t apr_err;
@@ -932,9 +940,8 @@
 		const char   *utf8_timestr;
 		zval 	*row;
 
-		item = &APR_ARRAY_IDX (array, i, svn_sort__item_t);
-		utf8_entryname = item->key;
-		dirent = apr_hash_get (dirents, utf8_entryname, item->klen);
+		utf8_entryname = apr_hash_this_key(hi);
+		dirent = apr_hash_this_val(hi);
 
 		/* svn_time_to_human_cstring gives us something *way* too long
 		to use for this, so we have to roll our own.  We include
@@ -972,12 +979,26 @@
 		add_assoc_zval(return_value, (char *)utf8_entryname, row);
 	}
 
+	//zend_hash_sort(return_value, zend_qsort, (compare_func_t) php_array_key_compare_string, 0);
+
 cleanup:
 	svn_pool_destroy(subpool);
 
 }
 /* }}} */
 
+
+static int compare_keys_as_paths(const void *a, const void *b) /* {{{ */
+{
+	Bucket *f = (Bucket *) a;
+	Bucket *s = (Bucket *) b;
+	char *s1, *s2;
+    s1 = f->arKey;
+	s2 = s->arKey;
+	return svn_sort_compare_paths(s1, s2);
+}
+/* }}} */
+
 static svn_error_t *
 php_svn_log_receiver (	void *ibaton,
 				apr_hash_t *changed_paths,
@@ -989,8 +1010,6 @@
 {
 	struct php_svn_log_receiver_baton *baton = (struct php_svn_log_receiver_baton*) ibaton;
 	zval  *row, *paths;
-	apr_array_header_t *sorted_paths;
-	int i;
 	TSRMLS_FETCH();
 
 	if (rev == 0) {
@@ -1017,23 +1036,19 @@
 		MAKE_STD_ZVAL(paths);
 		array_init(paths);
 
-		sorted_paths = svn_sort__hash(changed_paths, svn_sort_compare_items_as_paths, pool);
-
-		for (i = 0; i < sorted_paths->nelts; i++)
-		{
-			svn_sort__item_t *item;
+		for (apr_hash_index_t *hi = apr_hash_first(pool, changed_paths); hi; hi = apr_hash_next(hi)) {
 			svn_log_changed_path_t *log_item;
 			zval *zpaths;
 			const char *path;
 
 			MAKE_STD_ZVAL(zpaths);
 			array_init(zpaths);
-			item = &(APR_ARRAY_IDX (sorted_paths, i, svn_sort__item_t));
-			path = item->key;
-			log_item = apr_hash_get (changed_paths, item->key, item->klen);
+
+			path = apr_hash_this_key(hi);
+			log_item = apr_hash_this_val(hi);
 
 			add_assoc_stringl(zpaths, "action", &(log_item->action), 1,1);
-			add_assoc_string(zpaths, "path", (char *) item->key, 1);
+			add_assoc_string(zpaths, "path", path, 1);
 
 			if (log_item->copyfrom_path
 					&& SVN_IS_VALID_REVNUM (log_item->copyfrom_rev)) {
@@ -1044,7 +1059,10 @@
 			}
 
 			add_next_index_zval(paths,zpaths);
+			//add_assoc_zval(paths, path, zpaths);
 		}
+
+		//zend_hash_sort(paths, zend_qsort, (compare_func_t) compare_keys_as_paths, 1);
 		add_assoc_zval(row,"paths",paths);
 	}
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 02:01:31 2024 UTC