File tree Expand file tree Collapse file tree 2 files changed +22
-13
lines changed
Expand file tree Collapse file tree 2 files changed +22
-13
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,11 @@ fn test_writer_indent() {
255255
256256 let result = writer. into_inner ( ) . into_inner ( ) ;
257257 // println!("{:?}", String::from_utf8_lossy(&result));
258+
259+ #[ cfg( windows) ]
260+ assert ! ( result. into_iter( ) . eq( txt. bytes( ) . filter( |b| * b != 13 ) ) ) ;
261+
262+ #[ cfg( not( windows) ) ]
258263 assert_eq ! ( result, txt. as_bytes( ) ) ;
259264}
260265
@@ -274,6 +279,11 @@ fn test_writer_indent_cdata() {
274279 }
275280
276281 let result = writer. into_inner ( ) . into_inner ( ) ;
282+
283+ #[ cfg( windows) ]
284+ assert ! ( result. into_iter( ) . eq( txt. bytes( ) . filter( |b| * b != 13 ) ) ) ;
285+
286+ #[ cfg( not( windows) ) ]
277287 assert_eq ! ( result, txt. as_bytes( ) ) ;
278288}
279289
Original file line number Diff line number Diff line change @@ -421,24 +421,23 @@ impl<'a> Iterator for SpecIter<'a> {
421421 let start = self
422422 . 0
423423 . iter ( )
424- . position ( |b| match * b {
425- b' ' | b'\r' | b'\n' | b'\t' | b'|' | b':' => false ,
426- b'0' ..=b'9' => false ,
427- _ => true ,
428- } )
424+ . position ( |b| !matches ! ( * b, b' ' | b'\r' | b'\n' | b'\t' | b'|' | b':' | b'0' ..=b'9' ) )
429425 . unwrap_or ( 0 ) ;
430- if let Some ( p) = self . 0 . windows ( 2 ) . position ( |w| w == b")\n " ) {
426+
427+ if let Some ( p) = self . 0 . windows ( 3 ) . position ( |w| w == b")\r \n " ) {
428+ let ( prev, next) = self . 0 . split_at ( p + 1 ) ;
429+ self . 0 = & next[ 1 ..] ;
430+ Some ( from_utf8 ( & prev[ start..] ) . expect ( "Error decoding to uft8" ) )
431+ } else if let Some ( p) = self . 0 . windows ( 2 ) . position ( |w| w == b")\n " ) {
431432 let ( prev, next) = self . 0 . split_at ( p + 1 ) ;
432433 self . 0 = next;
433434 Some ( from_utf8 ( & prev[ start..] ) . expect ( "Error decoding to uft8" ) )
435+ } else if self . 0 . is_empty ( ) {
436+ None
434437 } else {
435- if self . 0 . is_empty ( ) {
436- None
437- } else {
438- let p = self . 0 ;
439- self . 0 = & [ ] ;
440- Some ( from_utf8 ( & p[ start..] ) . unwrap ( ) )
441- }
438+ let p = self . 0 ;
439+ self . 0 = & [ ] ;
440+ Some ( from_utf8 ( & p[ start..] ) . unwrap ( ) )
442441 }
443442 }
444443}
You can’t perform that action at this time.
0 commit comments