Substitute matches in prereqs in regex meta-rules.

This commit is contained in:
Daniel Jones 2014-02-01 19:03:11 -08:00
parent b9a5986fc7
commit 75d67f9fdb
2 changed files with 6 additions and 4 deletions

View file

@ -258,8 +258,6 @@ func expandSuffixes(input string, stem string) string {
return string(expanded) return string(expanded)
} }
// TODO: expand RegexpRefs
// Expand a backtick quoted string, by executing the contents. // Expand a backtick quoted string, by executing the contents.
func expandBackQuoted(input string, vars map[string][]string) ([]string, int) { func expandBackQuoted(input string, vars map[string][]string) ([]string, int) {
// TODO: expand sigils? // TODO: expand sigils?

View file

@ -191,9 +191,14 @@ func applyrules(rs *ruleSet, g *graph, target string, rulecnt []int) *node {
var stem string var stem string
var matches []string var matches []string
var match_vars = make(map[string][]string)
if r.attributes.regex { if r.attributes.regex {
matches = mat matches = mat
for i := range matches {
key := fmt.Sprintf("stem%d", i)
match_vars[key] = matches[i : i+1]
}
} else { } else {
stem = mat[1] stem = mat[1]
} }
@ -207,8 +212,7 @@ func applyrules(rs *ruleSet, g *graph, target string, rulecnt []int) *node {
for i := range r.prereqs { for i := range r.prereqs {
var prereq string var prereq string
if r.attributes.regex { if r.attributes.regex {
// TODO: write substituteRegexpRefs and use that here prereq = expandRecipeSigils(r.prereqs[i], match_vars)
prereq = r.prereqs[i]
} else { } else {
prereq = expandSuffixes(r.prereqs[i], stem) prereq = expandSuffixes(r.prereqs[i], stem)
} }