Author: [EMAIL PROTECTED]
Date: Fri Oct 3 17:27:23 2008
New Revision: 3709
Modified:
changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp
changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp
Log:
Fix XMLTest failures -- the problem is that the native code for nsIDOMParser
(which implements DOMParser) appears to expect a null terminated string
even though JS strings are counted. Allocating one extra word, setting it
to zero, and not including that word in the string length appears to make
nsIDOMParser happy. Also minor improvement to debug output.
Modified: changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp (original)
+++ changes/jat/oophm-branch/plugins/xpcom/FFSessionHandler.cpp Fri Oct 3
17:27:23 2008
@@ -310,7 +310,8 @@
break;
}
}
- jschar* buf = static_cast<jschar*>(JS_malloc(ctx, len * sizeof(jschar)));
+ // account for null terminator even if it isn't included in the string
length
+ jschar* buf = static_cast<jschar*>(JS_malloc(ctx, (len + 1) *
sizeof(jschar)));
if (!buf) {
return NULL;
}
@@ -362,6 +363,10 @@
break;
}
}
+ // null terminator, apparently some code expects a terminator even though
+ // the strings are counted. Note that this null word should not be
included
+ // in the length.
+ *p = 0;
return JS_NewUCString(ctx, buf, p - buf);
}
Modified: changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp
==============================================================================
--- changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp (original)
+++ changes/jat/oophm-branch/plugins/xpcom/XpcomDebug.cpp Fri Oct 3
17:27:23 2008
@@ -20,7 +20,7 @@
#include "JavaObject.h"
std::string dumpJsVal(JSContext* ctx, jsval v) {
- char buf[30];
+ char buf[70];
if (v == JSVAL_VOID) {
strcpy(buf, "undef");
} else if (v == JSVAL_NULL) {
@@ -50,10 +50,14 @@
{
JSString* str = JSVAL_TO_STRING(v);
int len = JS_GetStringLength(str);
+ char* continued = "";
if (len > 20) {
len = 20;
+ continued = "...";
}
- snprintf(buf, sizeof(buf), "string(%.*s)", len,
JS_GetStringBytes(str));
+ // TODO: trashes Unicode
+ snprintf(buf, sizeof(buf), "string(%.*s%s)", len,
+ JS_GetStringBytes(str), continued);
break;
}
case JSVAL_BOOLEAN:
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---