@@ -18,6 +18,7 @@ extern "C" {
1818#endif /* __cplusplus */
1919
2020#include <stdio.h>
21+ #include <string.h>
2122
2223#if defined(WIN32 ) || defined(_WIN32 ) || defined(__WIN32__ ) || defined(__NT__ )
2324#else
@@ -133,11 +134,13 @@ unsigned int crc32_file(FILE *file) {
133134 * Reads the file and computes its CRC32C checksum, then compares with
134135 * the hash string ignoring character cases.
135136 */
136- bool crc32c (const char * filename , const char * hash ) {
137+ bool crc32c (const char * const filename , const char * const hash ) {
137138 unsigned int crc32_res ;
138139 FILE * fh ;
139140 char computed [9 ];
140141
142+ fprintf (stderr , "fopen %s\n" , filename );
143+
141144#if defined(_MSC_VER ) || (defined(__STDC_LIB_EXT1__ ) && __STDC_WANT_LIB_EXT1__ )
142145 fopen_s (& fh , filename , "rb" );
143146#else
@@ -151,23 +154,8 @@ bool crc32c(const char *filename, const char *hash) {
151154 fclose (fh );
152155
153156 snprintf (computed , sizeof (computed ), "%08x" , crc32_res );
154-
155- {
156- int i ;
157- for (i = 0 ; computed [i ] && hash [i ]; i ++ ) {
158- char c1 = computed [i ];
159- char c2 = hash [i ];
160- if (c1 >= 'A' && c1 <= 'F' )
161- c1 += 'a' - 'A' ;
162- if (c2 >= 'A' && c2 <= 'F' )
163- c2 += 'a' - 'A' ;
164- if (c1 != c2 )
165- return false;
166- }
167- if (computed [i ] != '\0' || hash [i ] != '\0' )
168- return false;
169- }
170- return true;
157+ fprintf (stderr , "computed: \"%s\"\n" , computed );
158+ return strcmp (computed , hash ) == 0 ;
171159}
172160
173161#endif /* defined(LIBACQUIRE_IMPLEMENTATION) && \
0 commit comments