@@ -626,23 +626,23 @@ impl ByteSliceExt for [u8] {
626626}
627627
628628impl LineInfo {
629- fn parse ( s : impl AsRef < OsStr > , cached_lineformat : & mut Option < LineFormat > ) -> Option < Self > {
629+ fn parse ( s : impl AsRef < OsStr > , cached_line_format : & mut Option < LineFormat > ) -> Option < Self > {
630630 let line_bytes = os_str_as_bytes ( s. as_ref ( ) ) . ok ( ) ?;
631631
632632 if let Some ( info) = LineFormat :: parse_algo_based ( line_bytes) {
633633 return Some ( info) ;
634634 }
635- if let Some ( cached_format) = cached_lineformat {
635+ if let Some ( cached_format) = cached_line_format {
636636 match cached_format {
637637 LineFormat :: Untagged => LineFormat :: parse_untagged ( line_bytes) ,
638638 LineFormat :: SingleSpace => LineFormat :: parse_single_space ( line_bytes) ,
639639 _ => unreachable ! ( "we never catch the algo based format" ) ,
640640 }
641641 } else if let Some ( info) = LineFormat :: parse_untagged ( line_bytes) {
642- * cached_lineformat = Some ( LineFormat :: Untagged ) ;
642+ * cached_line_format = Some ( LineFormat :: Untagged ) ;
643643 Some ( info)
644644 } else if let Some ( info) = LineFormat :: parse_single_space ( line_bytes) {
645- * cached_lineformat = Some ( LineFormat :: SingleSpace ) ;
645+ * cached_line_format = Some ( LineFormat :: SingleSpace ) ;
646646 Some ( info)
647647 } else {
648648 None
@@ -921,7 +921,7 @@ fn process_checksum_line(
921921 cli_algo_name : Option < & str > ,
922922 cli_algo_length : Option < usize > ,
923923 opts : ChecksumOptions ,
924- cached_lineformat : & mut Option < LineFormat > ,
924+ cached_line_format : & mut Option < LineFormat > ,
925925 last_algo : & mut Option < String > ,
926926) -> Result < ( ) , LineCheckError > {
927927 let line_bytes = os_str_as_bytes ( line) ?;
@@ -933,7 +933,7 @@ fn process_checksum_line(
933933
934934 // Use `LineInfo` to extract the data of a line.
935935 // Then, depending on its format, apply a different pre-treatment.
936- let Some ( line_info) = LineInfo :: parse ( line, cached_lineformat ) else {
936+ let Some ( line_info) = LineInfo :: parse ( line, cached_line_format ) else {
937937 return Err ( LineCheckError :: ImproperlyFormatted ) ;
938938 } ;
939939
@@ -976,9 +976,9 @@ fn process_checksum_file(
976976 let reader = BufReader :: new ( file) ;
977977 let lines = read_os_string_lines ( reader) . collect :: < Vec < _ > > ( ) ;
978978
979- // cached_lineformat is used to ensure that several non algo-based checksum line
979+ // cached_line_format is used to ensure that several non algo-based checksum line
980980 // will use the same parser.
981- let mut cached_lineformat = None ;
981+ let mut cached_line_format = None ;
982982 // last_algo caches the algorithm used in the last line to print a warning
983983 // message for the current line if improperly formatted.
984984 // Behavior tested in gnu_cksum_c::test_warn
@@ -991,7 +991,7 @@ fn process_checksum_file(
991991 cli_algo_name,
992992 cli_algo_length,
993993 opts,
994- & mut cached_lineformat ,
994+ & mut cached_line_format ,
995995 & mut last_algo,
996996 ) ;
997997
@@ -1448,69 +1448,69 @@ mod tests {
14481448
14491449 #[ test]
14501450 fn test_line_info ( ) {
1451- let mut cached_lineformat = None ;
1451+ let mut cached_line_format = None ;
14521452
14531453 // Test algo-based parser
14541454 let line_algo_based =
14551455 OsString :: from ( "MD5 (example.txt) = d41d8cd98f00b204e9800998ecf8427e" ) ;
1456- let line_info = LineInfo :: parse ( & line_algo_based, & mut cached_lineformat ) . unwrap ( ) ;
1456+ let line_info = LineInfo :: parse ( & line_algo_based, & mut cached_line_format ) . unwrap ( ) ;
14571457 assert_eq ! ( line_info. algo_name. as_deref( ) , Some ( "MD5" ) ) ;
14581458 assert ! ( line_info. algo_bit_len. is_none( ) ) ;
14591459 assert_eq ! ( line_info. filename, b"example.txt" ) ;
14601460 assert_eq ! ( line_info. checksum, "d41d8cd98f00b204e9800998ecf8427e" ) ;
14611461 assert_eq ! ( line_info. format, LineFormat :: AlgoBased ) ;
1462- assert ! ( cached_lineformat . is_none( ) ) ;
1462+ assert ! ( cached_line_format . is_none( ) ) ;
14631463
14641464 // Test double-space parser
14651465 let line_double_space = OsString :: from ( "d41d8cd98f00b204e9800998ecf8427e example.txt" ) ;
1466- let line_info = LineInfo :: parse ( & line_double_space, & mut cached_lineformat ) . unwrap ( ) ;
1466+ let line_info = LineInfo :: parse ( & line_double_space, & mut cached_line_format ) . unwrap ( ) ;
14671467 assert ! ( line_info. algo_name. is_none( ) ) ;
14681468 assert ! ( line_info. algo_bit_len. is_none( ) ) ;
14691469 assert_eq ! ( line_info. filename, b"example.txt" ) ;
14701470 assert_eq ! ( line_info. checksum, "d41d8cd98f00b204e9800998ecf8427e" ) ;
14711471 assert_eq ! ( line_info. format, LineFormat :: Untagged ) ;
1472- assert ! ( cached_lineformat . is_some( ) ) ;
1472+ assert ! ( cached_line_format . is_some( ) ) ;
14731473
1474- cached_lineformat = None ;
1474+ cached_line_format = None ;
14751475
14761476 // Test single-space parser
14771477 let line_single_space = OsString :: from ( "d41d8cd98f00b204e9800998ecf8427e example.txt" ) ;
1478- let line_info = LineInfo :: parse ( & line_single_space, & mut cached_lineformat ) . unwrap ( ) ;
1478+ let line_info = LineInfo :: parse ( & line_single_space, & mut cached_line_format ) . unwrap ( ) ;
14791479 assert ! ( line_info. algo_name. is_none( ) ) ;
14801480 assert ! ( line_info. algo_bit_len. is_none( ) ) ;
14811481 assert_eq ! ( line_info. filename, b"example.txt" ) ;
14821482 assert_eq ! ( line_info. checksum, "d41d8cd98f00b204e9800998ecf8427e" ) ;
14831483 assert_eq ! ( line_info. format, LineFormat :: SingleSpace ) ;
1484- assert ! ( cached_lineformat . is_some( ) ) ;
1484+ assert ! ( cached_line_format . is_some( ) ) ;
14851485
1486- cached_lineformat = None ;
1486+ cached_line_format = None ;
14871487
14881488 // Test invalid checksum line
14891489 let line_invalid = OsString :: from ( "invalid checksum line" ) ;
1490- assert ! ( LineInfo :: parse( & line_invalid, & mut cached_lineformat ) . is_none( ) ) ;
1491- assert ! ( cached_lineformat . is_none( ) ) ;
1490+ assert ! ( LineInfo :: parse( & line_invalid, & mut cached_line_format ) . is_none( ) ) ;
1491+ assert ! ( cached_line_format . is_none( ) ) ;
14921492
14931493 // Test leading space before checksum line
14941494 let line_algo_based_leading_space =
14951495 OsString :: from ( " MD5 (example.txt) = d41d8cd98f00b204e9800998ecf8427e" ) ;
14961496 let line_info =
1497- LineInfo :: parse ( & line_algo_based_leading_space, & mut cached_lineformat ) . unwrap ( ) ;
1497+ LineInfo :: parse ( & line_algo_based_leading_space, & mut cached_line_format ) . unwrap ( ) ;
14981498 assert_eq ! ( line_info. format, LineFormat :: AlgoBased ) ;
1499- assert ! ( cached_lineformat . is_none( ) ) ;
1499+ assert ! ( cached_line_format . is_none( ) ) ;
15001500
15011501 // Test trailing space after checksum line (should fail)
15021502 let line_algo_based_leading_space =
15031503 OsString :: from ( "MD5 (example.txt) = d41d8cd98f00b204e9800998ecf8427e " ) ;
1504- let res = LineInfo :: parse ( & line_algo_based_leading_space, & mut cached_lineformat ) ;
1504+ let res = LineInfo :: parse ( & line_algo_based_leading_space, & mut cached_line_format ) ;
15051505 assert ! ( res. is_none( ) ) ;
1506- assert ! ( cached_lineformat . is_none( ) ) ;
1506+ assert ! ( cached_line_format . is_none( ) ) ;
15071507 }
15081508
15091509 #[ test]
15101510 fn test_get_expected_digest ( ) {
15111511 let line = OsString :: from ( "SHA256 (empty) = 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=" ) ;
1512- let mut cached_lineformat = None ;
1513- let line_info = LineInfo :: parse ( & line, & mut cached_lineformat ) . unwrap ( ) ;
1512+ let mut cached_line_format = None ;
1513+ let line_info = LineInfo :: parse ( & line, & mut cached_line_format ) . unwrap ( ) ;
15141514
15151515 let result = get_expected_digest_as_hex_string ( & line_info, None ) ;
15161516
@@ -1524,8 +1524,8 @@ mod tests {
15241524 fn test_get_expected_checksum_invalid ( ) {
15251525 // The line misses a '=' at the end to be valid base64
15261526 let line = OsString :: from ( "SHA256 (empty) = 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU" ) ;
1527- let mut cached_lineformat = None ;
1528- let line_info = LineInfo :: parse ( & line, & mut cached_lineformat ) . unwrap ( ) ;
1527+ let mut cached_line_format = None ;
1528+ let line_info = LineInfo :: parse ( & line, & mut cached_line_format ) . unwrap ( ) ;
15291529
15301530 let result = get_expected_digest_as_hex_string ( & line_info, None ) ;
15311531
0 commit comments