aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/utility28
-rw-r--r--build2/utility.cxx19
2 files changed, 38 insertions, 9 deletions
diff --git a/build2/utility b/build2/utility
index 5240e4d..9245d86 100644
--- a/build2/utility
+++ b/build2/utility
@@ -24,8 +24,32 @@ namespace build2
extern const dir_path empty_dir_path;
// Parse version string in the X.Y.Z[-{a|b}N] to a version integer in the
- // AABBCCDD form as describe in <build2/version>. Throw invalid_argument
- // if the passed string is not a valid version.
+ // AABBCCDD form, where:
+ //
+ // AA - major version number
+ // BB - minor version number
+ // CC - bugfix version number
+ // DD - alpha / beta (DD + 50) version number
+ //
+ // When DD is not 00, 1 is subtracted from AABBCC. For example:
+ //
+ // Version AABBCCDD
+ // 2.0.0 02000000
+ // 2.1.0 02010000
+ // 2.1.1 02010100
+ // 2.2.0-a1 02019901
+ // 3.0.0-b2 02999952
+ //
+ // For a version in the 1.2.3- form, it returns (AABBCC-1)01, which is the
+ // lowest possible version in the 1.2.3 release set. For example:
+ //
+ // Version AABBCCDD
+ // 2.2.0- 02019901
+ // 1.2.3- 01020201
+ //
+ // In fact versions 1.2.3- and 1.2.3-a1 are equivalent.
+ //
+ // Throw invalid_argument if the passed string is not a valid version.
//
unsigned int
to_version (const string&);
diff --git a/build2/utility.cxx b/build2/utility.cxx
index bd74e6d..3f078a7 100644
--- a/build2/utility.cxx
+++ b/build2/utility.cxx
@@ -61,16 +61,21 @@ namespace build2
char k (s[++p]);
- if (k != 'a' && k != 'b')
- bail ("'a' or 'b' expected in release component");
+ if (k != '\0')
+ {
+ if (k != 'a' && k != 'b')
+ bail ("'a' or 'b' expected in release component");
- ab = parse (++p, "invalid release component", 1, 49);
+ ab = parse (++p, "invalid release component", 1, 49);
- if (p != n)
- bail ("junk after release component");
+ if (p != n)
+ bail ("junk after release component");
- if (k == 'b')
- ab += 50;
+ if (k == 'b')
+ ab += 50;
+ }
+ else
+ ab = 1;
}
// AABBCCDD