@@ 311,11 311,11 @@ func (d *decoder) readKey() (nextfunc, error) {
}
err := d.readUntil(runeFunc(isKeyEnd), true, casefn)
- if err != nil && err != io.EOF {
+ if err != nil && !errors.Is(err, io.EOF) {
return nil, err
}
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
d.add(d.buffer.String(), d.true)
return nil, nil
}
@@ 327,7 327,7 @@ func (d *decoder) readKey() (nextfunc, error) {
}
func (d *decoder) readValueSep() (next nextfunc, err error) {
- if err = must(d.skipSpace(false), io.EOF, nil); err == io.EOF {
+ if err = must(d.skipSpace(false), io.EOF, nil); errors.Is(err, io.EOF) {
d.add(d.key, d.true)
return nil, nil
}
@@ 339,7 339,7 @@ func (d *decoder) readValueSep() (next nextfunc, err error) {
d.add(d.key, d.true)
return d.readElem, d.skip()
case rEquals:
- if err = d.skip(); err == io.EOF {
+ if err = d.skip(); errors.Is(err, io.EOF) {
d.add(d.key, "")
return nil, nil
}
@@ 356,7 356,7 @@ func (d *decoder) readHexCode(size int) (result rune, err error) {
for i := 0; i < size; i++ {
r, sz, err := d.nextRune()
if err != nil {
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
err = io.ErrUnexpectedEOF
}
return -1, d.syntaxerr(err, "expected hex code")
@@ 381,7 381,7 @@ func (d *decoder) readHexCode(size int) (result rune, err error) {
func (d *decoder) readStringValue() (next nextfunc, err error) {
err = d.readUntil(runestr(`"\`), true, nil)
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, d.syntaxerr(UnclosedError('"'), "encountered EOF inside string")
} else if err != nil {
return nil, err
@@ 420,7 420,7 @@ func (d *decoder) readStringValue() (next nextfunc, err error) {
func (d *decoder) readRawValue() (next nextfunc, err error) {
err = d.readUntil(oneRune(rRawQuote), true, nil)
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, d.syntaxerr(UnclosedError('`'), "encountered EOF inside raw string")
} else if err != nil {
return nil, err
@@ 437,7 437,7 @@ func (d *decoder) readRawValue() (next nextfunc, err error) {
}
func (d *decoder) readValue() (next nextfunc, err error) {
- if err = must(d.skipSpace(false), io.EOF); err == io.EOF {
+ if err = must(d.skipSpace(false), io.EOF); errors.Is(err, io.EOF) {
d.add(d.key, "")
return nil, nil
}
@@ 468,7 468,7 @@ func (d *decoder) readValue() (next nextfunc, err error) {
}
func (d *decoder) readQuotedSubsection() (next nextfunc, err error) {
- if must(d.readUntil(runestr(`"\`), true, nil), io.EOF) == io.EOF {
+ if err = must(d.readUntil(runestr(`"\`), true, nil), io.EOF); errors.Is(err, io.EOF) {
return nil, d.syntaxerr(UnclosedError('"'), "encountered EOF inside quoted section name")
}
@@ 558,7 558,7 @@ func (d *decoder) readSubsection() (next nextfunc, err error) {
func (d *decoder) start() (next nextfunc, err error) {
_, _, err = d.nextRune()
- if err == io.EOF {
+ if errors.Is(err, io.EOF) {
return nil, nil
}
return d.readElem, err
@@ 567,7 567,7 @@ func (d *decoder) start() (next nextfunc, err error) {
func (d *decoder) readElem() (next nextfunc, err error) {
d.buffer.Reset()
- if d.err == io.EOF {
+ if errors.Is(d.err, io.EOF) {
return nil, nil
} else if d.err != nil {
return nil, err
@@ 579,7 579,7 @@ func (d *decoder) readElem() (next nextfunc, err error) {
case rHash, rSemicolon:
return d.readComment()
case ' ', '\t', '\n', '\f', '\r', 0x85, 0xA0:
- if err = d.skipSpace(true); err == io.EOF {
+ if err = d.skipSpace(true); errors.Is(err, io.EOF) {
return nil, nil
}
return d.readElem, err
@@ 733,7 733,7 @@ func panictoerr(err *error) {
*err = fmt.Errorf("ini: panic: %v", rc)
}
- if *err == io.EOF {
+ if err != nil && errors.Is(*err, io.EOF) {
*err = io.ErrUnexpectedEOF
}
}
@@ 753,7 753,7 @@ func must(err error, allowed ...error) error {
}
func stopOnEOF(next *nextfunc, err *error) {
- if *err == io.EOF {
+ if err != nil && errors.Is(*err, io.EOF) {
*next = nil
*err = nil
}