Commit c0f8abd0 authored by Bernhard Nortmann's avatar Bernhard Nortmann
Browse files

fexc: Use "binary" mode for input/output on Windows



Without this, the Windows version of sunxi-fexc might not process
files correctly.

TODO: This is really "hackish" / rather awful.
Eventually we should probably get rid of the file descriptor
based approach, i.e. open() plus _setmode(), and move to stdio
FILE* instead, which can be opened with the 'b' mode flag set.
Signed-off-by: default avatarBernhard Nortmann <bernhard.nortmann@web.de>
parent 453296b7
......@@ -114,6 +114,11 @@ static inline int script_parse(enum script_format format,
pr_err("%s: %s\n", filename, strerror(errno));
break;
}
#ifdef _WIN32
/* need to set "binary" mode for input, otherwise reading might fail
* prematurely on <EOF> chars */
_setmode(in, _O_BINARY);
#endif
if (fstat(in, &sb) == -1) {
pr_err("%s: %s: %s\n", filename,
......@@ -189,6 +194,11 @@ static inline int script_generate(enum script_format format,
pr_err("%s: %s\n", filename, strerror(errno));
goto done;
}
#ifdef _WIN32
/* need to set "binary" mode, otherwise writing might spoil the output
* with implicit <CR> --> <CR><LF> conversions */
_setmode(out, _O_BINARY);
#endif
bin_size = script_bin_size(script, &sections, &entries);
bin = calloc(1, bin_size);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment