@@ -112,10 +112,14 @@ func (d *DirectiveParser) ParseAll(data []byte) ([]*Directive, error) {
112112// This allows for a flexible range of input formats, and appropriate syntax
113113// selection.
114114func DetectSyntax (dt []byte ) (string , string , []Range , bool ) {
115- return ParseDirective (keySyntax , dt )
115+ return parseDirective (keySyntax , dt , true )
116116}
117117
118118func ParseDirective (key string , dt []byte ) (string , string , []Range , bool ) {
119+ return parseDirective (key , dt , false )
120+ }
121+
122+ func parseDirective (key string , dt []byte , anyFormat bool ) (string , string , []Range , bool ) {
119123 dt = discardBOM (dt )
120124 dt , hadShebang , err := discardShebang (dt )
121125 if err != nil {
@@ -132,6 +136,10 @@ func ParseDirective(key string, dt []byte) (string, string, []Range, bool) {
132136 return syntax , cmdline , loc , true
133137 }
134138
139+ if ! anyFormat {
140+ return "" , "" , nil , false
141+ }
142+
135143 // use directive with different comment prefix, and search for //key=
136144 directiveParser = DirectiveParser {line : line }
137145 directiveParser .setComment ("//" )
0 commit comments