Closed Bug 25982 Opened 25 years ago Closed 24 years ago

Add PR_SetEnv

Categories

(NSPR :: NSPR, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: larryh)

Details

Attachments

(1 file)

We should add a function to set an environment variable.
There is already a PR_SetEnv() function, but it's ifdef'd
with XP_MAC.
Status: NEW → ASSIGNED
Reassigned to larryh as a NSPR 4.1 feature.
Assignee: wtc → larryh
Status: ASSIGNED → NEW
QA Contact: srinivas → wtc
Target Milestone: --- → 4.1
Status: NEW → ASSIGNED
The function's name should be PR_PutEnv.
Summary: Add PR_SetEnv → Add PR_PutEnv
Whew! It is done.

I hate to do it, but there is a change to the API for PR_PutEnv(). PR_PutEnv() 
was declared to return PRIntn; it is changed to return PRStatus.

During development of PR_PutEnv() I discovered a surprisingly wide range of 
behavior across different platforms of the getenv(), putenv(). To get some 
consistent behavior across all platforms, I had coerce some behavior on some 
platforms and document some usage suggestions. See the header file 
nsprpub/pr/include/prenv.h for the specifics of how PR_GetEnv(), PR_PutEnv() 
behaves; it may differ slightly for the behavior of getenv(), putenv() on your 
favorite platform.

cvs commit -m"BugZilla: 25982. Add function PR_PutEnv()" pr/tests/env.c
RCS file: /cvsroot/mozilla/nsprpub/pr/tests/env.c,v
done
Checking in pr/tests/env.c;
/cvsroot/mozilla/nsprpub/pr/tests/env.c,v  <--  env.c
initial revision: 1.1
done
cvs commit -m"BugZilla: 25982. Add function PR_PutEnv()" pr/include/prenv.h
Checking in pr/include/prenv.h;
/cvsroot/mozilla/nsprpub/pr/include/prenv.h,v  <--  prenv.h
new revision: 3.7; previous revision: 3.6
done
cvs commit -m"BugZilla: 25982. Add function PR_PutEnv()" pr/src/md/mac/mdmac.c
Checking in pr/src/md/mac/mdmac.c;
/cvsroot/mozilla/nsprpub/pr/src/md/mac/mdmac.c,v  <--  mdmac.c
new revision: 3.15; previous revision: 3.14
done
cvs commit -m"BugZilla: 25982. Add function PR_PutEnv()" 
pr/src/md/windows/ntmisc.c
Checking in pr/src/md/windows/ntmisc.c;
/cvsroot/mozilla/nsprpub/pr/src/md/windows/ntmisc.c,v  <--  ntmisc.c
new revision: 3.15; previous revision: 3.14
done
cvs commit -m"BugZilla: 25982. Add function PR_PutEnv()" pr/src/misc/prenv.c
Checking in pr/src/misc/prenv.c;
/cvsroot/mozilla/nsprpub/pr/src/misc/prenv.c,v  <--  prenv.c
new revision: 3.7; previous revision: 3.6
done
cvs commit -m"BugZilla: 25982. Add function PR_PutEnv()" pr/tests/Makefile
Checking in pr/tests/Makefile;
/cvsroot/mozilla/nsprpub/pr/tests/Makefile,v  <--  Makefile
new revision: 3.63; previous revision: 3.62
done
Marking as fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
In earlier versions of NSPR, the Mac-only PR_PutEnv()
function was declared in prenv.h as follows:
#ifdef XP_MAC
NSPR_API(PRIntn) PR_PutEnv(const char *string);
#endif

It returns PR_TRUE on success and PR_FALSE on failure.
This is inconsistent with NSPR's contention of using
the PRStatus type to indicate success or failure of
a function.

In NSPR 4.1, we implemented PR_PutEnv() for all platforms.
We also changed its return type to PRStatus.
NSPR_API(PRStatus) PR_PutEnv(const char *string);

This is incompatible with the old Mac-only PR_PutEnv().
Fortunately, all the existing uses of the old Mac-only
PR_PutEnv() in SeaMonkey ignore the return value of the
function, so the change of the function's return type
won't affect SeaMonkey.
So I changed my mind again.  The reason is that
I only searched the Mozilla source code but there
may be other code, e.g. Netscape proprietary code,
that calls the Mac-specific PR_PutEnv().  To avoid
any backward compatibility issues, I think we should
name the new function PR_SetEnv().

I'm going to attach a patch.  Larry, please review it.
Thanks.
Summary: Add PR_PutEnv → Add PR_SetEnv
I checked in the patch (attachment id=13712) on the tip.
/cvsroot/mozilla/nsprpub/pr/include/prenv.h, revision: 3.10
/cvsroot/mozilla/nsprpub/pr/src/misc/prenv.c, revision: 3.8
/cvsroot/mozilla/nsprpub/pr/tests/env.c, revision: 1.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: