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.
This commit is contained in:
Akim Demaille
2022-09-03 08:51:17 +02:00
parent 5555f4d051
commit cfef21f5b0
2 changed files with 5 additions and 4 deletions

1
THANKS
View File

@@ -14,6 +14,7 @@ Alexandre Duret-Lutz adl@lrde.epita.fr
Andre da Costa Barros andre.cbarros@yahoo.com Andre da Costa Barros andre.cbarros@yahoo.com
Andreas Damm adamm@onica.com Andreas Damm adamm@onica.com
Andreas Schwab schwab@suse.de Andreas Schwab schwab@suse.de
Andrei Malashkin malashkin.andrey@gmail.com
Andrew Suffield asuffield@users.sourceforge.net Andrew Suffield asuffield@users.sourceforge.net
Angelo Borsotti angelo.borsotti@gmail.com Angelo Borsotti angelo.borsotti@gmail.com
Anthony Heading ajrh@ajrh.net Anthony Heading ajrh@ajrh.net

View File

@@ -268,13 +268,13 @@ caret_set_file (const char *file)
if (!caret_info.pos.file) if (!caret_info.pos.file)
{ {
caret_info.pos.file = 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" /* If the file is not regular (imagine #line 1 "/dev/stdin"
in the input file for instance), don't try to quote the 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 file. Keep caret_info.pos.file set so that we don't try
open it again, but leave caret_info.file NULL so that we to open it again, but leave caret_info.file NULL so that
don't try to quote it. */ we don't try to quote it. */
struct stat buf; struct stat buf;
if (fstat (fileno (caret_info.file), &buf) == 0 if (fstat (fileno (caret_info.file), &buf) == 0
&& buf.st_mode & S_IFREG) && buf.st_mode & S_IFREG)