linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] getopt.3: Fix feature test macro requirements for getopt()
@ 2009-11-27  4:05 Jonathan Nieder
       [not found] ` <20091127040505.GA21636-Zz+2AvWe3NP1iTQCbxR7ew@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Nieder @ 2009-11-27  4:05 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

The synopsis previously stated that getopt requires
_POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE || _POSIX_SOURCE, but that
would be impossible, since _POSIX_SOURCE is a synonym for
_POSIX_C_SOURCE >= 1.

getopt was introduced to POSIX in POSIX.2.  The glibc headers
correctly test for that version.

Signed-off-by: Jonathan Nieder <jrnieder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Hi,

I noticed this when trying to compile a program that uses getopt with
_POSIX_SOURCE.  Checking the headers, I see that unistd.h does not
include getopt.h unless __USE_POSIX2 is defined, and getopt.h does not
choose the standards-conforming implementation unless __USE_POSIX2 &&
!__USE_POSIX_IMPLICITLY && !__USE_GNU is defined.

The POSIX-1 2008 documentation [1] suggests that SVr2 had a getopt,
and the FreeBSD manpage [2] says BSD 4.3 had one, too.  So maybe
getopt should be exposed if either _BSD_SOURCE or _SVID_SOURCE is
defined.  But it isn’t currently.

Anyway, I hope the patch is of some use.

Thanks,
Jonathan

[1] http://www.opengroup.org/onlinepubs/9699919799/functions/getopt.html
[2] http://svn.freebsd.org/viewvc/base/head/lib/libc/stdlib/getopt.3?view=markup

 man3/getopt.3 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/man3/getopt.3 b/man3/getopt.3
index 503f689..97ff60a 100644
--- a/man3/getopt.3
+++ b/man3/getopt.3
@@ -68,7 +68,7 @@ Feature Test Macro Requirements for glibc (see
 .in
 .sp
 .BR getopt ():
-_POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE || _POSIX_SOURCE
+_POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
 .br
 .BR getopt_long (),
 .BR getopt_long_only ():
-- 
1.6.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] getopt.3: Fix feature test macro requirements for getopt()
       [not found] ` <20091127040505.GA21636-Zz+2AvWe3NP1iTQCbxR7ew@public.gmane.org>
@ 2010-02-03  6:30   ` Michael Kerrisk
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk @ 2010-02-03  6:30 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

Hello Jonathan,

On Fri, Nov 27, 2009 at 5:05 AM, Jonathan Nieder <jrnieder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> The synopsis previously stated that getopt requires
> _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE || _POSIX_SOURCE, but that
> would be impossible, since _POSIX_SOURCE is a synonym for
> _POSIX_C_SOURCE >= 1.
>
> getopt was introduced to POSIX in POSIX.2.  The glibc headers
> correctly test for that version.

Agreed. I applied your patch. The change will be in man-pages-3.24.

I also discovered and fixed similar errors in popen(2) and confstr(3)!

Thanks!

Cheers,

Michael


> Signed-off-by: Jonathan Nieder <jrnieder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> Hi,
>
> I noticed this when trying to compile a program that uses getopt with
> _POSIX_SOURCE.  Checking the headers, I see that unistd.h does not
> include getopt.h unless __USE_POSIX2 is defined, and getopt.h does not
> choose the standards-conforming implementation unless __USE_POSIX2 &&
> !__USE_POSIX_IMPLICITLY && !__USE_GNU is defined.
>
> The POSIX-1 2008 documentation [1] suggests that SVr2 had a getopt,
> and the FreeBSD manpage [2] says BSD 4.3 had one, too.  So maybe
> getopt should be exposed if either _BSD_SOURCE or _SVID_SOURCE is
> defined.  But it isn’t currently.
>
> Anyway, I hope the patch is of some use.
>
> Thanks,
> Jonathan
>
> [1] http://www.opengroup.org/onlinepubs/9699919799/functions/getopt.html
> [2] http://svn.freebsd.org/viewvc/base/head/lib/libc/stdlib/getopt.3?view=markup
>
>  man3/getopt.3 |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/man3/getopt.3 b/man3/getopt.3
> index 503f689..97ff60a 100644
> --- a/man3/getopt.3
> +++ b/man3/getopt.3
> @@ -68,7 +68,7 @@ Feature Test Macro Requirements for glibc (see
>  .in
>  .sp
>  .BR getopt ():
> -_POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE || _POSIX_SOURCE
> +_POSIX_C_SOURCE\ >=\ 2 || _XOPEN_SOURCE
>  .br
>  .BR getopt_long (),
>  .BR getopt_long_only ():
> --
> 1.6.5.3
>
>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface" http://blog.man7.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-03  6:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-27  4:05 [PATCH] getopt.3: Fix feature test macro requirements for getopt() Jonathan Nieder
     [not found] ` <20091127040505.GA21636-Zz+2AvWe3NP1iTQCbxR7ew@public.gmane.org>
2010-02-03  6:30   ` Michael Kerrisk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).