pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/pkglint



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Dec 17 13:35:32 UTC 2016

Modified Files:
        pkgsrc/pkgtools/pkglint: Makefile
        pkgsrc/pkgtools/pkglint/files: files.go mkparser.go mkparser_test.go

Log Message:
Updated pkglint to 5.4.14.

Changes since 5.4.13:

* Pkglint can fix $(VARIABLES) in parentheses to ${VARIABLES} in braces
  automatically


To generate a diff of this commit:
cvs rdiff -u -r1.503 -r1.504 pkgsrc/pkgtools/pkglint/Makefile
cvs rdiff -u -r1.7 -r1.8 pkgsrc/pkgtools/pkglint/files/files.go
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/pkglint/files/mkparser.go
cvs rdiff -u -r1.3 -r1.4 pkgsrc/pkgtools/pkglint/files/mkparser_test.go

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/pkglint/Makefile
diff -u pkgsrc/pkgtools/pkglint/Makefile:1.503 pkgsrc/pkgtools/pkglint/Makefile:1.504
--- pkgsrc/pkgtools/pkglint/Makefile:1.503      Tue Dec 13 00:58:06 2016
+++ pkgsrc/pkgtools/pkglint/Makefile    Sat Dec 17 13:35:32 2016
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.503 2016/12/13 00:58:06 rillig Exp $
+# $NetBSD: Makefile,v 1.504 2016/12/17 13:35:32 rillig Exp $
 
-PKGNAME=       pkglint-5.4.13
+PKGNAME=       pkglint-5.4.14
 DISTFILES=     # none
 CATEGORIES=    pkgtools
 

Index: pkgsrc/pkgtools/pkglint/files/files.go
diff -u pkgsrc/pkgtools/pkglint/files/files.go:1.7 pkgsrc/pkgtools/pkglint/files/files.go:1.8
--- pkgsrc/pkgtools/pkglint/files/files.go:1.7  Sun Dec  4 15:28:36 2016
+++ pkgsrc/pkgtools/pkglint/files/files.go      Sat Dec 17 13:35:32 2016
@@ -33,7 +33,7 @@ func LoadExistingLines(fname string, fol
 func getLogicalLine(fname string, rawLines []*RawLine, pindex *int) *Line {
        { // Handle the common case efficiently
                index := *pindex
-               rawLine := rawLines[*pindex]
+               rawLine := rawLines[index]
                textnl := rawLine.textnl
                if hasSuffix(textnl, "\n") && !hasSuffix(textnl, "\\\n") {
                        *pindex = index + 1

Index: pkgsrc/pkgtools/pkglint/files/mkparser.go
diff -u pkgsrc/pkgtools/pkglint/files/mkparser.go:1.5 pkgsrc/pkgtools/pkglint/files/mkparser.go:1.6
--- pkgsrc/pkgtools/pkglint/files/mkparser.go:1.5       Sun Dec  4 15:28:36 2016
+++ pkgsrc/pkgtools/pkglint/files/mkparser.go   Sat Dec 17 13:35:32 2016
@@ -58,11 +58,15 @@ func (p *MkParser) VarUse() *MkVarUse {
                varnameMark := repl.Mark()
                varname := p.Varname()
                if varname != "" {
-                       if usingRoundParen && p.EmitWarnings {
-                               p.Line.Warnf("Please use curly braces {} instead of round parentheses () for %s.", varname)
-                       }
                        modifiers := p.VarUseModifiers(varname, closing)
                        if repl.AdvanceStr(closing) {
+                               if usingRoundParen && p.EmitWarnings {
+                                       parenVaruse := repl.Since(mark)
+                                       bracesVaruse := "${" + parenVaruse[2:len(parenVaruse)-1] + "}"
+                                       if !p.Line.AutofixReplace(parenVaruse, bracesVaruse) {
+                                               p.Line.Warnf("Please use curly braces {} instead of round parentheses () for %s.", varname)
+                                       }
+                               }
                                return &MkVarUse{varname, modifiers}
                        }
                }

Index: pkgsrc/pkgtools/pkglint/files/mkparser_test.go
diff -u pkgsrc/pkgtools/pkglint/files/mkparser_test.go:1.3 pkgsrc/pkgtools/pkglint/files/mkparser_test.go:1.4
--- pkgsrc/pkgtools/pkglint/files/mkparser_test.go:1.3  Sun Jul 10 21:24:47 2016
+++ pkgsrc/pkgtools/pkglint/files/mkparser_test.go      Sat Dec 17 13:35:32 2016
@@ -110,7 +110,7 @@ func (s *Suite) Test_MkParser_MkTokens(c
 
        checkRest("${VAR)", nil, "${VAR)") // Opening brace, closing parenthesis
        checkRest("$(VAR}", nil, "$(VAR}") // Opening parenthesis, closing brace
-       c.Check(s.Output(), equals, "WARN: Please use curly braces {} instead of round parentheses () for VAR.\n")
+       c.Check(s.Output(), equals, "")    // Warnings are only printed for balanced expressions.
 
        check("${PLIST_SUBST_VARS:@var@${var}=${${var}:Q}@}", varuse("PLIST_SUBST_VARS", "@var@${var}=${${var}:Q}@"))
        check("${PLIST_SUBST_VARS:@var@${var}=${${var}:Q}}", varuse("PLIST_SUBST_VARS", "@var@${var}=${${var}:Q}")) // Missing @ at the end
@@ -209,3 +209,24 @@ func (s *Suite) Test_MkParser_MkCond(c *
                NewTree("not", NewTree("empty", varuse("PKG_OPTIONS", "Msndfile"))),
                " || defined(PKG_OPTIONS:Msamplerate)")
 }
+
+func (s *Suite) Test_MkParser__varuse_parentheses_autofix(c *check.C) {
+       s.Init(c)
+       s.UseCommandLine("--autofix")
+       G.globalData.InitVartypes()
+       filename := s.CreateTmpFile("Makefile", "")
+       mklines := s.NewMkLines(filename,
+               mkrcsid,
+               "COMMENT=$(P1) $(P2)) $(P3:Q) ${BRACES}")
+
+       mklines.Check()
+
+       c.Check(s.Output(), equals, ""+
+               "AUTOFIX: ~/Makefile:2: Replacing \"$(P1)\" with \"${P1}\".\n"+
+               "AUTOFIX: ~/Makefile:2: Replacing \"$(P2)\" with \"${P2}\".\n"+
+               "AUTOFIX: ~/Makefile:2: Replacing \"$(P3:Q)\" with \"${P3:Q}\".\n"+
+               "AUTOFIX: ~/Makefile: Has been auto-fixed. Please re-run pkglint.\n")
+       c.Check(s.LoadTmpFile("Makefile"), equals, ""+
+               mkrcsid+"\n"+
+               "COMMENT=${P1} ${P2}) ${P3:Q} ${BRACES}\n")
+}



Home | Main Index | Thread Index | Old Index