Bug 281828 - gets_s(3) manpage needs to mention about __STDC_WANT_LIB_EXT1__
Summary: gets_s(3) manpage needs to mention about __STDC_WANT_LIB_EXT1__
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-03 03:57 UTC by Yuichiro NAITO
Modified: 2024-12-27 23:50 UTC (History)
6 users (show)

See Also:


Attachments
fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__ (819 bytes, patch)
2024-10-06 23:03 UTC, Graham Percival
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yuichiro NAITO 2024-10-03 03:57:49 UTC
Related to #281768, c25e55bcf80b7fc5384c34948404ae9d65c29bab commit hides
'gets_s' prototype under __EXT1_VISIBLE definition.
This change should be known from the 'gets_s' manpage.

As same as the 'qsort_s', ' #define __STDC_WANT_LIB_EXT1__ 1' should be written
above the 'gets_s' prototype in the SYNOPSIS section.
Comment 1 Graham Percival 2024-10-03 17:29:20 UTC
To be pedantic, the gets_s prototype was hidden in <stdio.h> when it was first introduced:
  https://github.com/freebsd/freebsd-src/commit/c13559d31e90a8c405771be36ab9ccfa41d4ebd6#diff-5e1f2789f2dc0618ffb77ce98c2fab185eaedd0897a0326180f0fb4db794e0b3R273

The "un-hiding" was in <ssp/stdio.h>, which was introduced much later, in
  https://reviews.freebsd.org/D45679

So the missing mention of __STDC_WANT_LIB_EXT1__ in the man page was a problem since 2018-04-03, not a new problem on 2024-10-02.
Comment 2 Graham Percival 2024-10-06 23:03:07 UTC
Created attachment 254063 [details]
fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__

Fix attached.
Comment 3 John Baldwin freebsd_committer freebsd_triage 2024-12-06 18:19:21 UTC
I'll merge the patch, but note that the default namespace in <sys/cdefs.h> sets __EXT_VISIBLE to 1 so this is only really required if you are doing something to restrict your namespace to a specific C or POSIX version.
Comment 4 commit-hook freebsd_committer freebsd_triage 2024-12-06 18:21:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d0a3fd34a05794bc5cbf48709001a78e9f85169a

commit d0a3fd34a05794bc5cbf48709001a78e9f85169a
Author:     Graham Percival <gperciva@tarsnap.com>
AuthorDate: 2024-10-06 22:57:45 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-12-06 18:20:19 +0000

    fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__

    This matches the man page for qsort_s().

    PR:             281828
    Signed-off-by:  Graham Percival <gperciva@tarsnap.com>
    Sponsored by:   Tarsnap Backup Inc.

 lib/libc/stdio/fgets.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 5 Ed Maste freebsd_committer freebsd_triage 2024-12-06 18:21:25 UTC
The spacing is maybe not completely clear about to what the #define applies, but perhaps this is consistent with all cases of this.

     #include <stdio.h>

     char *
     fgets(char * restrict str, int size, FILE * restrict stream);

     #define __STDC_WANT_LIB_EXT1__ 1

     char *
     gets_s(char *str, rsize_t size);
Comment 6 Graham Percival 2024-12-07 00:20:24 UTC
@emaste:
I based my patch on the man page for qsort_s (3); seen in
    lib/libc/stdlib/qsort.3
or
    https://reviews.freebsd.org/D23174

My interpretation of that page is "everything under the #define needs it", so I did the same thing for gets_s().

@jhb:
I did wonder about writing something like "you only need __STD_WANT_LIB_EXT1__ if you're using c99 or added some special -D defines".  But I couldn't see any such language in qsort(3) or set_constraint_handler_s(3), so I left it out.
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-12-27 17:06:56 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=334e641d3861a866817a91a85b0bc3ec76936799

commit 334e641d3861a866817a91a85b0bc3ec76936799
Author:     Graham Percival <gperciva@tarsnap.com>
AuthorDate: 2024-10-06 22:57:45 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-12-27 15:48:27 +0000

    fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__

    This matches the man page for qsort_s().

    PR:             281828
    Signed-off-by:  Graham Percival <gperciva@tarsnap.com>
    Sponsored by:   Tarsnap Backup Inc.

    (cherry picked from commit d0a3fd34a05794bc5cbf48709001a78e9f85169a)

 lib/libc/stdio/fgets.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-12-27 17:07:59 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7c4be554f72adb4bc008aa71c269801c10012d77

commit 7c4be554f72adb4bc008aa71c269801c10012d77
Author:     Graham Percival <gperciva@tarsnap.com>
AuthorDate: 2024-10-06 22:57:45 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-12-27 15:49:31 +0000

    fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__

    This matches the man page for qsort_s().

    PR:             281828
    Signed-off-by:  Graham Percival <gperciva@tarsnap.com>
    Sponsored by:   Tarsnap Backup Inc.

    (cherry picked from commit d0a3fd34a05794bc5cbf48709001a78e9f85169a)

 lib/libc/stdio/fgets.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)