Variable expansion bug.
This commit is contained in:
parent
8cbbe9c53c
commit
587bdd6c63
8 changed files with 99 additions and 79 deletions
|
|
@ -52,6 +52,9 @@ improvements.
|
|||
|
||||
1. A clean, modern implementation in Go, that doesn't depend on the whole Plan
|
||||
9 stack.
|
||||
1. Parallel by default. Modern computers can build more than one C file at a
|
||||
time. Cases that should not be run in parallel are the exception. Use
|
||||
`-p=1` if this is the case.
|
||||
1. Use Go regular expressions, which are perl-like. The original mk used plan9
|
||||
regex, which few people know or care to learn.
|
||||
1. Allow blank lines in recipes. A recipe is any indented block of text, and
|
||||
|
|
@ -60,8 +63,6 @@ improvements.
|
|||
1. Add an 'S' attribute to execute recipes with programs other than sh. This
|
||||
way, you don't have to separate your six line python script into its own
|
||||
file. Just stick it directly in the mkfile.
|
||||
1. Use sh syntax for command insertion (i.e. backticks) rather than rc shell
|
||||
syntax.
|
||||
1. Pretty colors.
|
||||
|
||||
# Current State
|
||||
|
|
|
|||
20
TODO.md
Normal file
20
TODO.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
# Short-term
|
||||
* Unit tests.
|
||||
* Expanding regex matches in targets.
|
||||
* Dummy rule for multiple explicit targets
|
||||
* Expand `$newprereq`.
|
||||
* Expand `$alltargets`.
|
||||
* Man page.
|
||||
* Namelist syntax.
|
||||
* Environment variables.
|
||||
|
||||
# Long-term
|
||||
* Nicer syntax for alternative-shell rules.
|
||||
* An attribute to demand n processors for a particular rule. This way
|
||||
resource hog rules can be run on their own without disabling parallel
|
||||
make.
|
||||
* A switch that prints the rules that will be executed and prompts to user
|
||||
to do so. I often find myself doing `mk -n` before `mk` to make sure my
|
||||
rules aren't bogus.
|
||||
|
||||
|
|
@ -13,12 +13,13 @@ func expand(input string, vars map[string][]string, expandBackticks bool) []stri
|
|||
expanded := ""
|
||||
var i, j int
|
||||
for i = 0; i < len(input); {
|
||||
j = i + strings.IndexAny(input[i:], "\"'`$\\")
|
||||
j = strings.IndexAny(input[i:], "\"'`$\\")
|
||||
|
||||
if j < 0 {
|
||||
expanded += input[i:]
|
||||
break
|
||||
}
|
||||
j += i
|
||||
|
||||
expanded += input[i:j]
|
||||
c, w := utf8.DecodeRuneInString(input[j:])
|
||||
|
|
|
|||
3
graph.go
3
graph.go
|
|
@ -56,7 +56,6 @@ type node struct {
|
|||
flags nodeFlag // bitwise combination of node flags
|
||||
}
|
||||
|
||||
|
||||
// Update a node's timestamp and 'exists' flag.
|
||||
func (u *node) updateTimestamp() {
|
||||
info, err := os.Stat(u.name)
|
||||
|
|
@ -283,7 +282,7 @@ func (g *graph) vacuous(u *node) bool {
|
|||
|
||||
// Check for cycles
|
||||
func (g *graph) cyclecheck(u *node) {
|
||||
if u.flags & nodeFlagCycle != 0 && len(u.prereqs) > 0 {
|
||||
if u.flags&nodeFlagCycle != 0 && len(u.prereqs) > 0 {
|
||||
mkError(fmt.Sprintf("cycle in the graph detected at target %s", u.name))
|
||||
}
|
||||
u.flags |= nodeFlagCycle
|
||||
|
|
|
|||
3
lex.go
3
lex.go
|
|
@ -1,10 +1,9 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type tokenType int
|
||||
|
|
|
|||
4
parse.go
4
parse.go
|
|
@ -5,10 +5,10 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type parser struct {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ func subprocess(program string,
|
|||
var outbytes []byte
|
||||
outbytes, err = cmd.Output()
|
||||
output = string(outbytes)
|
||||
if output[len(output)-1] == '\n' {
|
||||
if len(output) > 0 && output[len(output)-1] == '\n' {
|
||||
output = output[:len(output)-1]
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue