X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=ref.cc;fp=ref.cc;h=8ed747ddaa59b0c992442e56abfe4a3275d5b2ac;hb=ab51d5778a1f19c204c935de231737df2e62c20c;hp=80f4d1deb51ee95706cb41559183e8466726baa9;hpb=2fc79690f0e5066b689746b18d42b95eca48a0ab;p=cumulus.git diff --git a/ref.cc b/ref.cc index 80f4d1d..8ed747d 100644 --- a/ref.cc +++ b/ref.cc @@ -78,7 +78,11 @@ string ObjectReference::to_string() const if (range_valid) { char buf[64]; - sprintf(buf, "[%zu+%zu]", range_start, range_length); + if (range_start == 0) { + sprintf(buf, "[%zu]", range_length); + } else { + sprintf(buf, "[%zu+%zu]", range_start, range_length); + } result += buf; } @@ -143,21 +147,28 @@ ObjectReference ObjectReference::parse(const std::string& str) s = t; while (*t >= '0' && *t <= '9') t++; - if (*t != '+') - return ObjectReference(); - string val(s, t - s); - range1 = atoll(val.c_str()); + // Abbreviated-length only range? + if (*t == ']') { + string val(s, t - s); + range2 = atoll(val.c_str()); + } else { + if (*t != '+') + return ObjectReference(); - t++; - s = t; - while (*t >= '0' && *t <= '9') - t++; - if (*t != ']') - return ObjectReference(); + string val(s, t - s); + range1 = atoll(val.c_str()); - val = string(s, t - s); - range2 = atoll(val.c_str()); + t++; + s = t; + while (*t >= '0' && *t <= '9') + t++; + if (*t != ']') + return ObjectReference(); + + val = string(s, t - s); + range2 = atoll(val.c_str()); + } have_range = true; }