Replace boost::scoped_ptr with std::unique_ptr.
[cumulus.git] / ref.cc
diff --git a/ref.cc b/ref.cc
index 7e92b7a..2a45781 100644 (file)
--- a/ref.cc
+++ b/ref.cc
@@ -1,7 +1,6 @@
-/* Cumulus: Smart Filesystem Backup to Dumb Servers
- *
- * Copyright (C) 2007  The Regents of the University of California
- * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+/* Cumulus: Efficient Filesystem Backup to the Cloud
+ * Copyright (C) 2007-2008 The Cumulus Developers
+ * See the AUTHORS file for a list of contributors.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +24,7 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <uuid/uuid.h>
@@ -97,9 +97,7 @@ string ObjectReference::to_string() const
 
     if (range_valid) {
         char buf[64];
-        if (range_exact) {
-            sprintf(buf, "[=%zu]", range_length);
-        } else if (range_start == 0) {
+        if (range_exact || type == REF_ZERO) {
             sprintf(buf, "[%zu]", range_length);
         } else {
             sprintf(buf, "[%zu+%zu]", range_start, range_length);
@@ -166,6 +164,9 @@ ObjectReference ObjectReference::parse(const std::string& str)
     if (*t == '[') {
         t++;
 
+        // An equal sign was once used for a length assertion but is now
+        // deprecated.  Skip it if present, and mark that we are expecting a
+        // length-only reference.
         if (*t == '=') {
             range_exact = true;
             t++;
@@ -179,6 +180,7 @@ ObjectReference ObjectReference::parse(const std::string& str)
         if (*t == ']') {
             string val(s, t - s);
             range2 = atoll(val.c_str());
+            range_exact = true;
         } else {
             if (*t != '+')
                 return ObjectReference();