Files
conan-build/recipes/bison/all/patches/0002-3.7.1-open-source-file-in-binary-mode-MS-ftell-bug-ks-68337.patch
Aleksandr Vodyanov 3759e1163f [DO-981] qt package (!15)
Co-authored-by: aleksandr.vodyanov <aleksandr.vodyanov@avroid.tech>
Reviewed-on: https://git.avroid.tech/Conan/conan_build/pulls/15
2025-02-13 12:25:48 +03:00

27 lines
968 B
Diff

--- src/location.c
+++ src/location.c
@@ -256,6 +256,14 @@ caret_free (void)
static bool
caret_set_file (const char *file)
{
+#if defined(_WIN32)
+ /* ftell() is unusable on Windows in the face of text files
+ that use just LF and not Windows-style CR-LF as newlines
+ http://support.microsoft.com/kb/68337 */
+ char fopen_mode[3] = "rb";
+#else
+ char fopen_mode[2] = "r";
+#endif
/* If a different file than before, close and let the rest open
the new one. */
if (caret_info.pos.file && caret_info.pos.file != file)
@@ -266,7 +266,7 @@ caret_set_file (const char *file)
if (!caret_info.pos.file)
{
caret_info.pos.file = file;
- if ((caret_info.file = fopen (caret_info.pos.file, "r")))
+ if ((caret_info.file = fopen (caret_info.pos.file, fopen_mode)))
{
/* If the file is not regular (imagine #line 1 "/dev/stdin"
in the input file for instance), don't try to quote the