diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-04 15:52:13 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-04 15:52:13 +0300 |
commit | b5b66e6a831cf68b7da764235f669fad758491fb (patch) | |
tree | 7778767e088ba47ba48c2c17e43e79709fef1012 /libbutl | |
parent | 0cbdc0afe4ef27417e654fd1409f644c5bd01ca4 (diff) |
Change standard version epoch syntax from '<num>~' to '+<num>-'
Diffstat (limited to 'libbutl')
-rw-r--r-- | libbutl/standard-version.cxx | 25 | ||||
-rw-r--r-- | libbutl/standard-version.mxx | 4 |
2 files changed, 13 insertions, 16 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 (); diff --git a/libbutl/standard-version.mxx b/libbutl/standard-version.mxx index e6c6f27..b161063 100644 --- a/libbutl/standard-version.mxx +++ b/libbutl/standard-version.mxx @@ -44,8 +44,8 @@ LIBBUTL_MODEXPORT namespace butl { // The build2 "standard version" (specific, earliest and stub): // - // [<epoch>~]<maj>.<min>.<patch>[-(a|b).<num>[.<snapsn>[.<snapid>]]][+<rev>] - // [<epoch>~]<maj>.<min>.<patch>- + // [+<epoch>-]<maj>.<min>.<patch>[-(a|b).<num>[.<snapsn>[.<snapid>]]][+<rev>] + // [+<epoch>-]<maj>.<min>.<patch>- // 0[+<revision>] // struct LIBBUTL_SYMEXPORT standard_version |