OSDN Git Service

ChangeLog, uuid_compare.3.in, compare.c:
authorTheodore Ts'o <tytso@mit.edu>
Thu, 17 Jun 1999 22:49:23 +0000 (22:49 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 17 Jun 1999 22:49:23 +0000 (22:49 +0000)
  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
lib/uuid/compare.c
lib/uuid/uuid_compare.3.in

index 69d0050..c38761c 100644 (file)
@@ -1,3 +1,9 @@
+1999-05-03    <tytso@rsts-11.mit.edu>
+
+       * 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 <adilger@enel.ucalgary.ca>
 
        * Created man pages for libuuid functions.
index 7bca4fa..c1182fe 100644 (file)
 
 #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);
 }
 
index 3dab071..de56e42 100644 (file)
@@ -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.