diff options
| author | Pierre Pronchery <khorben@FreeBSD.org> | 2026-06-25 22:30:05 +0000 |
|---|---|---|
| committer | Pierre Pronchery <khorben@FreeBSD.org> | 2026-06-29 05:21:48 +0000 |
| commit | b0fc1b7a2fe8fcb18ee407227591bf25a86ffbaf (patch) | |
| tree | 0cc32f86bf808bcf9d79da95db969cd76f0feadb /libpkgconf/version.c | |
| parent | eaa637963bcfde283b411c14968b7903b02d6aa1 (diff) | |
Vendor import of pkgconf 2.9.92vendor/pkgconf/2.9.92
Obtained from https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-2.9.92.tar.gz
SHA1: 865d15aac5e720a8897b14e0f475736a810a9340 -
SHA256: 1eeda57d5f7b8dd346278ea164536f313366bb10d531d7c490be439638942f6d -
SHA512: a66960f79f83508e372ef948ec98f906abb31aed0b4c1a667f2cf8235f55ede1553fc5dfd1baaa6217a2d82c725448e64207b1dfb858f21fdb12f82e6771546f -
One test folder in tests/lib1 had to be removed to avoid UTF-8 filenames
in the tree. (Breaks `make create-source-packages`)
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57856
Diffstat (limited to 'libpkgconf/version.c')
| -rw-r--r-- | libpkgconf/version.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/libpkgconf/version.c b/libpkgconf/version.c index 7b597bd721b2..9a958fe3d1f6 100644 --- a/libpkgconf/version.c +++ b/libpkgconf/version.c @@ -23,8 +23,7 @@ typedef enum { PKGCONF_VERSION_TOKEN_END = 0, PKGCONF_VERSION_TOKEN_TILDE, PKGCONF_VERSION_TOKEN_NUMERIC, - PKGCONF_VERSION_TOKEN_ALPHA, - PKGCONF_VERSION_TOKEN_OTHER + PKGCONF_VERSION_TOKEN_ALPHA } pkgconf_version_token_kind_t; typedef struct { @@ -85,17 +84,14 @@ pkgconf_version_next_token(pkgconf_version_iter_t *it) return tok; } - if (isalpha((unsigned char)*s)) - { - tok.kind = PKGCONF_VERSION_TOKEN_ALPHA; - while (*tok.end && isalpha((unsigned char)*tok.end)) - tok.end++; - it->cur = tok.end; - return tok; - } - - tok.kind = PKGCONF_VERSION_TOKEN_OTHER; - tok.end = s + 1; + /* + * Having skipped separators and ruled out end-of-string, tilde and + * digits, the only remaining possibility is alpha: isalnum(c) is by + * definition isalpha(c) || isdigit(c). + */ + tok.kind = PKGCONF_VERSION_TOKEN_ALPHA; + while (*tok.end && isalpha((unsigned char)*tok.end)) + tok.end++; it->cur = tok.end; return tok; @@ -190,20 +186,10 @@ pkgconf_version_compare_token(const pkgconf_version_token_t *a, const pkgconf_ve } /* left-side is alpha, any right-side non-alpha wins */ - if (a->kind == PKGCONF_VERSION_TOKEN_ALPHA) - { - if (b->kind != PKGCONF_VERSION_TOKEN_ALPHA) - return -1; - - return pkgconf_version_compare_alpha(a, b); - } - - if (a->kind < b->kind) + if (b->kind != PKGCONF_VERSION_TOKEN_ALPHA) return -1; - if (a->kind > b->kind) - return 1; - return 0; + return pkgconf_version_compare_alpha(a, b); } /* |
