diff options
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/check-portability/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/check-portability/files/check-portability.c | 12 | ||||
-rw-r--r-- | pkgtools/check-portability/files/testdata/random | 3 |
3 files changed, 11 insertions, 8 deletions
diff --git a/pkgtools/check-portability/Makefile b/pkgtools/check-portability/Makefile index d1687809725..1b7069289e3 100644 --- a/pkgtools/check-portability/Makefile +++ b/pkgtools/check-portability/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.8 2020/03/21 15:02:20 rillig Exp $ +# $NetBSD: Makefile,v 1.9 2020/04/19 12:05:14 rillig Exp $ -PKGNAME= check-portability-19.4.3 +PKGNAME= check-portability-20.1.0 CATEGORIES= pkgtools DISTFILES= # none diff --git a/pkgtools/check-portability/files/check-portability.c b/pkgtools/check-portability/files/check-portability.c index e9644e6f2d0..4dcc8aa3c83 100644 --- a/pkgtools/check-portability/files/check-portability.c +++ b/pkgtools/check-portability/files/check-portability.c @@ -1,4 +1,4 @@ -/* $NetBSD: check-portability.c,v 1.12 2020/03/21 15:02:20 rillig Exp $ */ +/* $NetBSD: check-portability.c,v 1.13 2020/04/19 12:05:14 rillig Exp $ */ /* Copyright (c) 2020 Roland Illig @@ -39,9 +39,9 @@ static const size_t npos = -1; static bool -is_alnum(char c) +is_alnumu(char c) { - return isalnum((unsigned char) c) != 0; + return isalnum((unsigned char) c) != 0 || c == '_'; } static bool @@ -160,12 +160,12 @@ cstr_right_of_last(cstr s, cstr delimiter) } static bool -cstr_has_word_boundary(cstr s, size_t idx) +cstr_has_varname_boundary(cstr s, size_t idx) { assert(idx <= s.len); if (idx == 0 || idx == s.len) return true; - return is_alnum(s.data[idx - 1]) != is_alnum(s.data[idx]); + return is_alnumu(s.data[idx - 1]) != is_alnumu(s.data[idx]); } // str is a modifiable string buffer. @@ -376,7 +376,7 @@ checkline_sh_dollar_random(cstr filename, size_t lineno, cstr line) size_t idx = cstr_index(line, CSTR("$RANDOM")); // Variable names that only start with RANDOM are not special. - if (idx == npos || !cstr_has_word_boundary(line, idx + 7)) + if (idx == npos || !cstr_has_varname_boundary(line, idx + 7)) return; // $RANDOM together with the PID is often found in GNU-style diff --git a/pkgtools/check-portability/files/testdata/random b/pkgtools/check-portability/files/testdata/random index 302c34a6af7..c5095524f32 100644 --- a/pkgtools/check-portability/files/testdata/random +++ b/pkgtools/check-portability/files/testdata/random @@ -16,3 +16,6 @@ ${RANDOM} # This is not a special variable. $RANDOMNESS + +# This is not a special variable as well. +$RANDOM_FILE |