@@ -196,7 +196,14 @@ pub fn from_file(sc: &mut ScannerPool, filename: &'static str) -> Result<(), Box
196196 sc. launch_scanner ( Some ( & filename) , & byte_counter, & chunk) ;
197197 byte_counter += WIN_STEP ;
198198 }
199- // The last is usually shorter
199+ // The last is shorter than WIN_LEN bytes, but can be longer than WIN_STEP
200+ if byte_counter < len {
201+ let chunk = & mmap[ byte_counter..len] ;
202+ sc. launch_scanner ( Some ( & filename) , & byte_counter, & chunk) ;
203+ byte_counter += WIN_STEP ;
204+ }
205+
206+ // Now there can be still some bytes left (maximum WIN_OVERLAP bytes)
200207 if byte_counter < len {
201208 let chunk = & mmap[ byte_counter..len] ;
202209 sc. launch_scanner ( Some ( & filename) , & byte_counter, & chunk) ;
@@ -242,7 +249,14 @@ fn from_stdin(sc: &mut ScannerPool) -> Result<(), Box<std::io::Error>> {
242249 byte_counter += WIN_STEP ;
243250 }
244251 }
245- // The last is usually shorter
252+ // The last is shorter than WIN_LEN bytes, but can be longer than WIN_STEP
253+ if data_start < data_end {
254+ sc. launch_scanner ( None , & byte_counter, & buf[ data_start..data_end] ) ;
255+ data_start += WIN_STEP ;
256+ byte_counter += WIN_STEP ;
257+ }
258+
259+ // Now there can be still some bytes left (maximum WIN_OVERLAP bytes)
246260 if data_start < data_end {
247261 sc. launch_scanner ( None , & byte_counter, & buf[ data_start..data_end] ) ;
248262 }
0 commit comments