aboutsummaryrefslogtreecommitdiff
path: root/libbutl/standard-version.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-05-04 15:52:13 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-05-04 15:52:13 +0300
commitb5b66e6a831cf68b7da764235f669fad758491fb (patch)
tree7778767e088ba47ba48c2c17e43e79709fef1012 /libbutl/standard-version.cxx
parent0cbdc0afe4ef27417e654fd1409f644c5bd01ca4 (diff)
Change standard version epoch syntax from '<num>~' to '+<num>-'
Diffstat (limited to 'libbutl/standard-version.cxx')
-rw-r--r--libbutl/standard-version.cxx25
1 files changed, 11 insertions, 14 deletions
diff --git a/libbutl/standard-version.cxx b/libbutl/standard-version.cxx
index d8582dd..b7678ac 100644
--- a/libbutl/standard-version.cxx
+++ b/libbutl/standard-version.cxx
@@ -137,25 +137,21 @@ namespace butl
{
auto bail = [] (const char* m) {throw invalid_argument (m);};
- // Pre-parse the first component to see if the version starts with epoch,
- // to keep the subsequent parsing straightforward.
- //
- bool ep (false);
- {
- char* e (nullptr);
- strtoull (s.c_str (), &e, 10);
- ep = *e == '~';
- }
-
// Note that here and below p is less or equal n, and so s[p] is always
// valid.
//
size_t p (0), n (s.size ());
+ bool ep (s[p] == '+'); // Has epoch.
+
if (ep)
{
- epoch = parse_uint16 (s, p, "invalid epoch", 1, uint16_t (~0));
- ++p; // Skip '~'.
+ epoch = parse_uint16 (s, ++p, "invalid epoch", 1, uint16_t (~0));
+
+ // Skip the terminating character if it is '-', otherwise fail.
+ //
+ if (s[p++] != '-')
+ bail ("'-' expected after epoch");
}
uint16_t ma, mi, bf, ab (0);
@@ -446,8 +442,9 @@ namespace butl
if (epoch != 0)
{
- r = to_string (epoch);
- r += '~';
+ r += '+';
+ r += to_string (epoch);
+ r += '-';
}
r += string_project ();