From a041d523de389b65b98a5373a8034041db2a8d83 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 2 Apr 2026 06:23:30 +0000 Subject: *: Remove --- config/parser.go | 88 -------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 config/parser.go (limited to 'config/parser.go') diff --git a/config/parser.go b/config/parser.go deleted file mode 100644 index c56a68d5..00000000 --- a/config/parser.go +++ /dev/null @@ -1,88 +0,0 @@ -package config - -import ( - "bufio" - "errors" - "fmt" - "io" -) - -// ParseConfig reads and parses Git configuration entries from r. -func ParseConfig(r io.Reader) (*Config, error) { - parser := &configParser{ - reader: bufio.NewReader(r), - lineNum: 1, - } - - return parser.parse() -} - -type configParser struct { - reader *bufio.Reader - lineNum int - currentSection string - currentSubsec string - peeked byte - hasPeeked bool -} - -func (p *configParser) parse() (*Config, error) { - cfg := &Config{} - - err := p.skipBOM() - if err != nil { - return nil, err - } - - for { - ch, err := p.nextChar() - if errors.Is(err, io.EOF) { - break - } - - if err != nil { - return nil, err - } - - // Skip leading whitespace between entries. - if isWhitespace(ch) { - continue - } - - // Comments - if ch == '#' || ch == ';' { - err := p.skipToEOL() - if err != nil && !errors.Is(err, io.EOF) { - return nil, err - } - - continue - } - - // Section header - if ch == '[' { - err := p.parseSection() - if err != nil { - return nil, fmt.Errorf("furgit: config: line %d: %w", p.lineNum, err) - } - - continue - } - - // Key-value pair - if isLetter(ch) { - p.unreadChar(ch) - - err := p.parseKeyValue(cfg) - if err != nil { - return nil, fmt.Errorf("furgit: config: line %d: %w", p.lineNum, err) - } - - continue - } - - return nil, fmt.Errorf("furgit: config: line %d: unexpected character %q", p.lineNum, ch) - } - - return cfg, nil -} -- cgit v1.3.1-10-gc9f91