Hi Bruno, Thanks a lot for the analysis, and suggestion. Thanks to Andrei for the report, and to Kaz and Paul for routing them to gnulib.
> Le 23 août 2022 à 22:53, Bruno Haible <br...@clisp.org> a écrit : > > The second patch is against Bison proper, and can be simplified like this: > > diff --git a/src/location.c b/src/location.c > index 5edce82c..86e7c39d 100644 > --- a/src/location.c > +++ b/src/location.c > @@ -268,7 +268,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, "rb"))) > { > /* If the file is not regular (imagine #line 1 "/dev/stdin" > in the input file for instance), don't try to quote the > > It rationale is that caret_getc_internal already handles the CR/LF > newlines from Windows, and therefore opening the file in binary mode > avoids the horrible kludges of the Microsoft stdio runtime for O_TEXT > files. I'm installing this: commit cfef21f5b0a5c4291dcaa019e287210064371edb Author: Akim Demaille <akim.demai...@gmail.com> Date: Sat Sep 3 08:51:17 2022 +0200 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. diff --git a/THANKS b/THANKS index 391b847e..52092368 100644 --- a/THANKS +++ b/THANKS @@ -14,6 +14,7 @@ Alexandre Duret-Lutz a...@lrde.epita.fr Andre da Costa Barros andre.cbar...@yahoo.com Andreas Damm ad...@onica.com Andreas Schwab sch...@suse.de +Andrei Malashkin malashkin.and...@gmail.com Andrew Suffield asuffi...@users.sourceforge.net Angelo Borsotti angelo.borso...@gmail.com Anthony Heading a...@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)