From ffd3af5874950a38f4e383331a5a332e40cabf80 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 17 Jun 1999 22:49:23 +0000 Subject: [PATCH] ChangeLog, uuid_compare.3.in, compare.c: compare.c (uuid_compare): Change sense of uuid_compare so that its return values match that of memcpy and the uuid_compare() found in Paul Leach's internet-draft. --- lib/uuid/ChangeLog | 6 ++++++ lib/uuid/compare.c | 17 +++++++++++------ lib/uuid/uuid_compare.3.in | 6 +++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/uuid/ChangeLog b/lib/uuid/ChangeLog index 69d00502..c38761c6 100644 --- a/lib/uuid/ChangeLog +++ b/lib/uuid/ChangeLog @@ -1,3 +1,9 @@ +1999-05-03 + + * compare.c (uuid_compare): Change sense of uuid_compare so that + its return values match that of memcpy and the + uuid_compare() found in Paul Leach's internet-draft. + 1999-03-11 Andreas Dilger * Created man pages for libuuid functions. diff --git a/lib/uuid/compare.c b/lib/uuid/compare.c index 7bca4fa4..c1182feb 100644 --- a/lib/uuid/compare.c +++ b/lib/uuid/compare.c @@ -13,14 +13,19 @@ #include "uuidP.h" +#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1); + int uuid_compare(uuid_t uu1, uuid_t uu2) { - unsigned char *cp1, *cp2; - int i; + struct uuid uuid1, uuid2; + + uuid_unpack(uu1, &uuid1); + uuid_unpack(uu2, &uuid2); - for (i=0, cp1 = uu1, cp2 = uu2; i < 16; i++) - if (*cp1++ != *cp2++) - return 0; - return 1; + UUCMP(uuid1.time_low, uuid2.time_low); + UUCMP(uuid1.time_mid, uuid2.time_mid); + UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version); + UUCMP(uuid1.clock_seq, uuid2.clock_seq); + return memcmp(uuid1.node, uuid2.node, 6); } diff --git a/lib/uuid/uuid_compare.3.in b/lib/uuid/uuid_compare.3.in index 3dab0719..de56e426 100644 --- a/lib/uuid/uuid_compare.3.in +++ b/lib/uuid/uuid_compare.3.in @@ -21,7 +21,11 @@ function compares the two supplied uuid variables .IR uu1 " and " uu2 to each other. .SH RETURN VALUE -Returns 1 if the two UUIDs are the same and 0 otherwise. +Returns an integer less than, equal to, or greater than zero if +.I uu1 +is found, respectively, to be lexigraphically less than, equal, or +greater than +.IR uu2 . .SH AUTHOR .B uuid_compare was written by Theodore Y. Ts'o for the ext2 filesystem utilties. -- 2.11.0