Hello Bastien,

On 1/27/21 4:48 PM, roucaries.bast...@gmail.com wrote:
> From: Bastien Roucariès <ro...@debian.org>
> 
> Use feature_test_macros and document that historically
> you should manually declare it.
> ---
>  man7/environ.7 | 24 +++++++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/man7/environ.7 b/man7/environ.7
> index 981038ea1..7eeb1fe0e 100644
> --- a/man7/environ.7
> +++ b/man7/environ.7
> @@ -36,19 +36,36 @@
>  environ \- user environment
>  .SH SYNOPSIS
>  .nf
> +.B #include <unistd.h>
> +.PP
>  .BI "extern char **" environ ;
>  .fi
> +.PP
> +.RS -4
> +Feature Test Macro Requirements for glibc (see
> +.BR feature_test_macros (7)):
> +.RE
> +.PP
> +.I environ:
> +.nf
> +        _GNU_SOURCE
> +.fi

I fear that documenting this in the SYNOPSIS encourages
reliance on nonstandard behavior. I think the existing text
is nearly sufficient. 

>  .SH DESCRIPTION
>  The variable
>  .I environ
>  points to an array of pointers to strings called the "environment".
>  The last pointer in this array has the value NULL.
> -(This variable must be declared in the user program,
> -but is declared in the header file
> +.PP
> +Historically and by standard, this variable must be declared in the user 
> program,
> +but for programmer convenience
> +.I environ
> +is also declared in the header file

I like some of the wording you added here, and I've added.
But, at the same time, I've demoted this piece of text to NOTES,
since it cluttered up the initial paragraph, and as noted above,
I wouldn't encourage use of this nonstandard feature in portable
code.

Thanks,

Michael

>  .I <unistd.h>
>  if the
>  .B _GNU_SOURCE
> -feature test macro is defined.)
> +feature test macro is defined (see
> +.BR feature_test_macros(7)).
> +.PP
>  This array of strings is made available to the process by the
>  .BR exec (3)
>  call that started the process.
> @@ -380,6 +397,7 @@ should use instead an explicit \(aq\fB.\fP\(aq.
>  .BR putenv (3),
>  .BR setenv (3),
>  .BR unsetenv (3),
> +.NR feature_test_macros(7),
>  .BR locale (7),
>  .BR ld.so (8),
>  .BR pam_env (8)
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Reply via email to