mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-04-12 18:40:23 +08:00
codeview: Make md5sum calc read file in 'binary' mode
When assembling on Windows machines with CRLF line endings, computing the MD5 hash from the file read in "text" mode (transforms CRLF->LF) gives incorrect results. Signed-off-by: Fabian Giesen <fabiang@radgametools.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
0bbc38dbd5
commit
5b838ef981
@ -309,7 +309,7 @@ static void calc_md5(const char *const filename,
|
||||
FILE *f;
|
||||
MD5_CTX ctx;
|
||||
|
||||
f = pp_input_fopen(filename);
|
||||
f = pp_input_fopen(filename, "rb");
|
||||
if (!f)
|
||||
goto done;
|
||||
|
||||
|
12
preproc.c
12
preproc.c
@ -1504,7 +1504,7 @@ static bool in_list(const StrList *list, const char *str)
|
||||
* the end of the path.
|
||||
*/
|
||||
static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail,
|
||||
bool missing_ok)
|
||||
bool missing_ok, const char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
char *prefix = "";
|
||||
@ -1517,7 +1517,7 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail,
|
||||
sl = nasm_malloc(prefix_len+len+1+sizeof sl->next);
|
||||
memcpy(sl->str, prefix, prefix_len);
|
||||
memcpy(sl->str+prefix_len, file, len+1);
|
||||
fp = fopen(sl->str, "r");
|
||||
fp = fopen(sl->str, mode);
|
||||
if (fp && dhead && !in_list(*dhead, sl->str)) {
|
||||
sl->next = NULL;
|
||||
**dtail = sl;
|
||||
@ -1559,13 +1559,13 @@ static FILE *inc_fopen(const char *file, StrList **dhead, StrList ***dtail,
|
||||
* that get a file:lineno pair and need to look at the file again
|
||||
* (e.g. the CodeView debug backend). Returns NULL on failure.
|
||||
*/
|
||||
FILE *pp_input_fopen(const char *filename)
|
||||
FILE *pp_input_fopen(const char *filename, const char *mode)
|
||||
{
|
||||
FILE *fp;
|
||||
StrList *xsl = NULL;
|
||||
StrList **xst = &xsl;
|
||||
|
||||
fp = inc_fopen(filename, &xsl, &xst, true);
|
||||
fp = inc_fopen(filename, &xsl, &xst, true, mode);
|
||||
if (xsl)
|
||||
nasm_free(xsl);
|
||||
return fp;
|
||||
@ -2512,7 +2512,7 @@ static int do_directive(Token * tline)
|
||||
inc = nasm_malloc(sizeof(Include));
|
||||
inc->next = istk;
|
||||
inc->conds = NULL;
|
||||
inc->fp = inc_fopen(p, dephead, &deptail, pass == 0);
|
||||
inc->fp = inc_fopen(p, dephead, &deptail, pass == 0, "r");
|
||||
if (!inc->fp) {
|
||||
/* -MG given but file not found */
|
||||
nasm_free(inc);
|
||||
@ -3253,7 +3253,7 @@ issue_error:
|
||||
if (t->type != TOK_INTERNAL_STRING)
|
||||
nasm_unquote(p, NULL);
|
||||
|
||||
fp = inc_fopen(p, &xsl, &xst, true);
|
||||
fp = inc_fopen(p, &xsl, &xst, true, "r");
|
||||
if (fp) {
|
||||
p = xsl->str;
|
||||
fclose(fp); /* Don't actually care about the file */
|
||||
|
@ -49,6 +49,6 @@ typedef const unsigned char macros_t;
|
||||
enum preproc_token pp_token_hash(const char *token);
|
||||
|
||||
/* Opens an include file or input file. This uses the include path. */
|
||||
FILE *pp_input_fopen(const char *filename);
|
||||
FILE *pp_input_fopen(const char *filename, const char *mode);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user