From 00ed910db37a1161c309383fb74c11622090af97 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 5 Sep 2017 14:19:46 +0000 Subject: Add support for "-rc" releases, which are the same as final releases but the version string is different. --- doc/package.n | 16 ++++++++++++---- generic/tcl.h | 19 +++++++++++++++++++ generic/tclPkg.c | 33 ++++++++++++++++++++++----------- tests/package.test | 6 +++++- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/doc/package.n b/doc/package.n index 410fe38..4472ba5 100644 --- a/doc/package.n +++ b/doc/package.n @@ -311,23 +311,31 @@ In addition, the specifiers .QW -alpha (alpha) and/or .QW -beta -(beta) may be inserted +(beta) and/or +.QW -rc +(rc) may be inserted exactly once just before a dot for separation. These specifiers semantically add a negative specifier into the version, where .QW -alpha -is \-2, and +is \-3, and .QW -beta +is \-2, and +.QW -rc is \-1. Each may be specified only once, and .QW -alpha or .QW -beta +or +.QW -rc are mutually exclusive in a specifier. Thus 1.3.0-alpha.1 becomes (semantically) -1.3.0.\-2.1, 1.3.0-beta.1 is 1.3.0.\-1.1. Negative numbers are not directly allowed +1.3.0.\-3.1, 1.3.0-beta.1 is 1.3.0.\-2.1. Negative numbers are not directly allowed in version specifiers. A version number not containing the specifier .QW -alpha or .QW -beta +or +.QW -rc as specified above is called a \fBstable\fR version, whereas presence of the specifier causes the version to be called is \fBunstable\fR. @@ -346,7 +354,7 @@ number of elements doesn't need to be 3 (MAJOR, MINOR, PATCH), but it could be for reasons of compatibility with the "Semantic Versioning" specification. Tcl and Tk >= 8.7 follow this specificiation, but packages are not required to do that: Those packages will still function as expected -with Tcl and Tk >= 8.7. +with Tcl and Tk >= 8.7. There is no short equivalent to \fB-rc.\fR .PP Note that valid version number may contain a "-", while a dash can also be used to separate two version numbers in a requirement. The rule diff --git a/generic/tcl.h b/generic/tcl.h index e35129a..7648e38 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -57,6 +57,25 @@ extern "C" { #define TCL_RELEASE_LEVEL TCL_ALPHA_RELEASE #define TCL_RELEASE_SERIAL 0 +/* + * Translation of above numbers to the strings below are as follows: + * TCL_VERSION = $TCL_MAJOR_VERSION.$TCL_MINOR_VERSION + * For alpha releases: + * TCL_PATCH_LEVEL = $TCL_MAJOR_VERSION.$TCL_MINOR_VERSION.0-alpha.$TCL_RELEASE_SERIAL + * For beta releases: + * TCL_PATCH_LEVEL = $TCL_MAJOR_VERSION.$TCL_MINOR_VERSION.0-beta.$TCL_RELEASE_SERIAL + * For rc releases (not distinguishing from final releases, other than through TCL_PATCH_LEVEL): + * TCL_PATCH_LEVEL = $TCL_MAJOR_VERSION.$TCL_MINOR_VERSION.0-rc.1 + * For final releases: + * TCL_PATCH_LEVEL = $TCL_MAJOR_VERSION.$TCL_MINOR_VERSION.$TCL_RELEASE_SERIAL + * + * Indeed, for alpha and beta releases, and additional ".0" is inserted in order + * to comply with the semver rules that the numerical version must consist of 3 parts. + * It indicates that version "a.b.c-anything" will eventually lead to version "a.b.c". + * Tcl only releases alpha/beta's for c=0, there are no plans to change that (although + * it would be possible with the semver numbering) + */ + #define TCL_VERSION "8.7" #define TCL_PATCH_LEVEL "8.7.0-alpha.0" diff --git a/generic/tclPkg.c b/generic/tclPkg.c index 5b19ca2..87f3f3e 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -1402,7 +1402,7 @@ CheckVersionAndConvert( int hasunstable = 0; /* * 4* assuming that each char is a separator (a,b become ' -x '). - * 4+ to have spce for an additional -2 at the end + * 4+ to have spce for an additional -3 at the end */ char *ibuf = ckalloc(4 + 4*strlen(string)); char *ip = ibuf; @@ -1422,7 +1422,9 @@ CheckVersionAndConvert( * * TIP 439, Modified rules * In stead of "a" and "b" in the above rules, the longer - * forms "-alpha." and "-beta." are accepted as well + * forms "-alpha." and "-beta." are accepted as well. In + * addition, "-rc." is allowed as intermediate between + * beta and final release. */ if (!isdigit(UCHAR(*p))) { /* INTL: digit */ @@ -1435,7 +1437,7 @@ CheckVersionAndConvert( if (!isdigit(UCHAR(*p)) && /* INTL: digit */ ((*p!='.' && *p!='a' && *p!='b' && *p!='-') || ((hasunstable && (*p=='a' || *p=='b'|| *p=='-')) || - ((prevChar=='a' || prevChar=='b' || prevChar=='.') + ((prevChar=='a' || prevChar=='b' || prevChar=='r' || prevChar=='.') && (*p=='.')) || ((*p=='a' || *p=='b' || *p=='.') && prevChar=='.')))) { goto error; @@ -1455,6 +1457,9 @@ CheckVersionAndConvert( } else if (!strncmp(p+1, "beta.", 5)) { p += 5; prevChar = 'b'; + } else if (!strncmp(p+1, "rc.", 3)) { + p += 3; + prevChar = 'r'; } } if (prevChar == '.') { @@ -1465,12 +1470,18 @@ CheckVersionAndConvert( hasunstable = 1; *ip++ = ' '; *ip++ = '-'; - *ip++ = '2'; + *ip++ = '3'; *ip++ = ' '; } else if (prevChar == 'b') { hasunstable = 1; *ip++ = ' '; *ip++ = '-'; + *ip++ = '2'; + *ip++ = ' '; + } else if (prevChar == 'r') { + hasunstable = 1; + *ip++ = ' '; + *ip++ = '-'; *ip++ = '1'; *ip++ = ' '; } else { @@ -1478,7 +1489,7 @@ CheckVersionAndConvert( } } - if (prevChar!='.' && prevChar!='a' && prevChar!='b') { + if (prevChar!='.' && prevChar!='a' && prevChar!='b' && prevChar!='r') { *ip = '\0'; if (internal != NULL) { *internal = ibuf; @@ -1942,7 +1953,7 @@ RequirementSatisfied( /* * No dash found, is a simple version, fallback to regular check. The * 'CheckVersionAndConvert' cannot fail. We pad the requirement with - * 'a0', i.e '-2' before doing the comparison to properly accept + * 'a0', i.e '-3' before doing the comparison to properly accept * unstables as well. */ @@ -1950,7 +1961,7 @@ RequirementSatisfied( int thisIsMajor; CheckVersionAndConvert(NULL, req, &reqi, NULL); - strcat(reqi, " -2"); + strcat(reqi, " -3"); res = CompareVersions(havei, reqi, &thisIsMajor); satisfied = (res == 0) || ((res == 1) && !thisIsMajor); ckfree(reqi); @@ -1971,11 +1982,11 @@ RequirementSatisfied( if (*dash == '\0') { /* * We have a min, but no max. For the comparison we generate the - * internal rep, padded with 'a0' i.e. '-2'. + * internal rep, padded with 'a0' i.e. '-3'. */ CheckVersionAndConvert(NULL, buf, &min, NULL); - strcat(min, " -2"); + strcat(min, " -3"); satisfied = (CompareVersions(havei, min, NULL) >= 0); ckfree(min); ckfree(buf); @@ -1994,8 +2005,8 @@ RequirementSatisfied( if (CompareVersions(min, max, NULL) == 0) { satisfied = (CompareVersions(min, havei, NULL) == 0); } else { - strcat(min, " -2"); - strcat(max, " -2"); + strcat(min, " -3"); + strcat(max, " -3"); satisfied = ((CompareVersions(min, havei, NULL) <= 0) && (CompareVersions(havei, max, NULL) < 0)); } diff --git a/tests/package.test b/tests/package.test index 8e36763..3ee868f 100644 --- a/tests/package.test +++ b/tests/package.test @@ -117,10 +117,14 @@ test package-2.6 {Tcl_PkgProvide procedure} { package forget t package provide t 2.3a1 } {} -test package-2.6 {Tcl_PkgProvide procedure} { +test package-2.7 {Tcl_PkgProvide procedure} { package forget t package provide t 2.3.0-alpha.1 } {} +test package-2.8 {Tcl_PkgProvide procedure} { + package forget t + package provide t 2.3.0-rc.1 +} {} set n 0 foreach v { -- cgit v0.12