summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-11-30 18:06:02 +0000
committerphk <phk@FreeBSD.org>2003-11-30 18:06:02 +0000
commit66faa6a3a29ff32f392980d0d25731cd70c4db57 (patch)
tree6c461a4a23eeb3ff051fdfb1bd34e0d0f8b2d905
parent396e8abc850f4833591004d40a59d10c56696041 (diff)
downloadFreeBSD-src-66faa6a3a29ff32f392980d0d25731cd70c4db57.zip
FreeBSD-src-66faa6a3a29ff32f392980d0d25731cd70c4db57.tar.gz
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@
-rw-r--r--usr.sbin/mtree/specspec.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/usr.sbin/mtree/specspec.c b/usr.sbin/mtree/specspec.c
index 88589ad..6281c15 100644
--- a/usr.sbin/mtree/specspec.c
+++ b/usr.sbin/mtree/specspec.c
@@ -71,6 +71,7 @@ shownode(NODE *n, int f, char const *path)
static int
mismatch(NODE *n1, NODE *n2, int differ, char const *path)
{
+
if (n2 == NULL) {
shownode(n1, differ, path);
return (1);
@@ -151,8 +152,14 @@ walk_in_the_forest(NODE *t1, NODE *t2, char const *path)
r = 0;
- c1 = t1->child;
- c2 = t2->child;
+ if (t1 != NULL)
+ c1 = t1->child;
+ else
+ c1 = NULL;
+ if (t2 != NULL)
+ c2 = t2->child;
+ else
+ c2 = NULL;
while (c1 != NULL || c2 != NULL) {
n1 = n2 = NULL;
if (c1 != NULL)
@@ -160,13 +167,21 @@ walk_in_the_forest(NODE *t1, NODE *t2, char const *path)
if (c2 != NULL)
n2 = c2->next;
if (c1 != NULL && c2 != NULL) {
- i = strcmp(c1->name, c2->name);
- if (i > 0) {
- n1 = c1;
- c1 = NULL;
- } else if (i < 0) {
+ 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);
+ if (i > 0) {
+ n1 = c1;
+ c1 = NULL;
+ } else if (i < 0) {
+ n2 = c2;
+ c2 = NULL;
+ }
}
}
if (c1 == NULL || c2 == NULL) {
OpenPOWER on IntegriCloud