m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [PATCH] Open files in binary mode.


From: Maarten Anonymous
Subject: Fwd: [PATCH] Open files in binary mode.
Date: Thu, 30 Jul 2020 23:23:44 +0200

I Forgot to CC m4-patches@gnu.org...

(I'm new to mailing lists)

---------- Forwarded message ---------
Van: Maarten Anonymous <anonymous.maarten@gmail.com>
Date: do 30 jul. 2020 om 23:19
Subject: Re: [PATCH] Open files in binary mode.
To: Eric Blake <eblake@redhat.com>


Op do 30 jul. 2020 om 22:33 schreef Eric Blake <eblake@redhat.com>:

> Thanks for the patch.  However, I'm of the opinion that installing it
> would be a violation of POSIX, which requires that m4 operate on text
> files.  Since m4 can insert or remove newlines as part of macro
> definitions, operating in binary mode is very prone to creating
> incorrect line endings for a text file.  Yes, the POSIX definition of a
> text file does NOT play nicely with Windows text files, but my
> interpretation of POSIX is that using "rb" instead of "r" (on platforms
> where it _does_ matter, since a true POSIX platform treats them
> identically) is only safe to do in programs where POSIX requires the
> utility to operate on all files, not just text files.

Thanks for the quick reply!
I'm now skimmed though the posix m4 spec at
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/m4.html.
It indeed always refers to the input as `text file`.

For reference, what this patch fixes, is errors like the log at
https://github.com/conan-io/conan-center-index/pull/2103#issuecomment-653470881

Autoconf creates a frozen autoconf.m4f file that contains binary data.
This patch allows m4 to load the frozen file containing binary data.
e.g. the test file at
https://github.com/conan-io/conan-center-index/blob/master/recipes/m4/all/test_package/frozen.m4f

I think the origin of the binary data are these lines:
https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/m4sugar/m4sugar.m4#n2210

So I think only opening m4f files in binary mode would be fine too.

Maarten



reply via email to

[Prev in Thread] Current Thread [Next in Thread]