@@ -16,7 +16,7 @@ use std::str::from_utf8;
1616use unicode_width:: UnicodeWidthChar ;
1717use uucore:: display:: Quotable ;
1818use uucore:: error:: { FromIo , UError , UResult , USimpleError } ;
19- use uucore:: { crash_if_err , format_usage, help_about, help_usage, show} ;
19+ use uucore:: { format_usage, help_about, help_usage, show} ;
2020
2121const USAGE : & str = help_usage ! ( "unexpand.md" ) ;
2222const ABOUT : & str = help_about ! ( "unexpand.md" ) ;
@@ -244,7 +244,7 @@ fn write_tabs(
244244 prevtab : bool ,
245245 init : bool ,
246246 amode : bool ,
247- ) {
247+ ) -> UResult < ( ) > {
248248 // This conditional establishes the following:
249249 // We never turn a single space before a non-blank into
250250 // a tab, unless it's at the start of the line.
@@ -255,15 +255,16 @@ fn write_tabs(
255255 break ;
256256 }
257257
258- crash_if_err ! ( 1 , output. write_all( b"\t " ) ) ;
258+ output. write_all ( b"\t " ) ? ;
259259 scol += nts;
260260 }
261261 }
262262
263263 while col > scol {
264- crash_if_err ! ( 1 , output. write_all( b" " ) ) ;
264+ output. write_all ( b" " ) ? ;
265265 scol += 1 ;
266266 }
267+ Ok ( ( ) )
267268}
268269
269270#[ derive( PartialEq , Eq , Debug ) ]
@@ -325,7 +326,7 @@ fn unexpand_line(
325326 options : & Options ,
326327 lastcol : usize ,
327328 ts : & [ usize ] ,
328- ) -> std :: io :: Result < ( ) > {
329+ ) -> UResult < ( ) > {
329330 let mut byte = 0 ; // offset into the buffer
330331 let mut col = 0 ; // the current column
331332 let mut scol = 0 ; // the start col for the current span, i.e., the already-printed width
@@ -335,7 +336,7 @@ fn unexpand_line(
335336 while byte < buf. len ( ) {
336337 // when we have a finite number of columns, never convert past the last column
337338 if lastcol > 0 && col >= lastcol {
338- write_tabs ( output, ts, scol, col, pctype == CharType :: Tab , init, true ) ;
339+ write_tabs ( output, ts, scol, col, pctype == CharType :: Tab , init, true ) ? ;
339340 output. write_all ( & buf[ byte..] ) ?;
340341 scol = col;
341342 break ;
@@ -370,7 +371,7 @@ fn unexpand_line(
370371 pctype == CharType :: Tab ,
371372 init,
372373 options. aflag ,
373- ) ;
374+ ) ? ;
374375 init = false ; // no longer at the start of a line
375376 col = if ctype == CharType :: Other {
376377 // use computed width
@@ -391,7 +392,7 @@ fn unexpand_line(
391392 }
392393
393394 // write out anything remaining
394- write_tabs ( output, ts, scol, col, pctype == CharType :: Tab , init, true ) ;
395+ write_tabs ( output, ts, scol, col, pctype == CharType :: Tab , init, true ) ? ;
395396 output. flush ( ) ?;
396397 buf. truncate ( 0 ) ; // clear out the buffer
397398
0 commit comments