зеркало из https://github.com/mozilla/pjs.git
Cleaning up PR_GetEnv() usage. b=306840. r=timeless, patch by serge gautherie
This commit is contained in:
Родитель
c7fdbeb1ba
Коммит
e4b1b62115
|
@ -226,6 +226,7 @@ PRStatus TimelineInit(void)
|
|||
{
|
||||
char *timeStr;
|
||||
char *fileName;
|
||||
const char *timelineEnable;
|
||||
PRInt32 secs, msecs;
|
||||
PRFileDesc *fd;
|
||||
PRInt64 tmp1, tmp2;
|
||||
|
@ -234,19 +235,19 @@ PRStatus TimelineInit(void)
|
|||
NS_WARN_IF_FALSE(status==0, "TimelineService could not allocate TLS storage.");
|
||||
|
||||
timeStr = PR_GetEnv("NS_TIMELINE_INIT_TIME");
|
||||
|
||||
// NS_TIMELINE_INIT_TIME only makes sense for the main thread, so if it
|
||||
// exists, set it there. If not, let normal thread management code take
|
||||
// care of setting the init time.
|
||||
if (timeStr != NULL && 2 == PR_sscanf(timeStr, "%d.%d", &secs, &msecs)) {
|
||||
if (timeStr && *timeStr && (2 == PR_sscanf(timeStr, "%d.%d", &secs, &msecs))) {
|
||||
PRTime &initTime = GetThisThreadData()->initTime;
|
||||
LL_MUL(tmp1, (PRInt64)secs, 1000000);
|
||||
LL_MUL(tmp2, (PRInt64)msecs, 1000);
|
||||
LL_ADD(initTime, tmp1, tmp2);
|
||||
}
|
||||
|
||||
// Get the log file.
|
||||
fileName = PR_GetEnv("NS_TIMELINE_LOG_FILE");
|
||||
if (fileName != NULL
|
||||
if (fileName && *fileName
|
||||
&& (fd = PR_Open(fileName, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
|
||||
0666)) != NULL) {
|
||||
timelineFD = fd;
|
||||
|
@ -256,7 +257,8 @@ PRStatus TimelineInit(void)
|
|||
}
|
||||
|
||||
// Runtime disable of timeline
|
||||
if (PR_GetEnv("NS_TIMELINE_ENABLE"))
|
||||
timelineEnable = PR_GetEnv("NS_TIMELINE_ENABLE");
|
||||
if (timelineEnable && *timelineEnable)
|
||||
gTimelineDisabled = PR_FALSE;
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile
|
|||
NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). "
|
||||
"Use nsAppFileLocationProvider::GetFiles(...).");
|
||||
const char *pathVar = PR_GetEnv("MOZ_PLUGIN_PATH");
|
||||
if (pathVar)
|
||||
if (pathVar && *pathVar)
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), PR_TRUE, getter_AddRefs(localFile));
|
||||
}
|
||||
else if (nsCRT::strcmp(prop, NS_USER_PLUGINS_DIR) == 0)
|
||||
|
|
|
@ -246,18 +246,18 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile)
|
|||
// regardless of the environment. This makes it easier to write apps that
|
||||
// embed mozilla without having to worry about setting up the environment
|
||||
//
|
||||
// We do this py putenv()ing the default value into the environment. Note that
|
||||
// We do this by putenv()ing the default value into the environment. Note that
|
||||
// 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)
|
||||
{
|
||||
putenv("MOZILLA_FIVE_HOME=" MOZ_DEFAULT_MOZILLA_FIVE_HOME);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME");
|
||||
|
||||
if (moz5)
|
||||
if (moz5 && *moz5)
|
||||
{
|
||||
if (realpath(moz5, buf)) {
|
||||
localFile->InitWithNativePath(nsDependentCString(buf));
|
||||
|
@ -268,7 +268,7 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile)
|
|||
#if defined(DEBUG)
|
||||
static PRBool firstWarning = PR_TRUE;
|
||||
|
||||
if(!moz5 && firstWarning) {
|
||||
if((!moz5 || !*moz5) && firstWarning) {
|
||||
// Warn that MOZILLA_FIVE_HOME not set, once.
|
||||
printf("Warning: MOZILLA_FIVE_HOME not set.\n");
|
||||
firstWarning = PR_FALSE;
|
||||
|
|
|
@ -126,7 +126,7 @@ xptiInterfaceInfoManager::xptiInterfaceInfoManager(nsISupportsArray* aSearchPath
|
|||
mSearchPath(aSearchPath)
|
||||
{
|
||||
const char* statsFilename = PR_GetEnv("MOZILLA_XPTI_STATS");
|
||||
if(statsFilename)
|
||||
if(statsFilename && *statsFilename)
|
||||
{
|
||||
mStatsLogFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
if(mStatsLogFile &&
|
||||
|
@ -142,7 +142,7 @@ xptiInterfaceInfoManager::xptiInterfaceInfoManager(nsISupportsArray* aSearchPath
|
|||
}
|
||||
|
||||
const char* autoRegFilename = PR_GetEnv("MOZILLA_XPTI_REGLOG");
|
||||
if(autoRegFilename)
|
||||
if(autoRegFilename && *autoRegFilename)
|
||||
{
|
||||
mAutoRegLogFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
if(mAutoRegLogFile &&
|
||||
|
|
|
@ -98,8 +98,7 @@ nsEnvironment::Exists(const nsAString& aName, PRBool *aOutValue)
|
|||
* An environment variable does not exist when |getenv()| returns NULL.
|
||||
*/
|
||||
const char *value = PR_GetEnv(nativeName.get());
|
||||
|
||||
*aOutValue = (value)?(PR_TRUE):(PR_FALSE);
|
||||
*aOutValue = value && *value;
|
||||
#else
|
||||
/* For non-Unix/Linux platforms we have to fall back to a
|
||||
* "portable" definition (which is incorrect for Unix/Linux!!!!)
|
||||
|
@ -108,7 +107,7 @@ nsEnvironment::Exists(const nsAString& aName, PRBool *aOutValue)
|
|||
*/
|
||||
nsAutoString value;
|
||||
Get(aName, value);
|
||||
*aOutValue = (value.IsEmpty())?(PR_FALSE):(PR_TRUE);
|
||||
*aOutValue = !value.IsEmpty();
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
return NS_OK;
|
||||
|
@ -123,7 +122,7 @@ nsEnvironment::Get(const nsAString& aName, nsAString& aOutValue)
|
|||
|
||||
nsCAutoString nativeVal;
|
||||
const char *value = PR_GetEnv(nativeName.get());
|
||||
if (value) {
|
||||
if (value && *value) {
|
||||
rv = NS_CopyNativeToUnicode(nsDependentCString(value), aOutValue);
|
||||
} else {
|
||||
aOutValue.Truncate();
|
||||
|
|
Загрузка…
Ссылка в новой задаче