builder: Remove blankNode(), use &Node{} instead.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
Erik Hollensbe 2014-08-10 04:01:10 -07:00
parent 21b15ac920
commit 135f54ccbf
2 changed files with 10 additions and 15 deletions

View File

@ -20,7 +20,7 @@ var (
// ignore the current argument. This will still leave a command parsed, but
// will not incorporate the arguments into the ast.
func parseIgnore(rest string) (*Node, error) {
return blankNode(), nil
return &Node{}, nil
}
// used for onbuild. Could potentially be used for anything that represents a
@ -40,11 +40,11 @@ func parseSubCommand(rest string) (*Node, error) {
// parse environment like statements. Note that this does *not* handle
// variable interpolation, which will be handled in the evaluator.
func parseEnv(rest string) (*Node, error) {
node := blankNode()
node := &Node{}
rootnode := node
strs := TOKEN_WHITESPACE.Split(rest, 2)
node.Value = strs[0]
node.Next = blankNode()
node.Next = &Node{}
node.Next.Value = strs[1]
return rootnode, nil
@ -53,13 +53,13 @@ func parseEnv(rest string) (*Node, error) {
// parses a whitespace-delimited set of arguments. The result is effectively a
// linked list of string arguments.
func parseStringsWhitespaceDelimited(rest string) (*Node, error) {
node := blankNode()
node := &Node{}
rootnode := node
prevnode := node
for _, str := range TOKEN_WHITESPACE.Split(rest, -1) { // use regexp
prevnode = node
node.Value = str
node.Next = blankNode()
node.Next = &Node{}
node = node.Next
}
@ -80,7 +80,7 @@ func parseString(rest string) (*Node, error) {
func parseJSON(rest string) (*Node, error) {
var (
myJson []interface{}
next = blankNode()
next = &Node{}
orignext = next
prevnode = next
)
@ -98,7 +98,7 @@ func parseJSON(rest string) (*Node, error) {
return nil, dockerFileErrJSONNesting
}
next.Value = str.(string)
next.Next = blankNode()
next.Next = &Node{}
prevnode = next
next = next.Next
}
@ -124,7 +124,7 @@ func parseMaybeJSON(rest string) (*Node, error) {
}
}
node := blankNode()
node := &Node{}
node.Value = rest
return node, nil
}

View File

@ -59,11 +59,6 @@ func init() {
}
}
// empty node. Useful for managing structure.
func blankNode() *Node {
return &Node{"", nil, []*Node{}}
}
// parse a line and return the remainder.
func parseLine(line string) (string, *Node, error) {
if line = stripComments(line); line == "" {
@ -77,7 +72,7 @@ func parseLine(line string) (string, *Node, error) {
cmd, args := splitCommand(line)
node := blankNode()
node := &Node{}
node.Value = cmd
sexp, err := fullDispatch(cmd, args)
@ -96,7 +91,7 @@ func Parse(rwc io.Reader) (*Node, error) {
var child *Node
var line string
var err error
root := blankNode()
root := &Node{}
scanner := bufio.NewScanner(rwc)
for scanner.Scan() {