diff options
author | Fabian Giesen <fabiang@radgametools.com> | 2016-04-28 13:48:15 -0700 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2016-05-10 12:01:22 +0300 |
commit | 142285ddd8e8d2cb08003198d7186db9d3286ac1 (patch) | |
tree | 05917734ba27b9925859618f1b289281074c0225 | |
parent | 86d8756f0cd255e91c8ef8a4de1ebae3c18d30f3 (diff) | |
download | nasm-142285ddd8e8d2cb08003198d7186db9d3286ac1.tar.gz |
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>
-rw-r--r-- | output/codeview.c | 2 | ||||
-rw-r--r-- | preproc.c | 12 | ||||
-rw-r--r-- | preproc.h | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/output/codeview.c b/output/codeview.c index 571cbabe..56c46f2c 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -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; @@ -1509,7 +1509,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 = ""; @@ -1522,7 +1522,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; @@ -1564,13 +1564,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; @@ -2517,7 +2517,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); @@ -3260,7 +3260,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 |