Bug 202545 - A small change suggestion for the manual page fopen(3)
Summary: A small change suggestion for the manual page fopen(3)
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Books & Articles (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Eitan Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-21 11:27 UTC by intron
Modified: 2018-01-15 16:51 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description intron 2015-08-21 11:27:14 UTC
As so people know, fopen("/path/to/xxxxx.xxx", "w") empties the file if it exists. I believe that the FreeBSD manual page fopen(3) needs to mention it.

The corresponding POSIX manual page fopen(3p) says:

w or wb       Truncate to zero length or create file for writing.

The corresponding Linux manual page fopen(3) says:

w      Truncate file to zero length or create text file for writing.  The stream is positioned at the beginning of the file.

The following patch is against:

https://svnweb.freebsd.org/base/head/lib/libc/stdio/fopen.3?revision=266971&view=co

--- fopen.3.orig	2015-08-21 18:48:52 +0800
+++ fopen.3	2015-08-21 18:53:37 +0800
@@ -72,7 +72,7 @@
 .It Dq Li w
 Open for writing.
 The stream is positioned at the beginning of the file.
-Create the file if it does not exist.
+Truncate the file to zero length if it exists or create the file if it does not exist.
 .It Dq Li a
 Open for writing.
 The stream is positioned at the end of the file.
Comment 1 commit-hook freebsd_committer freebsd_triage 2017-12-23 05:13:57 UTC
A commit references this bug:

Author: eadler
Date: Sat Dec 23 05:13:39 UTC 2017
New revision: 327099
URL: https://svnweb.freebsd.org/changeset/base/327099

Log:
  fopen.1: document truncation

  This documentation truncation similar to POSIX and glibc.

  PR:		202545
  Reported by:	intron@intron.ac

Changes:
  head/lib/libc/stdio/fopen.3
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-01-15 16:51:57 UTC
A commit references this bug:

Author: eadler
Date: Mon Jan 15 16:51:05 UTC 2018
New revision: 328006
URL: https://svnweb.freebsd.org/changeset/base/328006

Log:
  MFC r327099:

  fopen.1: document truncation

  This documentation truncation similar to POSIX and glibc.

  PR:	202545

Changes:
_U  stable/11/
  stable/11/lib/libc/stdio/fopen.3