Closed
Bug 306840
Opened 19 years ago
Closed 5 years ago
Improve PR_GetEnv() usages
Categories
(Core :: General, task)
Core
General
Tracking
()
RESOLVED
INACTIVE
People
(Reporter: sgautherie, Unassigned)
References
(Depends on 1 open bug, )
Details
Attachments
(3 files, 6 obsolete files)
11.92 KB,
patch
|
Details | Diff | Splinter Review | |
5.08 KB,
patch
|
sgautherie
:
review+
sgautherie
:
superreview+
|
Details | Diff | Splinter Review |
916 bytes,
patch
|
sgautherie
:
review+
sgautherie
:
superreview+
|
Details | Diff | Splinter Review |
Spun off from <https://bugzilla.mozilla.org/show_bug.cgi?id=287540#c34> {{ ------- Additional Comment #34 From timeless@myrealbox.com (working) 2005-08-16 22:56 PDT [reply] ------- the proper way to use PR_GetEnv involves: const char* foo = PR_GetEnv("BAR"); (foo && *foo) not simply (foo). }}
Reporter | ||
Updated•19 years ago
|
Assignee: general → gautheri
Reporter | ||
Updated•19 years ago
|
Status: NEW → ASSIGNED
Reporter | ||
Comment 1•19 years ago
|
||
Attachment #194656 -
Flags: superreview?(shaver)
Attachment #194656 -
Flags: review?(dougt)
Comment on attachment 194656 [details] [diff] [review] (Bv1) <XpCom/*> There's no need for all the whitespace noise in this patch, but regardless: please don't request sr from me for this sort of trivial cleanup. I just don't have the bandwidth for it.
Attachment #194656 -
Flags: superreview?(shaver)
Reporter | ||
Comment 3•19 years ago
|
||
Attachment #194658 -
Flags: review?(dougt)
Reporter | ||
Updated•19 years ago
|
Attachment #194656 -
Flags: review?(dougt)
Comment 4•19 years ago
|
||
Comment on attachment 194658 [details] [diff] [review] (Bv1) <XpCom/*> (-Bpuw for review) timeless should review this.
Attachment #194658 -
Flags: review?(dougt) → review?(timeless)
Reporter | ||
Comment 5•19 years ago
|
||
Attachment #194661 -
Flags: review?(neil.parkwaycc.co.uk)
Comment 6•19 years ago
|
||
Comment on attachment 194661 [details] [diff] [review] (Av1) <XpFe/*> (-Bw for review) > // Make sure to set a username if possible > if (!username) { > username = PR_GetEnv("LOGNAME"); >+ if (username && !*username) { >+ username = nsnull; >+ } > } This bit looks wrong but please ask timeless for review next time.
Attachment #194661 -
Flags: review?(neil.parkwaycc.co.uk) → review-
Reporter | ||
Comment 7•19 years ago
|
||
Comment on attachment 194661 [details] [diff] [review] (Av1) <XpFe/*> (-Bw for review) Timeless: I'll do the removal suggested by Neil after your review...
Attachment #194661 -
Flags: review?(timeless)
Comment 8•19 years ago
|
||
If the environment variable is defined, returns a pointer to its value; otherwise returns NULL. Why do we need to check both? http://www.mozilla.org/projects/nspr/reference/html/prsystem.html#25208
Comment 10•19 years ago
|
||
Comment on attachment 194658 [details] [diff] [review] (Bv1) <XpCom/*> (-Bpuw for review) >Index: mozilla/xpcom/io/nsDirectoryService.cpp >diff -u -p -B -p -u -w -r1.83 nsDirectoryService.cpp >@@ -249,15 +249,15 @@ nsDirectoryService::GetCurrentProcessDir > // We do this py putenv()ing the default value into the environment. Note that someone should change "py" to "by" ... > // we only do this if it is not already set. > #ifdef MOZ_DEFAULT_MOZILLA_FIVE_HOME >- if (PR_GetEnv("MOZILLA_FIVE_HOME") == nsnull) >+ const char *home = PR_GetEnv("MOZILLA_FIVE_HOME"); >+ if (!(home && *home)) this could be written: !home || !*home >Index: mozilla/xpcom/obsolete/nsSpecialSystemDirectory.cpp >diff -u -p -B -p -u -w -r1.9 nsSpecialSystemDirectory.cpp >@@ -748,6 +748,8 @@ void nsSpecialSystemDirectory::operator > *this = PR_GetEnv("HOME"); this is a trick piece of code, it's evil and magical and doesn't do what you think. don't change this file at all. >+ if (*this && !**this) >+ *this = nsnull; please post a new patch and have dougt check it in.
Attachment #194658 -
Flags: review?(timeless) → review-
Comment 11•19 years ago
|
||
Comment on attachment 194661 [details] [diff] [review] (Av1) <XpFe/*> (-Bw for review) this is fine, post a new patch and ask for sr?neil
Attachment #194661 -
Flags: review?(timeless) → review+
Reporter | ||
Comment 12•19 years ago
|
||
Av1, with comment 6 and 11 suggestion(s).
Attachment #194661 -
Attachment is obsolete: true
Attachment #202318 -
Flags: superreview?(neil.parkwaycc.co.uk)
Reporter | ||
Updated•19 years ago
|
Attachment #194658 -
Attachment is obsolete: true
Reporter | ||
Comment 13•19 years ago
|
||
Bv1, with comment 10 suggestion(s). Doug, can you check it in on my behalf ? Thanks.
Attachment #194656 -
Attachment is obsolete: true
Updated•19 years ago
|
Attachment #202318 -
Flags: superreview?(neil.parkwaycc.co.uk) → superreview+
Reporter | ||
Comment 14•19 years ago
|
||
Av2-Bw, but with full diff for checkin.
Attachment #202318 -
Attachment is obsolete: true
Reporter | ||
Updated•19 years ago
|
Attachment #202426 -
Attachment description: (Av2) <XpFe/*> → (Av2) <XpFe/*> [Wrong file]
Attachment #202426 -
Attachment is obsolete: true
Reporter | ||
Updated•19 years ago
|
Attachment #202426 -
Attachment is patch: false
Reporter | ||
Comment 15•19 years ago
|
||
Av2-Bw, but with full diff for checkin.
Reporter | ||
Comment 16•19 years ago
|
||
Comment on attachment 202427 [details] [diff] [review] (Av2) <XpFe/*> [Checked in: Comment 16] Check in: { 2005-12-22 09:57 bugzilla%standard8.demon.co.uk }
Attachment #202427 -
Attachment description: (Av2) <XpFe/*> → (Av2) <XpFe/*>
[Checked in: Comment 16]
Attachment #202427 -
Attachment is obsolete: true
Reporter | ||
Updated•19 years ago
|
Attachment #202324 -
Flags: review?(timeless)
Comment 17•18 years ago
|
||
checked in patch bv2: Checking in xpcom/ds/nsTimelineService.cpp; /cvsroot/mozilla/xpcom/ds/nsTimelineService.cpp,v <-- nsTimelineService.cpp new revision: 3.17; previous revision: 3.16 done Checking in xpcom/io/nsAppFileLocationProvider.cpp; /cvsroot/mozilla/xpcom/io/nsAppFileLocationProvider.cpp,v <-- nsAppFileLocationProvider.cpp new revision: 1.58; previous revision: 1.57 done Checking in xpcom/io/nsDirectoryService.cpp; /cvsroot/mozilla/xpcom/io/nsDirectoryService.cpp,v <-- nsDirectoryService.cpp new revision: 1.87; previous revision: 1.86 done Checking in xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp; /cvsroot/mozilla/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp,v <-- xptiInterfaceInfoManager.cpp new revision: 1.56; previous revision: 1.55 done Checking in xpcom/threads/nsEnvironment.cpp; /cvsroot/mozilla/xpcom/threads/nsEnvironment.cpp,v <-- nsEnvironment.cpp new revision: 1.3; previous revision: 1.2 done
(In reply to comment #0) > the proper way to > use PR_GetEnv involves: > > const char* foo = PR_GetEnv("BAR"); > (foo && *foo) Why can't we make PR_GetEnv be consistent across platforms and avoid this mess?
Reporter | ||
Comment 19•18 years ago
|
||
Comment on attachment 202324 [details] [diff] [review] (Bv2) <XpCom/*> [Checkin: See comment 17+19] Comment 17 checkin missed the <nsAtomTable.cpp> file, which had become in conflict.
Attachment #202324 -
Attachment description: (Bv2) <XpCom/*> → (Bv2) <XpCom/*>
[Checkin: See comment 19]
Attachment #202324 -
Attachment is obsolete: true
Attachment #202324 -
Flags: review?(timeless)
Reporter | ||
Comment 20•18 years ago
|
||
Reporter | ||
Comment 21•18 years ago
|
||
Comment on attachment 202324 [details] [diff] [review] (Bv2) <XpCom/*> [Checkin: See comment 17+19] Keeping {{ (Av1) <XpFe/*> (-Bw for review) patch 2005-09-02 08:05 PST 4.08 KB timeless: review+ (Av2) <XpFe/*> (-Bw for review) patch 2005-11-08 16:39 PST 3.80 KB neil: superreview+ }}
Attachment #202324 -
Flags: superreview+
Attachment #202324 -
Flags: review+
Reporter | ||
Updated•18 years ago
|
Attachment #202324 -
Flags: superreview+
Attachment #202324 -
Flags: review+
Reporter | ||
Comment 22•18 years ago
|
||
Comment on attachment 202427 [details] [diff] [review] (Av2) <XpFe/*> [Checked in: Comment 16] Keeping {{ (Av1) <XpFe/*> (-Bw for review) patch 2005-09-02 08:05 PST 4.08 KB timeless: review+ (Av2) <XpFe/*> (-Bw for review) patch 2005-11-08 16:39 PST 3.80 KB neil: superreview+ }}
Attachment #202427 -
Flags: superreview+
Attachment #202427 -
Flags: review+
Comment 23•18 years ago
|
||
PR_GetEnv is designed not to limit your ability to distinguish things that the underlying os allows. one thiing it does do is guarantee that there's only one clibrary mucking w/ the env block so all your answers will be coherent. restricting the ability of the client to distinguish things is not usually something nspr goes for. and i certainly don't want to ask nspr to change its behaviors and limit other clients.
Reporter | ||
Comment 24•18 years ago
|
||
(In reply to comment #23) > PR_GetEnv is designed not to limit your ability to distinguish things that the > underlying os allows. Just a thought/question from an "outsider": Would adding another function like "PR_GetEnv2()" which would call PR_GetEnv() and filter out the null-string case, that clients/callers could decide to use or not, be acceptable, or is it not the NSPR way either ? If not good for NSPR, would it make sense to add something like a "Gecko_GetEnv()" function ?? (Or should we simply keep it the way it is currently ?)
Reporter | ||
Updated•15 years ago
|
Attachment #202427 -
Attachment is obsolete: false
Reporter | ||
Updated•15 years ago
|
Attachment #202324 -
Attachment description: (Bv2) <XpCom/*>
[Checkin: See comment 19] → (Bv2) <XpCom/*>
[Checkin: See comment 17+19]
Attachment #202324 -
Attachment is obsolete: false
Reporter | ||
Comment 25•15 years ago
|
||
Cv1, without the whitespace cleanups, and "hg"... Keeping {{ (Av1) <XpFe/*> (-Bw for review) patch 2005-09-02 08:05 PST 4.08 KB timeless: review+ (Av2) <XpFe/*> (-Bw for review) patch 2005-11-08 16:39 PST 3.80 KB neil: superreview+ }}
Attachment #215578 -
Attachment is obsolete: true
Attachment #379354 -
Flags: superreview+
Attachment #379354 -
Flags: review+
Reporter | ||
Updated•15 years ago
|
Keywords: checkin-needed
Whiteboard: [c-n: Cv1a to cvs/1.9.0]
Reporter | ||
Updated•15 years ago
|
Whiteboard: [c-n: Cv1a to cvs/1.9.0] → [c-n: Cv1a to m-c after m-1.9.1 freeze]
Reporter | ||
Comment 26•15 years ago
|
||
Comment on attachment 379354 [details] [diff] [review] (Cv1a) <XpCom/nsAtomTable.cpp> (= sync'ed Bv2) [Checkin: Comment 26] http://hg.mozilla.org/mozilla-central/rev/6012e6d2b1fa
Attachment #379354 -
Attachment description: (Cv1a) <XpCom/nsAtomTable.cpp> (= sync'ed Bv2) → (Cv1a) <XpCom/nsAtomTable.cpp> (= sync'ed Bv2)
[Checkin: Comment 26]
Reporter | ||
Updated•15 years ago
|
Keywords: checkin-needed
Whiteboard: [c-n: Cv1a to m-c after m-1.9.1 freeze]
Reporter | ||
Comment 27•15 years ago
|
||
(In reply to comment #24) > Would adding another function like "PR_GetEnv2()" which would call PR_GetEnv() > and filter out the null-string case, that clients/callers could decide to use > or not, be acceptable, or is it not the NSPR way either ? I filed bug 497667.
Comment 28•15 years ago
|
||
(In reply to comment #18) > Why can't we make PR_GetEnv be consistent across platforms and avoid this > mess? Q: On what platform is the environment defined such that variables cannot have empty string values? Not on Windows, MacOSX or (my) Linux. So where? Seems to me the problem is that there's some code, somewhere, that was written by coders who believe that setting an environment variable to an empty string unsets it. The change that Timeless advocated in this bug is a concession to that belief, attempting to make Firefox behave consistently as if that is true. Maybe what's really needed is to find and fix all the places that call putenv("VAR=") thinking that will unset $VAR, because *that* is the practice that is inconsistent across platforms.
Reporter | ||
Comment 29•15 years ago
|
||
(In reply to comment #28) > Q: On what platform is the environment defined such that variables cannot > have empty string values? Not on Windows, MacOSX or (my) Linux. So where? (I would have replied "Windows, as in |set var=| command line removes the var from the env", but maybe you're referring to something else.) > Maybe what's really needed is to find and fix all the places that call > putenv("VAR=") thinking that will unset $VAR, because *that* is the practice > that is inconsistent across platforms. If the cause is within Mozilla code only, then that would probably be the best way to solve it. But I would have thought we could be dealing with vars set externally, which the only solution for would then be bug 497667.
Comment 30•15 years ago
|
||
(In reply to comment #29) > (I would have replied "Windows, as in |set var=| command line removes the var > from the env", but maybe you're referring to something else.) Ah. That's apparently a limitation of the set command in Windows' command line interpreter. That's distinct from the behavior of the libc functions in the process.
Product: SeaMonkey → Core
QA Contact: general → general
Comment 31•5 years ago
|
||
Closing as no activity for 10 years...
Feel free to reopen if you disagree
Assignee: bugzillamozillaorg_serge_20140323 → nobody
Status: ASSIGNED → RESOLVED
Type: defect → task
Closed: 5 years ago
Resolution: --- → INACTIVE
You need to log in
before you can comment on or make changes to this bug.
Description
•