Hello Bruno, Bruno Haible <br...@clisp.org> writes:
> Additionally, gnulib is the right place to do this because - as Eric said - > the 'e' flag is already scheduled for being added to the next POSIX version: > https://www.austingroupbugs.net/view.php?id=411 > > My evaluation of current platform support was incorrect: Current versions of > FreeBSD, NetBSD, OpenBSD, Solaris, Cygwin, and even Minix already support it. Thank you for this; would it make sense to use it in the modules that do one-shot fopen/fclose, such as read-file?
>From 5de739d03a7da71127b771cc213c873cd711ce51 Mon Sep 17 00:00:00 2001 From: Daiki Ueno <u...@gnu.org> Date: Tue, 26 May 2020 07:56:13 +0200 Subject: [PATCH] read-file: make use of fopen-gnu * lib/read-file.c (read_file): Pass an 'e' flag to fopen. (read_binary_file): Likewise. * modules/read-file (Depends-on): Add fopen-gnu. --- ChangeLog | 7 +++++++ lib/read-file.c | 4 ++-- modules/read-file | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1acb99ca..07d4d5124 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-05-26 Daiki Ueno <u...@gnu.org> + + read-file: make use of fopen-gnu + * lib/read-file.c (read_file): Pass an 'e' flag to fopen. + (read_binary_file): Likewise. + * modules/read-file (Depends-on): Add fopen-gnu. + 2020-05-25 Paul Eggert <egg...@cs.ucla.edu> getentropy, getrandom: new modules diff --git a/lib/read-file.c b/lib/read-file.c index c6f230178..293bc3e8a 100644 --- a/lib/read-file.c +++ b/lib/read-file.c @@ -171,7 +171,7 @@ internal_read_file (const char *filename, size_t *length, const char *mode) char * read_file (const char *filename, size_t *length) { - return internal_read_file (filename, length, "r"); + return internal_read_file (filename, length, "re"); } /* Open (on non-POSIX systems, in binary mode) and read the contents @@ -184,5 +184,5 @@ read_file (const char *filename, size_t *length) char * read_binary_file (const char *filename, size_t *length) { - return internal_read_file (filename, length, "rb"); + return internal_read_file (filename, length, "rbe"); } diff --git a/modules/read-file b/modules/read-file index 506e88f0a..a6e7faf0a 100644 --- a/modules/read-file +++ b/modules/read-file @@ -7,6 +7,7 @@ lib/read-file.c m4/read-file.m4 Depends-on: +fopen-gnu fstat ftello malloc-posix -- 2.26.2
Regards, -- Daiki Ueno