]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - int64.c
When we're quoting user-interface text from PuTTY 0.51, we probably shouldn't
[PuTTY.git] / int64.c
diff --git a/int64.c b/int64.c
index da7b4c3b2ae0e28f669217bd8fb67f47cf63e40a..8a1cda1a5fddc274816a133ba7aabf7ce1e0dba3 100644 (file)
--- a/int64.c
+++ b/int64.c
@@ -5,10 +5,9 @@
  */
 
 #include <assert.h>
+#include <string.h>
 
-typedef struct {
-    unsigned long hi, lo;
-} uint64, int64;
+#include "int64.h"
 
 uint64 uint64_div10(uint64 x, int *remainder)
 {
@@ -37,11 +36,11 @@ void uint64_decimal(uint64 x, char *buffer)
     int start = 20;
     int d;
 
-    while (x.hi || x.lo) {
+    do {
        x = uint64_div10(x, &d);
        assert(start > 0);
        buf[--start] = d + '0';
-    }
+    } while (x.hi || x.lo);
 
     memcpy(buffer, buf + start, sizeof(buf) - start);
     buffer[sizeof(buf) - start] = '\0';
@@ -69,3 +68,12 @@ uint64 uint64_add32(uint64 x, unsigned long y)
     yy.lo = y;
     return uint64_add(x, yy);
 }
+
+int uint64_compare(uint64 x, uint64 y)
+{
+    if (x.hi != y.hi)
+       return x.hi < y.hi ? -1 : +1;
+    if (x.lo != y.lo)
+       return x.lo < y.lo ? -1 : +1;
+    return 0;
+}