Bug 312154, Start script does not take care of running instance on solaris sparc. benjamin: first-review+ Patch by leon.sha@sun.com, a=dveditz

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@187053 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2006-01-06 03:19:48 +00:00
parent 519bc2b25c
commit e6c1d92a5e
2 changed files with 24 additions and 8 deletions

View File

@@ -81,6 +81,14 @@
#define MOZILLA_PROGRAM_PROP "_MOZILLA_PROGRAM"
#define MOZILLA_COMMANDLINE_PROP "_MOZILLA_COMMANDLINE"
#ifdef IS_BIG_ENDIAN
#define TO_LITTLE_ENDIAN32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#else
#define TO_LITTLE_ENDIAN32(x) (x)
#endif
#ifdef MOZ_XUL_APP
const unsigned char kRemoteVersion[] = "5.1";
#else
@@ -340,7 +348,7 @@ nsGTKRemoteService::HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow)
// [argc][offsetargv0][offsetargv1...]<workingdir>\0<argv[0]>\0argv[1]...\0
// (offset is from the beginning of the buffer)
PRInt32 argc = *NS_REINTERPRET_CAST(PRInt32*, aBuffer);
PRInt32 argc = TO_LITTLE_ENDIAN32(*NS_REINTERPRET_CAST(PRInt32*, aBuffer));
char *wd = aBuffer + ((argc + 1) * sizeof(PRInt32));
#ifdef DEBUG_bsmedberg
@@ -362,7 +370,7 @@ nsGTKRemoteService::HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow)
PRInt32 *offset = NS_REINTERPRET_CAST(PRInt32*, aBuffer) + 1;
for (int i = 0; i < argc; ++i) {
argv[i] = aBuffer + offset[i];
argv[i] = aBuffer + TO_LITTLE_ENDIAN32(offset[i]);
#ifdef DEBUG_bsmedberg
printf(" argv[%i]:\t%s\n", i, argv[i]);
@@ -474,7 +482,7 @@ nsGTKRemoteService::HandlePropertyChange(GtkWidget *aWidget,
return FALSE;
// Failed to get the data off the window or it was the wrong type?
if (!data || !*data)
if (!data || !TO_LITTLE_ENDIAN32(*NS_REINTERPRET_CAST(PRInt32*, data)))
return FALSE;
// cool, we got the property data.
@@ -519,7 +527,7 @@ nsGTKRemoteService::HandlePropertyChange(GtkWidget *aWidget,
return FALSE;
// Failed to get the data off the window or it was the wrong type?
if (!data || !*data)
if (!data || !TO_LITTLE_ENDIAN32(*NS_REINTERPRET_CAST(PRInt32*, data)))
return FALSE;
// cool, we got the property data.

View File

@@ -67,6 +67,14 @@
#define MOZILLA_PROFILE_PROP "_MOZILLA_PROFILE"
#define MOZILLA_PROGRAM_PROP "_MOZILLA_PROGRAM"
#ifdef IS_BIG_ENDIAN
#define TO_LITTLE_ENDIAN32(x) \
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#else
#define TO_LITTLE_ENDIAN32(x) (x)
#endif
#ifndef MAX_PATH
#define MAX_PATH 1024
#endif
@@ -691,19 +699,19 @@ XRemoteClient::DoSendCommandLine(Window aWindow, PRInt32 argc, char **argv,
if (!buffer)
return NS_ERROR_OUT_OF_MEMORY;
buffer[0] = argc;
buffer[0] = TO_LITTLE_ENDIAN32(argc);
char *bufend = (char*) (buffer + argc + 1);
bufend = estrcpy(cwdbuf, bufend);
for (int i = 0; i < argc; ++i) {
buffer[i + 1] = bufend - ((char*) buffer);
buffer[i + 1] = TO_LITTLE_ENDIAN32(bufend - ((char*) buffer));
bufend = estrcpy(argv[i], bufend);
}
#ifdef DEBUG_bsmedberg
PRInt32 debug_argc = *buffer;
PRInt32 debug_argc = TO_LITTLE_ENDIAN32(*buffer);
char *debug_workingdir = (char*) (buffer + argc + 1);
printf("Sending command line:\n"
@@ -715,7 +723,7 @@ XRemoteClient::DoSendCommandLine(Window aWindow, PRInt32 argc, char **argv,
PRInt32 *debug_offset = buffer + 1;
for (int debug_i = 0; debug_i < debug_argc; ++debug_i)
printf(" argv[%i]:\t%s\n", debug_i,
((char*) buffer) + debug_offset[debug_i]);
((char*) buffer) + TO_LITTLE_ENDIAN32(debug_offset[debug_i]));
#endif
XChangeProperty (mDisplay, aWindow, mMozCommandLineAtom, XA_STRING, 8,