Merge pull request #245 from octo/cartridge-return

scanner: Improve regular expression in "scanner".scanHeredoc().
This commit is contained in:
Mitchell Hashimoto 2018-04-03 10:00:26 -07:00 committed by GitHub
commit c247bd0851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 2 deletions

View File

@ -153,6 +153,8 @@ func TestFormatValidOutput(t *testing.T) {
cases := []string{
"#\x00",
"#\ue123t",
"Y=<<4\n4/\n\n\n/4/@=4/\n\n\n/4000000004\r\r\n00004\n",
"x=<<_\n_\r\r\n_\n",
}
for _, c := range cases {

View File

@ -1,6 +1,7 @@
obj {
foo = [<<EOF
TEXT!
!!EOF
EOF
]
}

View File

@ -1,6 +1,7 @@
obj {
foo = [<<EOF
TEXT!
!!EOF
EOF
]
}

View File

@ -440,9 +440,9 @@ func (s *Scanner) scanHeredoc() {
var identRegexp *regexp.Regexp
if identBytes[0] == '-' {
identRegexp = regexp.MustCompile(fmt.Sprintf(`[[:space:]]*%s\z`, identBytes[1:]))
identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\r*\z`, identBytes[1:]))
} else {
identRegexp = regexp.MustCompile(fmt.Sprintf(`[[:space:]]*%s\z`, identBytes))
identRegexp = regexp.MustCompile(fmt.Sprintf(`^[[:space:]]*%s\r*\z`, identBytes))
}
// Read the actual string value