Skip to content

Commit

Permalink
also match ?= and += where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
dmgk committed Apr 11, 2020
1 parent c444e1f commit 866af56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 10 additions & 10 deletions grep/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,60 +182,60 @@ var (
broken = &boolPattern{
flag: "b",
desc: "search only ports marked BROKEN",
pat: `\b(?P<q>BROKEN(_[^=]+)?)\s*=(?P<r>.*)(\n|\z)`,
pat: `\b(?P<q>BROKEN(_[^=]+)?)\s*\??=(?P<r>.*)(\n|\z)`,
}
depends = &stringPattern{
flag: "d",
desc: "search by *_DEPENDS",
pat: `\b(?P<q>(\w+_)?DEPENDS)\s*(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:>\.].*(\n|\z))`,
pat: `\b(?P<q>(\w+_)?DEPENDS)\s*(\+|\?)?(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:>\.].*(\n|\z))`,
val: "",
}
buildDepends = &stringPattern{
flag: "db",
desc: "search by BUILD_DEPENDS",
pat: `\b(?P<q>(\w+_)?BUILD_DEPENDS)\s*(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:>\.].*(\n|\z))`,
pat: `\b(?P<q>(\w+_)?BUILD_DEPENDS)\s*(\+|\?)?(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:>\.].*(\n|\z))`,
val: "",
}
libDepends = &stringPattern{
flag: "dl",
desc: "search by LIB_DEPENDS",
pat: `\b(?P<q>(\w+_)?LIB_DEPENDS)\s*(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:\.].*(\n|\z))`,
pat: `\b(?P<q>(\w+_)?LIB_DEPENDS)\s*(\+|\?)?(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:\.].*(\n|\z))`,
val: "",
}
runDepends = &stringPattern{
flag: "dr",
desc: "search by RUN_DEPENDS",
pat: `\b(?P<q>(\w+_)?RUN_DEPENDS)\s*(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:>\.].*(\n|\z))`,
pat: `\b(?P<q>(\w+_)?RUN_DEPENDS)\s*(\+|\?)?(=|=.*?[\s/}])(?P<r>%s)((\n|\z)|[\s@:>\.].*(\n|\z))`,
val: "",
}
onlyForArchs = &stringPattern{
flag: "oa",
desc: "search by ONLY_FOR_ARCHS",
pat: `\b(?P<q>ONLY_FOR_ARCHS)\s*(=|=.*?\s)(?P<r>%s)((\n|\z)|\s.*(\n|\z))`,
pat: `\b(?P<q>ONLY_FOR_ARCHS)\s*(\+|\?)?(=|=.*?\s)(?P<r>%s)((\n|\z)|\s.*(\n|\z))`,
val: "",
}
maintainer = &stringPattern{
flag: "m",
desc: "search by MAINTAINER",
pat: `(?i)\b(?P<q>MAINTAINER)\s*=\s*(?P<r>%s).*(\n|\z)`,
pat: `(?i)\b(?P<q>MAINTAINER)\s*\??=\s*(?P<r>%s).*(\n|\z)`,
val: "",
}
portname = &stringPattern{
flag: "n",
desc: "search by PORTNAME",
pat: `(?i)\b(?P<q>PORTNAME)\s*=\s*(?P<r>%s).*(\n|\z)`,
pat: `(?i)\b(?P<q>PORTNAME)\s*\??=\s*(?P<r>%s).*(\n|\z)`,
val: "",
}
uses = &stringPattern{
flag: "u",
desc: "search by USES",
pat: `\b(?P<q>([\w_]+_)?USES)\s*(=|=.*?\s)(?P<r>%s)((\n|\z)|[\s:,].*(\n|\z))`,
pat: `\b(?P<q>([\w_]+_)?USES)\s*(\+|\?)?(=|=.*?\s)(?P<r>%s)((\n|\z)|[\s:,].*(\n|\z))`,
val: "",
}
plist = &stringPattern{
flag: "pl",
desc: "search by PLIST_FILES",
pat: `\b(?P<q>([\w_]+_)?PLIST_FILES)\s*=.*?(?P<r>%s).*(\n|\z)`,
pat: `\b(?P<q>([\w_]+_)?PLIST_FILES)\s*(\+|\?)?=.*?(?P<r>%s).*(\n|\z)`,
val: "",
}
)
Expand Down
6 changes: 6 additions & 0 deletions grep/pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ func TestBroken(t *testing.T) {
func TestDepends(t *testing.T) {
matches := []string{
"BUILD_DEPENDS= dash:shells/dash bash:shells/bash",
"BUILD_DEPENDS?= dash:shells/dash bash:shells/bash",
"BUILD_DEPENDS+= dash:shells/dash bash:shells/bash",
"RUN_DEPENDS= bash>0:shells/bash dash:shells/dash",
"OPT_DEPENDS= /usr/local/bin/bash:shells/bash",
}
Expand Down Expand Up @@ -106,6 +108,8 @@ func TestBuildDepends(t *testing.T) {
func TestLibDepends(t *testing.T) {
matches := []string{
"LIB_DEPENDS= dash:shells/dash bash:shells/bash",
"LIB_DEPENDS?= dash:shells/dash bash:shells/bash",
"LIB_DEPENDS+= dash:shells/dash bash:shells/bash",
"OPT_LIB_DEPENDS= bash:shells/bash",
}

Expand All @@ -119,6 +123,8 @@ func TestLibDepends(t *testing.T) {
func TestRunDepends(t *testing.T) {
matches := []string{
"RUN_DEPENDS= dash:shells/dash bash:shells/bash",
"RUN_DEPENDS?= dash:shells/dash bash:shells/bash",
"RUN_DEPENDS+= dash:shells/dash bash:shells/bash",
"OPT_RUN_DEPENDS= bash:shells/bash",
}

Expand Down

0 comments on commit 866af56

Please sign in to comment.