--- jsfile.c 2006/07/24 19:53:01 1.6
+++ jsfile.c 2006/07/26 07:15:59 1.7
@@ -807,7 +807,11 @@
/* Buffered version of PR_Read. Used by js_FileRead */
static int32
+#ifdef OSSP
+js_BufferedRead(JSFile * f, unsigned char *buf, int32 len)
+#else
js_BufferedRead(JSFile * f, char *buf, int32 len)
+#endif
{
int32 count = 0;
@@ -901,7 +905,11 @@
break;
case UCS2:
+#ifdef OSSP
+ count = js_BufferedRead(file, (unsigned char*)buf, len*2) >> 1;
+#else
count = js_BufferedRead(file, (char*)buf, len*2) >> 1;
+#endif
if (count == -1)
return 0;
@@ -2259,8 +2267,15 @@
file_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval*rval)
{
JSFile *file = JS_GetInstancePrivate(cx, obj, &file_class, NULL);
+#ifdef OSSP
+ JSString *str;
+ if ((str = JS_NewStringCopyZ(cx, file->path)) == NULL)
+ return JS_FALSE;
+ *rval = STRING_TO_JSVAL(str);
+#else
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, file->path));
+#endif
return JS_TRUE;
}
@@ -2270,6 +2285,10 @@
JSFile *file = JS_GetInstancePrivate(cx, obj, &file_class, NULL);
char url[MAX_PATH_LENGTH];
jschar *urlChars;
+#ifdef OSSP
+ size_t len;
+ JSString *str;
+#endif
JSFILE_CHECK_NATIVE("toURL");
@@ -2277,12 +2296,14 @@
/* TODO: js_escape in jsstr.h may go away at some point */
#ifdef OSSP /* BUGFIX */
-{
- size_t len = strlen(url);
- urlChars = js_InflateString(cx, url, &len);
- if (urlChars == NULL) return JS_FALSE;
- *rval = STRING_TO_JSVAL(js_NewString(cx, urlChars, len, 0));
-}
+ len = strlen(url);
+ if ((urlChars = js_InflateString(cx, url, &len)) == NULL)
+ return JS_FALSE;
+ if ((str = js_NewString(cx, urlChars, len, 0)) == NULL) {
+ JS_free(cx, urlChars);
+ return JS_FALSE;
+ }
+ *rval = STRING_TO_JSVAL(str);
#else
urlChars = js_InflateString(cx, url, strlen(url));
if (urlChars == NULL) return JS_FALSE;
|