File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,25 @@ fn check_lalrpop() {
1818 . unwrap ( ) ;
1919 let expected_sha3_str = sha3_line. strip_prefix ( "// sha3: " ) . unwrap ( ) ;
2020
21- let mut hasher = Sha3 :: v256 ( ) ;
22- hasher. update ( & std:: fs:: read ( "src/python.lalrpop" ) . unwrap ( ) ) ;
23- let mut actual_sha3 = [ 0u8 ; 32 ] ;
24- hasher. finalize ( & mut actual_sha3) ;
21+ let actual_sha3 = {
22+ let mut hasher = Sha3 :: v256 ( ) ;
23+ let mut f = BufReader :: new ( File :: open ( "src/python.lalrpop" ) . unwrap ( ) ) ;
24+ let mut line = String :: new ( ) ;
25+ while f. read_line ( & mut line) . unwrap ( ) != 0 {
26+ if line. ends_with ( '\n' ) {
27+ line. pop ( ) ;
28+ if line. ends_with ( '\r' ) {
29+ line. pop ( ) ;
30+ }
31+ }
32+ hasher. update ( line. as_bytes ( ) ) ;
33+ hasher. update ( b"\n " ) ;
34+ line. clear ( ) ;
35+ }
36+ let mut hash = [ 0u8 ; 32 ] ;
37+ hasher. finalize ( & mut hash) ;
38+ hash
39+ } ;
2540
2641 // stupid stupid stupid hack. lalrpop outputs each byte as "{:x}" instead of "{:02x}"
2742 let sha3_equal = if expected_sha3_str. len ( ) == 64 {
You can’t perform that action at this time.
0 commit comments