develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991116.002] perl5.005_02: my_setenv() and Term::ReadLine::Gnu

From:
hiroo.hayashi
Date:
November 17, 1999 10:11
Subject:
Re: [ID 19991116.002] perl5.005_02: my_setenv() and Term::ReadLine::Gnu
Message ID:
199911171810.DAA16755@mail.fb3.so-net.ne.jp
--------
Hello Joerg, and long time no seeing you, Ilya.


Ilya> Without further explanation I hardly think this is a solution.  The
Ilya> real problem is that putenv() of Term::ReadLine::Gnu is mentioning a
Ilya> wrong malloc()  [though I have no idea how this might have happened -
Ilya> but it does, at least on Solaris 2.7].

I agree with you.  Something wrong around malloc().

But I feel strange by seeing the patch.

>> --- perl5.005_02/util.c.orig	Wed Nov 17 00:21:06 1999
>> +++ perl5.005_02/util.c	Wed Nov 17 00:21:50 1999
>> @@ -1413,12 +1413,14 @@
>> my_setenv(char *nam, char *val)
>> {
>> register I32 i=setenv_getix(nam);		/* where does it go? */
>> +    static int copyenv = 1;
>> 
>> -    if (environ == PL_origenviron) {	/* need we copy environment? */
>> +    if (copyenv) {	/* need we copy environment? */
>> I32 j;
>> I32 max;
>> char **tmpenv;
>> 
>> +	copyenv = 0;
>> /*SUPPRESS 530*/
>> for (max = i; environ[max]; max++) ;
>> New(901,tmpenv, max+2, char*);

The orignal code assumes

>> -    if (environ == PL_origenviron) {	/* need we copy environment? */

is true, only when my_setenv() is called at the first time only.  And
Joerg's patch should work as same as original code.  I do not
understand why the patch works.

Thank you.
--------
Hiroo Hayashi



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About