pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint pkgtools/pkglint: update to 21.1.4



details:   https://anonhg.NetBSD.org/pkgsrc/rev/18211da19871
branches:  trunk
changeset: 454100:18211da19871
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Jun 06 11:46:43 2021 +0000

description:
pkgtools/pkglint: update to 21.1.4

Changes since 21.1.3:

Allow slash in Git tags like 'refs/tags/v1.0.0', as well as in make
targets like 'subdir/build'.

diffstat:

 pkgtools/pkglint/Makefile                     |   4 +-
 pkgtools/pkglint/files/category.go            |   2 +-
 pkgtools/pkglint/files/licenses/licenses.go   |   2 +-
 pkgtools/pkglint/files/mkcondchecker.go       |   6 +-
 pkgtools/pkglint/files/mkline.go              |   8 +-
 pkgtools/pkglint/files/textproc/lexer.go      |   4 +-
 pkgtools/pkglint/files/textproc/lexer_test.go |  79 ++++++++++++++++++++++++--
 pkgtools/pkglint/files/vardefs.go             |  14 ++--
 pkgtools/pkglint/files/vartype.go             |   3 +
 pkgtools/pkglint/files/vartypecheck.go        |  54 +++++++++++++++---
 pkgtools/pkglint/files/vartypecheck_test.go   |  53 ++++++++++++++++++
 11 files changed, 193 insertions(+), 36 deletions(-)

diffs (truncated from 460 to 300 lines):

diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/Makefile
--- a/pkgtools/pkglint/Makefile Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/Makefile Sun Jun 06 11:46:43 2021 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.687 2021/06/06 07:41:34 rillig Exp $
+# $NetBSD: Makefile,v 1.688 2021/06/06 11:46:43 rillig Exp $
 
