]> Repositorios git - scryer-prolog.git/commitdiff
add missing self.pos to peek_char slices (#1726)
authorMark <[email protected]>
Tue, 4 Jul 2023 23:44:27 +0000 (17:44 -0600)
committerMark <[email protected]>
Tue, 4 Jul 2023 23:44:27 +0000 (17:44 -0600)
src/parser/char_reader.rs

index 8a74db377c80e45eb03e2e6fbd7bf98afeec781e..9d6babf4603cf9992509f9676de5e1c7a21ed83e 100644 (file)
@@ -187,7 +187,7 @@ impl<R: Read> CharRead for CharReader<R> {
                     if self.pos >= self.buf.len() {
                         return None;
                     } else if self.buf.len() - self.pos >= 4 {
-                        return match str::from_utf8(&self.buf[..e.valid_up_to()]) {
+                        return match str::from_utf8(&self.buf[self.pos .. e.valid_up_to()]) {
                             Ok(s) => {
                                 let mut chars = s.chars();
                                 let c = chars.next().unwrap();
@@ -195,7 +195,7 @@ impl<R: Read> CharRead for CharReader<R> {
                                 Some(Ok(c))
                             }
                             Err(e) => {
-                                let badbytes = self.buf[..e.valid_up_to()].to_vec();
+                                let badbytes = self.buf[self.pos .. e.valid_up_to()].to_vec();
 
                                 Some(Err(io::Error::new(io::ErrorKind::InvalidData,
                                                         BadUtf8Error { bytes: badbytes })))