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.
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.
Created attachment 254063 [details] fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__ Fix attached.
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.
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(-)
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);
@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.
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(-)
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(-)