builder: comments should also be elided in the middle of statements following a line continuation.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
Erik Hollensbe 2014-10-15 08:44:14 +00:00
parent a1ef2207dd
commit 96f342f703
3 changed files with 12 additions and 3 deletions

View File

@ -98,11 +98,12 @@ func Parse(rwc io.Reader) (*Node, error) {
scanner := bufio.NewScanner(rwc) scanner := bufio.NewScanner(rwc)
for scanner.Scan() { for scanner.Scan() {
if scanner.Text() == "" { scannedLine := strings.TrimLeftFunc(scanner.Text(), unicode.IsSpace)
if stripComments(scannedLine) == "" {
continue continue
} }
line, child, err := parseLine(strings.TrimLeftFunc(scanner.Text(), unicode.IsSpace)) line, child, err := parseLine(scannedLine)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -111,7 +112,7 @@ func Parse(rwc io.Reader) (*Node, error) {
for scanner.Scan() { for scanner.Scan() {
newline := scanner.Text() newline := scanner.Text()
if newline == "" { if stripComments(strings.TrimSpace(newline)) == "" {
continue continue
} }

View File

@ -26,3 +26,10 @@ frog
RUN echo good\ RUN echo good\
bye\ bye\
frog frog
RUN echo hello \
# this is a comment
# this is a comment with a blank line surrounding it
this is some more useful stuff

View File

@ -7,3 +7,4 @@
(run "echo hi world goodnight") (run "echo hi world goodnight")
(run "echo goodbyefrog") (run "echo goodbyefrog")
(run "echo goodbyefrog") (run "echo goodbyefrog")
(run "echo hello this is some more useful stuff")