summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-ini/ini/parser.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-ini/ini/parser.go')
-rw-r--r--vendor/github.com/go-ini/ini/parser.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/vendor/github.com/go-ini/ini/parser.go b/vendor/github.com/go-ini/ini/parser.go
index 826e893c0..d5aa2db60 100644
--- a/vendor/github.com/go-ini/ini/parser.go
+++ b/vendor/github.com/go-ini/ini/parser.go
@@ -198,7 +198,7 @@ func hasSurroundedQuote(in string, quote byte) bool {
func (p *parser) readValue(in []byte,
parserBufferSize int,
- ignoreContinuation, ignoreInlineComment, unescapeValueDoubleQuotes, unescapeValueCommentSymbols, allowPythonMultilines bool) (string, error) {
+ ignoreContinuation, ignoreInlineComment, unescapeValueDoubleQuotes, unescapeValueCommentSymbols, allowPythonMultilines, spaceBeforeInlineComment bool) (string, error) {
line := strings.TrimLeftFunc(string(in), unicode.IsSpace)
if len(line) == 0 {
@@ -240,11 +240,22 @@ func (p *parser) readValue(in []byte,
// Check if ignore inline comment
if !ignoreInlineComment {
- i := strings.IndexAny(line, "#;")
+ var i int
+ if spaceBeforeInlineComment {
+ i = strings.Index(line, " #")
+ if i == -1 {
+ i = strings.Index(line, " ;")
+ }
+
+ } else {
+ i = strings.IndexAny(line, "#;")
+ }
+
if i > -1 {
p.comment.WriteString(line[i:])
line = strings.TrimSpace(line[:i])
}
+
}
// Trim single and double quotes
@@ -429,7 +440,8 @@ func (f *File) parse(reader io.Reader) (err error) {
f.options.IgnoreInlineComment,
f.options.UnescapeValueDoubleQuotes,
f.options.UnescapeValueCommentSymbols,
- f.options.AllowPythonMultilineValues)
+ f.options.AllowPythonMultilineValues,
+ f.options.SpaceBeforeInlineComment)
if err != nil {
return err
}
@@ -458,7 +470,8 @@ func (f *File) parse(reader io.Reader) (err error) {
f.options.IgnoreInlineComment,
f.options.UnescapeValueDoubleQuotes,
f.options.UnescapeValueCommentSymbols,
- f.options.AllowPythonMultilineValues)
+ f.options.AllowPythonMultilineValues,
+ f.options.SpaceBeforeInlineComment)
if err != nil {
return err
}