[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: portability of fopen and 'e' (O_CLOEXEC) flag
From: |
Daiki Ueno |
Subject: |
Re: portability of fopen and 'e' (O_CLOEXEC) flag |
Date: |
Tue, 26 May 2020 08:01:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hello Bruno,
Bruno Haible <address@hidden> 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 <address@hidden>
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 <address@hidden>
+
+ 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 <address@hidden>
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
- portability of fopen and 'e' (O_CLOEXEC) flag, Tim Rühsen, 2020/05/11
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/11
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Eric Blake, 2020/05/11
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Tim Rühsen, 2020/05/12
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/24
- Re: portability of fopen and 'e' (O_CLOEXEC) flag,
Daiki Ueno <=
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/26
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/26
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/27
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Daiki Ueno, 2020/05/28
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Daiki Ueno, 2020/05/28
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/28
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Daiki Ueno, 2020/05/28
- Re: portability of fopen and 'e' (O_CLOEXEC) flag, Bruno Haible, 2020/05/29