diff options
Diffstat (limited to 'generic/tclPkg.c')
-rw-r--r-- | generic/tclPkg.c | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/generic/tclPkg.c b/generic/tclPkg.c index 9ad3cb7..ec9f3e6 100644 --- a/generic/tclPkg.c +++ b/generic/tclPkg.c @@ -1404,7 +1404,7 @@ CheckVersionAndConvert( int *stable) /* Flag: Version is (un)stable. */ { const char *p = string; - char prevChar; + char prevChar = 0; int hasunstable = 0; /* * 4* assuming that each char is a separator (a,b become ' -x '). @@ -1425,6 +1425,10 @@ CheckVersionAndConvert( * (3) s.a. * (4) Only one of 'a' or 'b' may occur. * (5) Neither 'a', nor 'b' may occur before or after a '.' + * + * TIP 439, Modified rules + * In stead of "a" and "b" in the above rules, the longer + * forms "-alpha." and "-beta." are accepted as well */ if (!isdigit(UCHAR(*p))) { /* INTL: digit */ @@ -1435,34 +1439,42 @@ CheckVersionAndConvert( for (prevChar = *p, p++; *p != 0; p++) { if (!isdigit(UCHAR(*p)) && /* INTL: digit */ - ((*p!='.' && *p!='a' && *p!='b') || - ((hasunstable && (*p=='a' || *p=='b')) || + ((*p!='.' && *p!='a' && *p!='b' && *p!='-') || + ((hasunstable && (*p=='a' || *p=='b'|| *p=='-')) || ((prevChar=='a' || prevChar=='b' || prevChar=='.') && (*p=='.')) || ((*p=='a' || *p=='b' || *p=='.') && prevChar=='.')))) { goto error; } - if (*p == 'a' || *p == 'b') { - hasunstable = 1; - } - /* * Translation to the internal rep. Regular version chars are copied * as is. The separators are translated to numerics. The new separator * for all parts is space. */ - if (*p == '.') { + prevChar = *p; + if (*p == '-') { + if (!strncmp(p+1, "alpha.", 6)) { + p += 6; + prevChar = 'a'; + } else if (!strncmp(p+1, "beta.", 5)) { + p += 5; + prevChar = 'b'; + } + } + if (prevChar == '.') { *ip++ = ' '; *ip++ = '0'; *ip++ = ' '; - } else if (*p == 'a') { + } else if (prevChar == 'a') { + hasunstable = 1; *ip++ = ' '; *ip++ = '-'; *ip++ = '2'; *ip++ = ' '; - } else if (*p == 'b') { + } else if (prevChar == 'b') { + hasunstable = 1; *ip++ = ' '; *ip++ = '-'; *ip++ = '1'; @@ -1471,7 +1483,6 @@ CheckVersionAndConvert( *ip++ = *p; } - prevChar = *p; } if (prevChar!='.' && prevChar!='a' && prevChar!='b') { *ip = '\0'; @@ -1738,7 +1749,10 @@ CheckRequirement( char *dash = NULL, *buf; dash = strchr(string, '-'); - if (dash == NULL) { + if ((dash != NULL) && (dash[1]=='a' || dash[1]=='b')) { + dash = strchr(dash+1, '-'); + } + if ((dash == NULL) || dash[1]=='a' || dash[1]=='b') { /* * No dash found, has to be a simple version. */ @@ -1746,7 +1760,8 @@ CheckRequirement( return CheckVersionAndConvert(interp, string, NULL, NULL); } - if (strchr(dash+1, '-') != NULL) { + buf = strchr(dash+1, '-'); + if ((buf != NULL) && isdigit(UCHAR(buf[1]))) { /* * More dashes found after the first. This is wrong. */ @@ -1926,7 +1941,10 @@ RequirementSatisfied( char *dash = NULL, *buf, *min, *max; dash = strchr(req, '-'); - if (dash == NULL) { + if ((dash != NULL) && (dash[1]=='a' || dash[1]=='b')) { + dash = strchr(dash+1, '-'); + } + if ((dash == NULL) || dash[1]=='a' || dash[1]=='b') { /* * No dash found, is a simple version, fallback to regular check. The * 'CheckVersionAndConvert' cannot fail. We pad the requirement with |