Date: Wed, 13 Jun 2001 11:58:16 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Tim Van Holder cc: DJGPP-Workers Subject: Re: (un)setenv() In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 12 Jun 2001, Tim Van Holder wrote: > I've written a simple implementation of unsetenv(), as that's > part of the new Posix standard. Thanks! I have a few minor comments, but other than that, it can go in. > That standard also specifies setenv(), though with slightly > different semantics (specifies errno=EINVAL if the name > contains a '='). Okay to update this function and its docs > to match the spec and move it from src/libc/compat/v1 to > src/libc/posix/stdlib? Please update the docs and the source, but I don't think we need to move the file to another directory. The structure of the directories in djlsr does not convey any information about standard compliance, it is simply a convenient way of organizing the source tree. We already have non-standard functions in standard directories, e.g. _rename in ansi/stdio. OTOH, if setenv is now Posix, we need to move its prototype in stdlib.h to the Posix section. > /* Let putenv() do the work */ > name_with_assign = malloc (strlen (name) + 2); Perhaps alloca is better here, since environment variables tend to be relatively short. You could also avoid this altogether, since `putenv' will remove the variable if passed a name without a value. I think it is okay to rely on this feature of our implementation of `putenv', provided that you say so in a comment. > putenv (name_with_assign); You cannot use `putenv' in a Posix function without including . > If @var{name} is @code{NULL}, points to an empty string, or points to > a string containing a @samp{=}, this function returns -1 and sets > @var{errno} to @code{EINVAL}; otherwise it returns 0. `errno' is not a formal argument, therefore it should have the @code markup, not @var. Finally, please add something in wc204.txi about these changes.