1
0
Fork 0

Adding upstream version 2.6.3.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-18 22:58:26 +02:00
parent 4d8cd0ce4c
commit 2b08a89310
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
39 changed files with 2140 additions and 0 deletions

43
simple_parser.go Normal file
View file

@ -0,0 +1,43 @@
package editorconfig
import (
"fmt"
"os"
"gopkg.in/ini.v1"
)
// SimpleParser implements the Parser interface but without doing any caching.
type SimpleParser struct{}
// ParseInit calls go-ini's Load on the file.
func (parser *SimpleParser) ParseIni(filename string) (*Editorconfig, error) {
ec, warning, err := parser.ParseIniGraceful(filename)
if err != nil {
return nil, err
}
return ec, warning
}
// ParseIni calls go-ini's Load on the file and keep warnings in a separate error.
func (parser *SimpleParser) ParseIniGraceful(filename string) (*Editorconfig, error, error) {
fp, err := os.Open(filename)
if err != nil {
return nil, nil, err //nolint:wrapcheck
}
defer fp.Close()
iniFile, err := ini.Load(fp)
if err != nil {
return nil, nil, fmt.Errorf("cannot load %q: %w", filename, err)
}
return newEditorconfig(iniFile)
}
// FnmatchCase calls the module's FnmatchCase.
func (parser *SimpleParser) FnmatchCase(selector string, filename string) (bool, error) {
return FnmatchCase(selector, filename)
}