manual: fopen with the x flag does not follow ISO C11

Message ID aa4cdd1b-cc35-e186-f68a-6de77bc7f396@cs.ucla.edu
State Superseded
Headers

Commit Message

Paul Eggert Dec. 10, 2019, 10:26 p.m. UTC
  On 12/10/19 4:18 AM, Florian Weimer wrote:
> I think it is worth clarifying that glibc's x specifier only results in
> O_EXCL and nothing else.

Although the glibc manual already says "x" means O_EXCL, I agree it'd be 
nice for it to also say that this behavior is compatible with ISO C. 
That is, the manual shouldn't imply that some standards require behavior 
other than O_EXCL.

How about the attached patch?

A different topic: shouldn't the manual refer to ISO C18 (the current 
version of the C standard) rather than to ISO C11 (the previous one)?
  

Comments

Andreas Schwab Dec. 11, 2019, 8:58 a.m. UTC | #1
On Dez 10 2019, Paul Eggert wrote:

> A different topic: shouldn't the manual refer to ISO C18 (the current
> version of the C standard) rather than to ISO C11 (the previous one)?

I think it makes sense to keep C11 which is when it was added.
Otherwise it should rather say just ISO C, so that it doesn't have to be
changed each time the standard is updated.

Andreas.
  
Florian Weimer Dec. 11, 2019, 9:53 a.m. UTC | #2
* Paul Eggert:

> On 12/10/19 4:18 AM, Florian Weimer wrote:
>> I think it is worth clarifying that glibc's x specifier only results in
>> O_EXCL and nothing else.
>
> Although the glibc manual already says "x" means O_EXCL, I agree it'd
> be nice for it to also say that this behavior is compatible with ISO
> C. That is, the manual shouldn't imply that some standards require
> behavior other than O_EXCL.
>
> How about the attached patch?

I'm not sure about the “common practice” part.  This would need
checking.  I would just drop it.

> A different topic: shouldn't the manual refer to ISO C18 (the current
> version of the C standard) rather than to ISO C11 (the previous one)?

I do not have a copy of C18, but it seems the wording is different
there.  As Andreas said, the x specifier was first mentioned in C11.

Thanks,
Florian
  
Andreas Schwab Dec. 11, 2019, 9:59 a.m. UTC | #3
On Dez 11 2019, Florian Weimer wrote:

> I do not have a copy of C18

C18 is N2176.

> but it seems the wording is different there.

C18 has exactly the same words.

Andreas.
  

Patch

From 20e37c044d4ebbaf593117364d8ad995c7628c2a Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 10 Dec 2019 14:22:36 -0800
Subject: [PATCH] manual: clarify fopen with the x flag

* manual/stdio.texi (Opening Streams): Say how glibc's
implementation of fopen with "x" follows ISO C11.
---
 manual/stdio.texi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/manual/stdio.texi b/manual/stdio.texi
index bbd3061bab..5caeacf595 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -216,7 +216,9 @@  exists, @code{fopen} fails rather than opening it.  If you use
 file.  This is equivalent to the @code{O_EXCL} option to the
 @code{open} function (@pxref{Opening and Closing Files}).
 
-The @samp{x} modifier is part of @w{ISO C11}.
+The @samp{x} modifier is part of @w{ISO C11}, which says the file is
+created with exclusive access; in @theglibc{} this means the
+equivalent of @code{O_EXCL}, which is common practice.
 @end table
 
 The character @samp{b} in @var{opentype} has a standard meaning; it
-- 
2.23.0