Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
| ... | ... |
@@ -20,7 +20,7 @@ var ( |
| 20 | 20 |
// ignore the current argument. This will still leave a command parsed, but |
| 21 | 21 |
// will not incorporate the arguments into the ast. |
| 22 | 22 |
func parseIgnore(rest string) (*Node, error) {
|
| 23 |
- return blankNode(), nil |
|
| 23 |
+ return &Node{}, nil
|
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
// used for onbuild. Could potentially be used for anything that represents a |
| ... | ... |
@@ -40,11 +40,11 @@ func parseSubCommand(rest string) (*Node, error) {
|
| 40 | 40 |
// parse environment like statements. Note that this does *not* handle |
| 41 | 41 |
// variable interpolation, which will be handled in the evaluator. |
| 42 | 42 |
func parseEnv(rest string) (*Node, error) {
|
| 43 |
- node := blankNode() |
|
| 43 |
+ node := &Node{}
|
|
| 44 | 44 |
rootnode := node |
| 45 | 45 |
strs := TOKEN_WHITESPACE.Split(rest, 2) |
| 46 | 46 |
node.Value = strs[0] |
| 47 |
- node.Next = blankNode() |
|
| 47 |
+ node.Next = &Node{}
|
|
| 48 | 48 |
node.Next.Value = strs[1] |
| 49 | 49 |
|
| 50 | 50 |
return rootnode, nil |
| ... | ... |
@@ -53,13 +53,13 @@ func parseEnv(rest string) (*Node, error) {
|
| 53 | 53 |
// parses a whitespace-delimited set of arguments. The result is effectively a |
| 54 | 54 |
// linked list of string arguments. |
| 55 | 55 |
func parseStringsWhitespaceDelimited(rest string) (*Node, error) {
|
| 56 |
- node := blankNode() |
|
| 56 |
+ node := &Node{}
|
|
| 57 | 57 |
rootnode := node |
| 58 | 58 |
prevnode := node |
| 59 | 59 |
for _, str := range TOKEN_WHITESPACE.Split(rest, -1) { // use regexp
|
| 60 | 60 |
prevnode = node |
| 61 | 61 |
node.Value = str |
| 62 |
- node.Next = blankNode() |
|
| 62 |
+ node.Next = &Node{}
|
|
| 63 | 63 |
node = node.Next |
| 64 | 64 |
} |
| 65 | 65 |
|
| ... | ... |
@@ -80,7 +80,7 @@ func parseString(rest string) (*Node, error) {
|
| 80 | 80 |
func parseJSON(rest string) (*Node, error) {
|
| 81 | 81 |
var ( |
| 82 | 82 |
myJson []interface{}
|
| 83 |
- next = blankNode() |
|
| 83 |
+ next = &Node{}
|
|
| 84 | 84 |
orignext = next |
| 85 | 85 |
prevnode = next |
| 86 | 86 |
) |
| ... | ... |
@@ -98,7 +98,7 @@ func parseJSON(rest string) (*Node, error) {
|
| 98 | 98 |
return nil, dockerFileErrJSONNesting |
| 99 | 99 |
} |
| 100 | 100 |
next.Value = str.(string) |
| 101 |
- next.Next = blankNode() |
|
| 101 |
+ next.Next = &Node{}
|
|
| 102 | 102 |
prevnode = next |
| 103 | 103 |
next = next.Next |
| 104 | 104 |
} |
| ... | ... |
@@ -124,7 +124,7 @@ func parseMaybeJSON(rest string) (*Node, error) {
|
| 124 | 124 |
} |
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 |
- node := blankNode() |
|
| 127 |
+ node := &Node{}
|
|
| 128 | 128 |
node.Value = rest |
| 129 | 129 |
return node, nil |
| 130 | 130 |
} |
| ... | ... |
@@ -59,11 +59,6 @@ func init() {
|
| 59 | 59 |
} |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 |
-// empty node. Useful for managing structure. |
|
| 63 |
-func blankNode() *Node {
|
|
| 64 |
- return &Node{"", nil, []*Node{}}
|
|
| 65 |
-} |
|
| 66 |
- |
|
| 67 | 62 |
// parse a line and return the remainder. |
| 68 | 63 |
func parseLine(line string) (string, *Node, error) {
|
| 69 | 64 |
if line = stripComments(line); line == "" {
|
| ... | ... |
@@ -77,7 +72,7 @@ func parseLine(line string) (string, *Node, error) {
|
| 77 | 77 |
|
| 78 | 78 |
cmd, args := splitCommand(line) |
| 79 | 79 |
|
| 80 |
- node := blankNode() |
|
| 80 |
+ node := &Node{}
|
|
| 81 | 81 |
node.Value = cmd |
| 82 | 82 |
|
| 83 | 83 |
sexp, err := fullDispatch(cmd, args) |
| ... | ... |
@@ -96,7 +91,7 @@ func Parse(rwc io.Reader) (*Node, error) {
|
| 96 | 96 |
var child *Node |
| 97 | 97 |
var line string |
| 98 | 98 |
var err error |
| 99 |
- root := blankNode() |
|
| 99 |
+ root := &Node{}
|
|
| 100 | 100 |
scanner := bufio.NewScanner(rwc) |
| 101 | 101 |
|
| 102 | 102 |
for scanner.Scan() {
|