@@ -170,10 +170,16 @@ fn print_cksum_report(res: &ChecksumResult) {
170170
171171/// Print a "no properly formatted lines" message in stderr
172172#[ inline]
173- fn log_no_properly_formatted ( filename : String ) {
173+ fn log_no_properly_formatted ( filename : impl Display ) {
174174 show_error ! ( "{filename}: no properly formatted checksum lines found" ) ;
175175}
176176
177+ /// Print a "no file was verified" message in stderr
178+ #[ inline]
179+ fn log_no_file_verified ( filename : impl Display ) {
180+ show_error ! ( "{filename}: no file was verified" ) ;
181+ }
182+
177183/// Represents the different outcomes that can happen to a file
178184/// that is being checked.
179185#[ derive( Debug , Clone , Copy ) ]
@@ -473,16 +479,6 @@ impl LineInfo {
473479 }
474480}
475481
476- fn get_filename_for_output ( filename : & OsStr , input_is_stdin : bool ) -> String {
477- if input_is_stdin {
478- "standard input"
479- } else {
480- filename. to_str ( ) . unwrap ( )
481- }
482- . maybe_quote ( )
483- . to_string ( )
484- }
485-
486482/// Extract the expected digest from the checksum string and decode it
487483fn get_raw_expected_digest ( checksum : & str , byte_len_hint : Option < usize > ) -> Option < Vec < u8 > > {
488484 // If the length of the digest is not a multiple of 2, then it must be
@@ -893,11 +889,19 @@ fn process_checksum_file(
893889 }
894890 }
895891
892+ let filename_display = || {
893+ if input_is_stdin {
894+ "standard input" . maybe_quote ( )
895+ } else {
896+ filename_input. maybe_quote ( )
897+ }
898+ } ;
899+
896900 // not a single line correctly formatted found
897901 // return an error
898902 if res. total_properly_formatted ( ) == 0 {
899903 if opts. verbose . over_status ( ) {
900- log_no_properly_formatted ( get_filename_for_output ( filename_input , input_is_stdin ) ) ;
904+ log_no_properly_formatted ( filename_display ( ) ) ;
901905 }
902906 return Err ( FileCheckError :: Failed ) ;
903907 }
@@ -911,11 +915,7 @@ fn process_checksum_file(
911915 // we have only bad format
912916 // and we had ignore-missing
913917 if opts. verbose . over_status ( ) {
914- eprintln ! (
915- "{}: {}: no file was verified" ,
916- util_name( ) ,
917- filename_input. maybe_quote( ) ,
918- ) ;
918+ log_no_file_verified ( filename_display ( ) ) ;
919919 }
920920 return Err ( FileCheckError :: Failed ) ;
921921 }
0 commit comments