summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2022-09-03 08:51:17 +0200
committerAkim Demaille <akim.demaille@gmail.com>2022-09-03 08:58:49 +0200
commitcfef21f5b0a5c4291dcaa019e287210064371edb (patch)
treed5d1dd56c09f53fe3cf068828737dd423d89333a
parent5555f4d05163316b8b5bddbdb172c0f5bae6f765 (diff)
downloadbison-cfef21f5b0a5c4291dcaa019e287210064371edb.tar.gz
diagnostics: Windows compatibility issues
Suggested by Bruno Haible <https://lists.gnu.org/r/bug-bison/2022-08/msg00006.html> following a report from Andrei Malashkin <https://lists.gnu.org/r/bug-bison/2022-08/msg00003.html> * src/location.c (caret_set_file): Read the file in binary. We already deal with CRLF in caret_getc_internal.
-rw-r--r--THANKS1
-rw-r--r--src/location.c8
2 files changed, 5 insertions, 4 deletions
diff --git a/THANKS b/THANKS
index 391b847e..52092368 100644
--- a/THANKS
+++ b/THANKS
@@ -14,6 +14,7 @@ Alexandre Duret-Lutz adl@lrde.epita.fr
Andre da Costa Barros andre.cbarros@yahoo.com
Andreas Damm adamm@onica.com
Andreas Schwab schwab@suse.de
+Andrei Malashkin malashkin.andrey@gmail.com
Andrew Suffield asuffield@users.sourceforge.net
Angelo Borsotti angelo.borsotti@gmail.com
Anthony Heading ajrh@ajrh.net
diff --git a/src/location.c b/src/location.c
index 94c77ef6..0f56bd39 100644
--- a/src/location.c
+++ b/src/location.c
@@ -268,13 +268,13 @@ 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, "rb")))
{
/* If the file is not regular (imagine #line 1 "/dev/stdin"
in the input file for instance), don't try to quote the
- file. Keep caret_info.file set so that we don't try to
- open it again, but leave caret_info.file NULL so that we
- don't try to quote it. */
+ file. Keep caret_info.pos.file set so that we don't try
+ to open it again, but leave caret_info.file NULL so that
+ we don't try to quote it. */
struct stat buf;
if (fstat (fileno (caret_info.file), &buf) == 0
&& buf.st_mode & S_IFREG)