Read a single byte. If there is no byte to read, return ok==false and leave the error in d.err. Maintain line number.
()
| 898 | // and leave the error in d.err. |
| 899 | // Maintain line number. |
| 900 | func (d *Decoder) getc() (b byte, ok bool) { |
| 901 | if d.err != nil { |
| 902 | return 0, false |
| 903 | } |
| 904 | if d.nextByte >= 0 { |
| 905 | b = byte(d.nextByte) |
| 906 | d.nextByte = -1 |
| 907 | } else { |
| 908 | b, d.err = d.r.ReadByte() |
| 909 | if d.err != nil { |
| 910 | return 0, false |
| 911 | } |
| 912 | if d.saved != nil { |
| 913 | d.saved.WriteByte(b) |
| 914 | } |
| 915 | } |
| 916 | if b == '\n' { |
| 917 | d.line++ |
| 918 | d.linestart = d.offset + 1 |
| 919 | } |
| 920 | d.offset++ |
| 921 | return b, true |
| 922 | } |
| 923 | |
| 924 | // InputOffset returns the input stream byte offset of the current decoder position. |
| 925 | // The offset gives the location of the end of the most recently returned token |