The new "spec against spec" comparison code was yet another time

victim of the special sort order employed where files come before
directories and alphabetic inside these two groups.

Approved by:	re@
This commit is contained in:
Poul-Henning Kamp 2003-11-30 18:06:02 +00:00
parent ccd50c4818
commit 7e4687f1aa

View File

@ -71,6 +71,7 @@ shownode(NODE *n, int f, char const *path)
static int static int
mismatch(NODE *n1, NODE *n2, int differ, char const *path) mismatch(NODE *n1, NODE *n2, int differ, char const *path)
{ {
if (n2 == NULL) { if (n2 == NULL) {
shownode(n1, differ, path); shownode(n1, differ, path);
return (1); return (1);
@ -151,8 +152,14 @@ walk_in_the_forest(NODE *t1, NODE *t2, char const *path)
r = 0; r = 0;
if (t1 != NULL)
c1 = t1->child; c1 = t1->child;
else
c1 = NULL;
if (t2 != NULL)
c2 = t2->child; c2 = t2->child;
else
c2 = NULL;
while (c1 != NULL || c2 != NULL) { while (c1 != NULL || c2 != NULL) {
n1 = n2 = NULL; n1 = n2 = NULL;
if (c1 != NULL) if (c1 != NULL)
@ -160,6 +167,13 @@ walk_in_the_forest(NODE *t1, NODE *t2, char const *path)
if (c2 != NULL) if (c2 != NULL)
n2 = c2->next; n2 = c2->next;
if (c1 != NULL && c2 != NULL) { if (c1 != NULL && c2 != NULL) {
if (c1->type != F_DIR && c2->type == F_DIR) {
n2 = c2;
c2 = NULL;
} else if (c1->type == F_DIR && c2->type != F_DIR) {
n1 = c1;
c1 = NULL;
} else {
i = strcmp(c1->name, c2->name); i = strcmp(c1->name, c2->name);
if (i > 0) { if (i > 0) {
n1 = c1; n1 = c1;
@ -169,6 +183,7 @@ walk_in_the_forest(NODE *t1, NODE *t2, char const *path)
c2 = NULL; c2 = NULL;
} }
} }
}
if (c1 == NULL || c2 == NULL) { if (c1 == NULL || c2 == NULL) {
i = compare_nodes(c1, c2, path); i = compare_nodes(c1, c2, path);
} else if (c1->child != NULL || c2->child != NULL) { } else if (c1->child != NULL || c2->child != NULL) {