From 4dd183f3c1cd093af0fc1382bd9d822423bbb748 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Fri, 6 Nov 2009 13:29:58 +0200 Subject: version: add support for version control suffixes add cvs, svn, git and mercurial tags for creating snapshot packages. --- src/version.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/version.c') diff --git a/src/version.c b/src/version.c index 8ac7024..34c5f1a 100644 --- a/src/version.c +++ b/src/version.c @@ -73,6 +73,7 @@ static void next_token(int *type, apk_blob_t *blob) static int get_token(int *type, apk_blob_t *blob) { static const char *pre_suffixes[] = { "alpha", "beta", "pre", "rc" }; + static const char *post_suffixes[] = { "cvs", "svn", "git", "hg", "p" }; int v = 0, i = 0, nt = TOKEN_INVALID; if (blob->len <= 0) { @@ -112,10 +113,14 @@ static int get_token(int *type, apk_blob_t *blob) v = v - ARRAY_SIZE(pre_suffixes); break; } - if (strncmp("p", blob->ptr, 1) == 0) { - v = 1; - break; + for (v = 0; v < ARRAY_SIZE(post_suffixes); v++) { + i = strlen(post_suffixes[v]); + if (i <= blob->len && + strncmp(post_suffixes[v], blob->ptr, i) == 0) + break; } + if (v < ARRAY_SIZE(post_suffixes)) + break; /* fallthrough: invalid suffix */ default: *type = TOKEN_INVALID; -- cgit v1.2.3-60-g2f50