From 9e2b58fe3743add27efffedd9e4c42016a5805d0 Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 19 Apr 2020 12:05:14 +0000 Subject: pkgtools/check-portability: update to 20.1.0 Changes since 19.4.3: The variable name RANDOM_FILE is ok since it doesn't have a special meaning to some shell implementations. Seen in www/curl. --- pkgtools/check-portability/Makefile | 4 ++-- pkgtools/check-portability/files/check-portability.c | 12 ++++++------ pkgtools/check-portability/files/testdata/random | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'pkgtools') 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 -- cgit v1.2.3