Skip to content

Commit

Permalink
Fixed test failure. (Error wrapping needed to be considered in EOF ch…
Browse files Browse the repository at this point in the history
…ecks.)
  • Loading branch information
arran4 committed Sep 29, 2024
1 parent 667ee73 commit 6aea8dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ics
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"time"
Expand Down Expand Up @@ -419,8 +420,8 @@ func ParseCalendar(r io.Reader) (*Calendar, error) {
for ln := 0; cont; ln++ {
l, err := cs.ReadLine()
if err != nil {
switch err {
case io.EOF:
switch {
case errors.Is(err, io.EOF):
cont = false
default:
return c, err
Expand Down Expand Up @@ -528,7 +529,7 @@ func (cs *CalendarStream) ReadLine() (*ContentLine, error) {
}
p, err := cs.b.Peek(1)
r = append(r, b[:len(b)-o]...)
if err == io.EOF {
if errors.Is(err, io.EOF) {
c = false
}
if len(p) == 0 {
Expand All @@ -541,14 +542,15 @@ func (cs *CalendarStream) ReadLine() (*ContentLine, error) {
} else {
r = append(r, b...)
}
switch err {
case nil:
switch {
case err == nil:
if len(r) == 0 {
c = true
}
case io.EOF:
case errors.Is(err, io.EOF):
c = false
default:
// This must be as a result of boxing?
if err != nil {
err = fmt.Errorf("readline: %w", err)
}
Expand Down
5 changes: 3 additions & 2 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ics
import (
"bytes"
"encoding/base64"
"errors"
"fmt"
"io"
"regexp"
Expand Down Expand Up @@ -978,8 +979,8 @@ func ParseComponent(cs *CalendarStream, startLine *BaseProperty) (ComponentBase,
for ln := 0; cont; ln++ {
l, err := cs.ReadLine()
if err != nil {
switch err {
case io.EOF:
switch {
case errors.Is(err, io.EOF):
cont = false
default:
return cb, err
Expand Down

0 comments on commit 6aea8dc

Please sign in to comment.