-PKGNAME=       pkglint-21.1.3
+PKGNAME=       pkglint-21.1.4
 CATEGORIES=    pkgtools
 DISTNAME=      tools
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=golang/}
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/category.go
--- a/pkgtools/pkglint/files/category.go        Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/category.go        Sun Jun 06 11:46:43 2021 +0000
@@ -25,7 +25,7 @@
        if mlex.SkipIf(func(mkline *MkLine) bool { return mkline.IsVarassign() && mkline.Varname() == "COMMENT" }) {
                mkline := mlex.PreviousMkLine()
 
-               valid := textproc.NewByteSet("--- '(),/0-9A-Za-z")
+               valid := textproc.NewByteSet("- '(),/0-9A-Za-z")
                invalid := invalidCharacters(mkline.Value(), valid)
                if invalid != "" {
                        mkline.Warnf("%s contains invalid characters (%s).",
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/licenses/licenses.go
--- a/pkgtools/pkglint/files/licenses/licenses.go       Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/licenses/licenses.go       Sun Jun 06 11:46:43 2021 +0000
@@ -67,7 +67,7 @@
        error  string
 }
 
-var licenseNameChars = textproc.NewByteSet("A-Za-z0-9---._")
+var licenseNameChars = textproc.NewByteSet("A-Za-z0-9-._")
 
 func (lexer *licenseLexer) Lex(llval *liyySymType) int {
        lex := lexer.lexer
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/mkcondchecker.go
--- a/pkgtools/pkglint/files/mkcondchecker.go   Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/mkcondchecker.go   Sun Jun 06 11:46:43 2021 +0000
@@ -152,11 +152,13 @@
 // mkCondStringLiteralUnquoted contains a safe subset of the characters
 // that may be used without surrounding quotes in a comparison such as
 // ${PKGPATH} == category/package.
-var mkCondStringLiteralUnquoted = textproc.NewByteSet("+---./0-9@A-Z_a-z")
+// TODO: Check whether the ',' really needs to be here.
+var mkCondStringLiteralUnquoted = textproc.NewByteSet("-+,./0-9@A-Z_a-z")
 
 // mkCondModifierPatternLiteral contains a safe subset of the characters
 // that are interpreted literally in the :M and :N modifiers.
-var mkCondModifierPatternLiteral = textproc.NewByteSet("+---./0-9<=>@A-Z_a-z")
+// TODO: Check whether the ',' really needs to be here.
+var mkCondModifierPatternLiteral = textproc.NewByteSet("-+,./0-9<=>@A-Z_a-z")
 
 // simplify replaces an unnecessarily complex condition with
 // a simpler condition that's still equivalent.
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/mkline.go
--- a/pkgtools/pkglint/files/mkline.go  Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/mkline.go  Sun Jun 06 11:46:43 2021 +0000
@@ -700,7 +700,7 @@
 }
 
 var (
-       LowerDash                  = textproc.NewByteSet("a-z---")
+       LowerDash                  = textproc.NewByteSet("a-z-")
        AlnumDot                   = textproc.NewByteSet("A-Za-z0-9_.")
        unescapeMkCommentSafeChars = textproc.NewByteSet("\\#[\n").Inverse()
 )
@@ -1327,8 +1327,10 @@
 // TODO: The allowed characters differ between the basename and the parameter
 //  of the variable. The square bracket is only allowed in the parameter part.
 var (
-       VarbaseBytes  = textproc.NewByteSet("A-Za-z_0-9+---")
-       VarparamBytes = textproc.NewByteSet("A-Za-z_0-9#*+---./[")
+       // TODO: remove the ','
+       VarbaseBytes = textproc.NewByteSet("A-Za-z_0-9-+,")
+       // TODO: Check whether the ',' really needs to be here.
+       VarparamBytes = textproc.NewByteSet("A-Za-z_0-9-#*+,./[")
 )
 
 func MatchMkInclude(text string) (m bool, indentation, directive string, filename RelPath) {
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/textproc/lexer.go
--- a/pkgtools/pkglint/files/textproc/lexer.go  Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/textproc/lexer.go  Sun Jun 06 11:46:43 2021 +0000
@@ -240,8 +240,8 @@
 func (l *Lexer) Commit(other *Lexer) bool { l.rest = other.rest; return true }
 
 // NewByteSet creates a bit mask out of a string like "0-9A-Za-z_".
-// To add an actual hyphen to the bit mask, write it as "---"
-// (a range from hyphen to hyphen).
+// To add an actual hyphen to the bit mask, write it either at the beginning
+// or at the end of the string, or directly after a range like "a-z".
 //
 // The bit mask can be used with Lexer.NextBytesSet.
 func NewByteSet(chars string) *ByteSet {
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/textproc/lexer_test.go
--- a/pkgtools/pkglint/files/textproc/lexer_test.go     Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/textproc/lexer_test.go     Sun Jun 06 11:46:43 2021 +0000
@@ -359,18 +359,81 @@
 }
 
 // Demonstrates how to specify a byte set that includes a hyphen,
-// since that is also used for byte ranges.
-// The hyphen must be written as ---, which is a range from hyphen to hyphen.
-func (s *Suite) Test_NewByteSet__range_hyphen(c *check.C) {
+// since that character is also used for byte ranges.
+// The hyphen is written as ---, which is a range from hyphen to hyphen.
+func (s *Suite) Test_NewByteSet__range_hyphen_beginning(c *check.C) {
        set := NewByteSet("---a-z")
 
-       expected := "abcdefghijklmnopqrstuvwxyz-"
+       var actual strings.Builder
+       for i := 0; i < 256; i++ {
+               if set.Contains(byte(i)) {
+                       actual.WriteByte(byte(i))
+               }
+       }
+
+       c.Check(actual.String(), equals, "-abcdefghijklmnopqrstuvwxyz")
+}
+
+// The byte set "x---a" is interpreted as 3 parts: "x--", "-", "a".
+//
+// The range "x--" is empty since U+0078 'x' comes later in Unicode than
+// U+002D '-'.
+func (s *Suite) Test_NewByteSet__range_hyphen_middle(c *check.C) {
+       set := NewByteSet("x---a")
+
+       var actual strings.Builder
+       for i := 0; i < 256; i++ {
+               if set.Contains(byte(i)) {
+                       actual.WriteByte(byte(i))
+               }
+       }
+
+       c.Check(actual.String(), equals, "-a")
+}
+
+// When a hyphen is listed at the very beginning, it is not considered part
+// of a byte range but interpreted literally.
+func (s *Suite) Test_NewByteSet__hyphen_beginning(c *check.C) {
+       set := NewByteSet("-ax")
+
+       var actual strings.Builder
        for i := 0; i < 256; i++ {
-               c.Check(
-                       set.Contains(byte(i)),
-                       equals,
-                       strings.IndexByte(expected, byte(i)) != -1)
+               if set.Contains(byte(i)) {
+                       actual.WriteByte(byte(i))
+               }
        }
+
+       c.Check(actual.String(), equals, "-ax")
+}
+
+// When a hyphen is listed directly after a range ('+-+' in this case),
+// it is interpreted literally.
+func (s *Suite) Test_NewByteSet__hyphen_after_range(c *check.C) {
+       set := NewByteSet("+-+-")
+
+       var actual strings.Builder
+       for i := 0; i < 256; i++ {
+               if set.Contains(byte(i)) {
+                       actual.WriteByte(byte(i))
+               }
+       }
+
+       c.Check(actual.String(), equals, "+-")
+}
+
+// When a hyphen is listed at the very end, it is not considered part
+// of a byte range but interpreted literally.
+func (s *Suite) Test_NewByteSet__hyphen_end(c *check.C) {
+       set := NewByteSet("ax-")
+
+       var actual strings.Builder
+       for i := 0; i < 256; i++ {
+               if set.Contains(byte(i)) {
+                       actual.WriteByte(byte(i))
+               }
+       }
+
+       c.Check(actual.String(), equals, "-ax")
 }
 
 func (s *Suite) Test_ByteSet_Inverse(c *check.C) {
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/vardefs.go
--- a/pkgtools/pkglint/files/vardefs.go Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/vardefs.go Sun Jun 06 11:46:43 2021 +0000
@@ -1032,8 +1032,8 @@
        reg.pkglist("BUILD_ENV", BtShellWord)
        reg.sys("BUILD_MAKE_CMD", BtShellCommand)
        reg.pkglist("BUILD_MAKE_FLAGS", BtShellWord)
-       reg.pkglist("BUILD_TARGET", BtIdentifierIndirect)
-       reg.pkglist("BUILD_TARGET.*", BtIdentifierIndirect)
+       reg.pkglist("BUILD_TARGET", BtMakeTarget)
+       reg.pkglist("BUILD_TARGET.*", BtMakeTarget)
        reg.pkg("BUILD_USES_MSGFMT", BtYes)
        reg.acl("BUILTIN_PKG", BtIdentifierDirect,
                PackageSettable,
@@ -1143,12 +1143,12 @@
        reg.pkg("DISTNAME", BtFilename)
        reg.pkg("DIST_SUBDIR", BtPathname)
        reg.pkglist("DJB_BUILD_ARGS", BtShellWord)
-       reg.pkglist("DJB_BUILD_TARGETS", BtIdentifierIndirect)
+       reg.pkglist("DJB_BUILD_TARGETS", BtMakeTarget)
        reg.pkgappend("DJB_CONFIG_CMDS", BtShellCommands)
        reg.pkglist("DJB_CONFIG_DIRS", BtWrksrcSubdirectory)
        reg.pkg("DJB_CONFIG_HOME", BtFilename)
        reg.pkg("DJB_CONFIG_PREFIX", BtPathname)
-       reg.pkglist("DJB_INSTALL_TARGETS", BtIdentifierIndirect)
+       reg.pkglist("DJB_INSTALL_TARGETS", BtMakeTarget)
        reg.pkg("DJB_MAKE_TARGETS", BtYesNo)
        reg.pkg("DJB_RESTRICTED", BtYesNo)
        reg.pkg("DJB_SLASHPACKAGE", BtYesNo)
@@ -1230,7 +1230,7 @@
        reg.pkglistbl3rat("GCC_REQD", BtGccReqd)
        reg.pkgappend("GENERATE_PLIST", BtShellCommands)
        reg.pkg("GITHUB_PROJECT", BtIdentifierIndirect)
-       reg.pkg("GITHUB_TAG", BtIdentifierIndirect)
+       reg.pkg("GITHUB_TAG", BtGitTag)
        reg.pkg("GITHUB_RELEASE", BtFilename)
        reg.pkg("GITHUB_TYPE", enum("tag release"))
        reg.pkgrat("GMAKE_REQD", BtVersion)
@@ -1282,7 +1282,7 @@
        reg.syslist("INSTALL_SCRIPTS_ENV", BtShellWord)
        reg.sys("INSTALL_SCRIPT_DIR", BtShellCommand)
        reg.pkglist("INSTALL_SRC", BtPathname)
-       reg.pkglist("INSTALL_TARGET", BtIdentifierIndirect)
+       reg.pkglist("INSTALL_TARGET", BtMakeTarget)
        reg.pkglist("INSTALL_TEMPLATES", BtPathname)
        reg.pkgload("INSTALL_UNSTRIPPED", BtYesNo)
        reg.pkglist("INTERACTIVE_STAGE", enum("fetch extract configure build test install"))
@@ -1729,7 +1729,7 @@
        reg.pkglist("TEST_DEPENDS", BtDependencyWithPath)
        reg.pkglist("TEST_DIRS", BtWrksrcSubdirectory)
        reg.pkglist("TEST_ENV", BtShellWord)
-       reg.pkglist("TEST_TARGET", BtIdentifierIndirect)
+       reg.pkglist("TEST_TARGET", BtMakeTarget)
        reg.pkglistrat("TEXINFO_REQD", BtVersion)
        reg.pkglistbl3("TOOL_DEPENDS", BtDependencyWithPath)
        reg.syslist("TOOLS_ALIASES", BtFilename)
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/vartype.go
--- a/pkgtools/pkglint/files/vartype.go Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/vartype.go Sun Jun 06 11:46:43 2021 +0000
@@ -358,6 +358,7 @@
                BtEmulPlatform,
                BtFileMode,
                BtFilename,
+               BtGitTag,
                BtIdentifierDirect,
                BtIdentifierIndirect,
                BtInteger,
@@ -428,6 +429,7 @@
        BtFilePattern            = &BasicType{"FilePattern", (*VartypeCheck).FilePattern}
        BtFileMode               = &BasicType{"FileMode", (*VartypeCheck).FileMode}
        BtGccReqd                = &BasicType{"GccReqd", (*VartypeCheck).GccReqd}
+       BtGitTag                 = &BasicType{"GitTag", (*VartypeCheck).GitTag}
        BtHomepage               = &BasicType{"Homepage", (*VartypeCheck).Homepage}
        BtIdentifierDirect       = &BasicType{"Identifier", (*VartypeCheck).IdentifierDirect}
        BtIdentifierIndirect     = &BasicType{"Identifier", (*VartypeCheck).IdentifierIndirect}
@@ -438,6 +440,7 @@
        BtMachinePlatform        = &BasicType{"MachinePlatform", (*VartypeCheck).MachinePlatform}
        BtMachinePlatformPattern = &BasicType{"MachinePlatformPattern", (*VartypeCheck).MachinePlatformPattern}
        BtMailAddress            = &BasicType{"MailAddress", (*VartypeCheck).MailAddress}
+       BtMakeTarget             = &BasicType{"MakeTarget", (*VartypeCheck).MakeTarget}
        BtMessage                = &BasicType{"Message", (*VartypeCheck).Message}
        BtOption                 = &BasicType{"Option", (*VartypeCheck).Option}
        BtPathlist               = &BasicType{"Pathlist", (*VartypeCheck).Pathlist}
diff -r f0f2560a7895 -r 18211da19871 pkgtools/pkglint/files/vartypecheck.go
--- a/pkgtools/pkglint/files/vartypecheck.go    Sun Jun 06 11:42:15 2021 +0000
+++ b/pkgtools/pkglint/files/vartypecheck.go    Sun Jun 06 11:46:43 2021 +0000
@@ -21,7 +21,7 @@
        Varname    string
        Op         MkOperator
        Value      string
-       ValueNoVar string
+       ValueNoVar string // The Value with all expressions removed.
        MkComment  string // The comment including the "#".
        Guessed    bool   // Whether the type definition is guessed (based on the variable name) or explicitly defined (see vardefs.go).
 }
@@ -676,6 +676,29 @@
        }
 }
 
+// GitTag checks for a fixed reference to a Git commit.
+//
+// https://git-scm.com/docs/gitrevisions
+func (cv *VartypeCheck) GitTag() {
+       tag := cv.ValueNoVar
+
+       valid := textproc.NewByteSet("0-9A-Za-z-+._/")
+       invalid := invalidCharacters(tag, valid)
+       if invalid != "" {
+               cv.Warnf("Invalid characters %q in Git tag.", invalid)
+               return
+       }
+
+       if tag == "master" || hasPrefix(tag, "refs/heads/") {



Home | Main Index | Thread Index | Old Index