From: nasm-bot f. F. G. <fa...@ra...> - 2016-05-10 09:06:23
|
Commit-ID: 142285ddd8e8d2cb08003198d7186db9d3286ac1 Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=142285ddd8e8d2cb08003198d7186db9d3286ac1 Author: Fabian Giesen <fa...@ra...> AuthorDate: Thu, 28 Apr 2016 13:48:15 -0700 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Tue, 10 May 2016 12:01:22 +0300 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 <fa...@ra...> Signed-off-by: Cyrill Gorcunov <gor...@gm...> --- output/codeview.c | 2 +- preproc.c | 12 ++++++------ preproc.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/output/codeview.c b/output/codeview.c index 571cbab..56c46f2 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; diff --git a/preproc.c b/preproc.c index 78263fb..d235280 100644 --- a/preproc.c +++ b/preproc.c @@ -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 */ diff --git a/preproc.h b/preproc.h index 3dee45f..3d1aa9c 100644 --- a/preproc.h +++ b/preproc.h @@ -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 |