delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/08/16:24:56

Message-Id: <199908082020.UAA80886@out1.ibm.net>
From: "Mark E." <snowball3 AT bigfoot DOT com>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>, djgpp-workers AT delorie DOT com
Date: Sun, 8 Aug 1999 16:20:48 -0400
MIME-Version: 1.0
Subject: Re: suggestion for getenv.c
References: <199908071919 DOT TAA94618 AT out4 DOT ibm DOT net>
In-reply-to: <Pine.SUN.3.91.990808143717.23423n-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.11)
Reply-To: djgpp-workers AT delorie DOT com

> The machinery to do such caching is already in place: see the
> variable `__environ_changed'.  `_use_lfn' actually uses it.
> 
> Assuming that there is some case where `getenv' is called a lot from
> `_put_path2', and where this caching makes a difference, I don't see
> any reasons not to add this feature.  Please send in the diffs.
> (Don't forget to use `__bss_count' to invalidate the cache when the
> program is restarted, for Emacs' sake.)
> 

There's one change to getenv I think should be made:

*** src/libc/ansi/stdlib/getenv.c.orig	Fri Nov 24 22:21:18 1995
--- src/libc/ansi/stdlib/getenv.c	Sun Aug  8 16:11:28 1999
***************
*** 1,3 ****
--- 1,4 ----
+ /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  #include <stdlib.h>
  #include <string.h>
*************** getenv(const char *name)
*** 9,15 ****
  {
    int i;
  
!   if (environ == 0)
      return 0;
  
    for (i=0; environ[i]; i++)
--- 10,16 ----
  {
    int i;
  
!   if (environ == 0 || name == 0)
      return 0;
  
    for (i=0; environ[i]; i++)

As for the other change, I'll do some testing and see if the change is worth making.

Mark
--- 
Mark Elbrecht, snowball3 AT bigfoot DOT com
http://snowball.frogspace.net/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019