Merge pull request #8580 from erikh/filter_comments_first

builder: strip blank lines before processing any line continuations.
Upstream-commit: de5b1b8bb01cfd9352b4e3127c4a19db22e85d46
Component: engine
This commit is contained in:
Alexandr Morozov
2014-10-15 11:00:31 -07:00
5 changed files with 22 additions and 2 deletions

View File

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

View File

@ -26,3 +26,10 @@ frog
RUN echo good\
bye\
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 goodbyefrog")
(run "echo goodbyefrog")
(run "echo hello this is some more useful stuff")

View File

@ -5,4 +5,10 @@ RUN apt-get \update && \
apt-get \"install znc -y
ADD \conf\\" /.znc
RUN foo \
bar \
baz
CMD [ "\/usr\\\"/bin/znc", "-f", "-r" ]

View File

@ -2,4 +2,5 @@
(maintainer "Erik \\\\Hollensbe <erik@hollensbe.org>\\\"")
(run "apt-get \\update && apt-get \\\"install znc -y")
(add "\\conf\\\\\"" "/.znc")
(run "foo bar baz")
(cmd "/usr\\\"/bin/znc" "-f" "-r")