1c30160016
- add -y support to read password from a file - remove useless header that vim whines about - preserve order of attribute values - fix possible LP64 issue (improper sentinel) - allow editors/pagers with arguments - getline namespace collision, upstream git 256ced029c - fix hash generation OK ajacoutot@
50 lines
1.2 KiB
Plaintext
50 lines
1.2 KiB
Plaintext
$OpenBSD: patch-diff_c,v 1.1 2012/03/02 08:01:07 sthen Exp $
|
|
|
|
preserve order of attribute values, from git upstream 3ae1458bb7
|
|
|
|
--- diff.c.orig Sat May 5 11:17:26 2007
|
|
+++ diff.c Thu Mar 1 22:19:30 2012
|
|
@@ -46,22 +46,32 @@ compare_ptr_arrays(GPtrArray *a, GPtrArray *b,
|
|
for (; i < a->len; i++) note(g_ptr_array_index(a, i), 0, x);
|
|
}
|
|
|
|
-static void
|
|
-note_values(GArray *a, GArray *b, int *changed)
|
|
+static int
|
|
+ordered_array_equal(GPtrArray *a, GPtrArray *b,
|
|
+ int (*cmp)(const void *, const void *))
|
|
{
|
|
- if (!(a && b)) *changed = 1;
|
|
+ int i;
|
|
+
|
|
+ if (a->len != b->len)
|
|
+ return 0;
|
|
+
|
|
+ for (i = 0; i < a->len; i++) {
|
|
+ void *ax = g_ptr_array_index(a, i);
|
|
+ void *bx = g_ptr_array_index(b, i);
|
|
+ if (cmp(&ax, &bx))
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ return 1;
|
|
}
|
|
|
|
static void
|
|
compare_attributes(tattribute *clean, tattribute *new, GPtrArray *mods)
|
|
{
|
|
- int changed = 0;
|
|
- compare_ptr_arrays(attribute_values(clean),
|
|
- attribute_values(new),
|
|
- carray_ptr_cmp,
|
|
- (note_function) note_values,
|
|
- &changed);
|
|
- if (changed) {
|
|
+ if (!ordered_array_equal(attribute_values(clean),
|
|
+ attribute_values(new),
|
|
+ carray_ptr_cmp))
|
|
+ {
|
|
LDAPMod *m = attribute2mods(new);
|
|
m->mod_op |= LDAP_MOD_REPLACE;
|
|
g_ptr_array_add(mods, m);
|