diff options
author | rillig <rillig@pkgsrc.org> | 2016-12-17 13:35:32 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2016-12-17 13:35:32 +0000 |
commit | 2e9c0413c25e39ad6ba9730e02f9fb9cfbe86952 (patch) | |
tree | d9dd5186afd1ae2b7d689ea19b3cf6fc5d50a0ff /pkgtools | |
parent | 5e681b7d31262807e8b03b63b479deb81740e590 (diff) | |
download | pkgsrc-2e9c0413c25e39ad6ba9730e02f9fb9cfbe86952.tar.gz |
Updated pkglint to 5.4.14.
Changes since 5.4.13:
* Pkglint can fix $(VARIABLES) in parentheses to ${VARIABLES} in braces
automatically
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/pkglint/files/files.go | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkparser.go | 10 | ||||
-rw-r--r-- | pkgtools/pkglint/files/mkparser_test.go | 23 |
4 files changed, 32 insertions, 7 deletions
diff --git a/pkgtools/pkglint/Makefile b/pkgtools/pkglint/Makefile index b0301995c59..f664fa03325 100644 --- a/pkgtools/pkglint/Makefile +++ b/pkgtools/pkglint/Makefile @@ -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 diff --git a/pkgtools/pkglint/files/files.go b/pkgtools/pkglint/files/files.go index 2a635108c8e..5ec188017b3 100644 --- a/pkgtools/pkglint/files/files.go +++ b/pkgtools/pkglint/files/files.go @@ -33,7 +33,7 @@ func LoadExistingLines(fname string, foldBackslashLines bool) []*Line { 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 diff --git a/pkgtools/pkglint/files/mkparser.go b/pkgtools/pkglint/files/mkparser.go index 876845f357d..883dbc2aaac 100644 --- a/pkgtools/pkglint/files/mkparser.go +++ b/pkgtools/pkglint/files/mkparser.go @@ -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} } } diff --git a/pkgtools/pkglint/files/mkparser_test.go b/pkgtools/pkglint/files/mkparser_test.go index fd248fce426..aec93f9b599 100644 --- a/pkgtools/pkglint/files/mkparser_test.go +++ b/pkgtools/pkglint/files/mkparser_test.go @@ -110,7 +110,7 @@ func (s *Suite) Test_MkParser_MkTokens(c *check.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 *check.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") +} |