From 7a6c773df8f3df361a6267f6ca491b133684179e Mon Sep 17 00:00:00 2001 From: "sdagley%netscape.com" Date: Fri, 9 Jul 1999 04:03:51 +0000 Subject: [PATCH] Part deux of the fix for #8491. Had to add the ability to externally re-init NSPR's log feature as we were reading the environemnt vars on the Mac after the initial init. Reviewed saari. --- nsprpub/pr/include/prlog.h | 6 ++++++ nsprpub/pr/src/io/prlog.c | 9 +++++++++ xpfe/appshell/src/nsCommandLineServiceMac.cpp | 11 +++++++++-- .../startup/src/nsCommandLineServiceMac.cpp | 11 +++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/nsprpub/pr/include/prlog.h b/nsprpub/pr/include/prlog.h index 50d4aba7e8d..d8e82d51166 100644 --- a/nsprpub/pr/include/prlog.h +++ b/nsprpub/pr/include/prlog.h @@ -170,6 +170,12 @@ PR_EXTERN(void) PR_LogPrint(const char *fmt, ...); */ PR_EXTERN(void) PR_LogFlush(void); +/* Need external access to this on Mac so we can first set up our faux environment vars */ +#ifdef XP_MAC +PR_EXTERN(void) PR_Init_Log(void); +#endif + + /* ** Windoze 16 can't support a large static string space for all of the ** various debugging strings so logging is not enabled for it. diff --git a/nsprpub/pr/src/io/prlog.c b/nsprpub/pr/src/io/prlog.c index 6d7e4e166b0..24dbfddee45 100644 --- a/nsprpub/pr/src/io/prlog.c +++ b/nsprpub/pr/src/io/prlog.c @@ -481,3 +481,12 @@ PR_IMPLEMENT(void) PR_Assert(const char *s, const char *file, PRIntn ln) #endif #endif /* PR_LOGGING */ } + +#ifdef XP_MAC +PR_IMPLEMENT(void) PR_Init_Log(void) +{ +#ifdef PR_LOGGING + _PR_InitLog(); +#endif +} +#endif diff --git a/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/xpfe/appshell/src/nsCommandLineServiceMac.cpp index 8ad74468a86..e3e39d87c11 100644 --- a/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -45,6 +45,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "prmem.h" #include "plstr.h" #include "prenv.h" +#include "prlog.h" // Universal #include @@ -512,6 +513,7 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil if (s.is_open()) { Boolean foundArgs = false; + Boolean foundEnv = false; char chars[1024]; const char* kCommandLinePrefix = "ARGS:"; const char* kEnvVarLinePrefix = "ENV:"; @@ -527,7 +529,7 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil else if (PL_strstr(chars, kEnvVarLinePrefix) == chars) { (void)AddToEnvironmentVars(chars + PL_strlen(kEnvVarLinePrefix)); - foundArgs = true; + foundEnv = true; } // Clear the buffer and get the next line from the command line file @@ -535,9 +537,14 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil s.readline(chars, sizeof(chars)); } while (PL_strlen(chars)); + // If we found any environment vars we need to re-init NSPR's logging + // so that it knows what the new vars are + if (foundEnv) + PR_Init_Log(); + // If we found a command line or environment vars we want to return now // raather than trying to open the file as a URL - if (foundArgs) + if (foundArgs || foundEnv) return noErr; } } diff --git a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index 8ad74468a86..e3e39d87c11 100644 --- a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -45,6 +45,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "prmem.h" #include "plstr.h" #include "prenv.h" +#include "prlog.h" // Universal #include @@ -512,6 +513,7 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil if (s.is_open()) { Boolean foundArgs = false; + Boolean foundEnv = false; char chars[1024]; const char* kCommandLinePrefix = "ARGS:"; const char* kEnvVarLinePrefix = "ENV:"; @@ -527,7 +529,7 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil else if (PL_strstr(chars, kEnvVarLinePrefix) == chars) { (void)AddToEnvironmentVars(chars + PL_strlen(kEnvVarLinePrefix)); - foundArgs = true; + foundEnv = true; } // Clear the buffer and get the next line from the command line file @@ -535,9 +537,14 @@ OSErr nsAppleEventHandler::HandleOpen1Doc(const FSSpec& inFileSpec, OSType inFil s.readline(chars, sizeof(chars)); } while (PL_strlen(chars)); + // If we found any environment vars we need to re-init NSPR's logging + // so that it knows what the new vars are + if (foundEnv) + PR_Init_Log(); + // If we found a command line or environment vars we want to return now // raather than trying to open the file as a URL - if (foundArgs) + if (foundArgs || foundEnv) return noErr; } }