From e6452400a0d3c3bb6fc0e8dfc54c1958253cf6dc Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Fri, 8 Feb 2002 23:59:49 +0000 Subject: [PATCH] Fix recently-uncovered ECMA violation: lastIndex must use double storage (124339, r=rogerl, sr=shaver). git-svn-id: svn://10.0.0.236/trunk@114095 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsregexp.c | 12 ++++++------ mozilla/js/src/jsregexp.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mozilla/js/src/jsregexp.c b/mozilla/js/src/jsregexp.c index fb4f74f469d..48cbf8e9eba 100644 --- a/mozilla/js/src/jsregexp.c +++ b/mozilla/js/src/jsregexp.c @@ -1227,10 +1227,10 @@ js_NewRegExp(JSContext *cx, JSTokenStream *ts, if (!re) goto out; re->nrefs = 1; - re->source = str; - re->lastIndex = 0; re->parenCount = state.parenCount; re->flags = flags; + re->lastIndex = 0; + re->source = str; #ifdef JS_THREADSAFE re->owningThread = 0; re->lastIndexes = NULL; @@ -1247,14 +1247,14 @@ out: typedef struct LastIndexEntry { JSDHashEntryHdr hdr; jsword thread; - uintN index; + double index; } LastIndexEntry; #endif /* * NB: Get and SetLastIndex must be called with re's owning object locked. */ -static uintN +static double GetLastIndex(JSContext *cx, JSRegExp *re) { #ifdef JS_THREADSAFE @@ -1279,7 +1279,7 @@ GetLastIndex(JSContext *cx, JSRegExp *re) } static JSBool -SetLastIndex(JSContext *cx, JSRegExp *re, uintN lastIndex) +SetLastIndex(JSContext *cx, JSRegExp *re, double lastIndex) { #ifdef JS_THREADSAFE if (!re->owningThread) { @@ -2440,7 +2440,7 @@ regexp_setProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) JS_LOCK_OBJ(cx, obj); re = (JSRegExp *) JS_GetInstancePrivate(cx, obj, &js_RegExpClass, NULL); if (re) - ok = SetLastIndex(cx, re, (uintN)d); + ok = SetLastIndex(cx, re, d); JS_UNLOCK_OBJ(cx, obj); } return ok; diff --git a/mozilla/js/src/jsregexp.h b/mozilla/js/src/jsregexp.h index 7914ab6c353..18fd6e1ce2a 100644 --- a/mozilla/js/src/jsregexp.h +++ b/mozilla/js/src/jsregexp.h @@ -73,14 +73,14 @@ typedef struct RENode RENode; struct JSRegExp { jsrefcount nrefs; /* reference count */ - JSString *source; /* locked source string, sans // */ - uintN lastIndex; /* number of parenthesized submatches */ - uint32 parenCount:24, /* index after last match, for //g iterator */ + uint32 parenCount:24, /* number of parenthesized submatches */ flags:8; /* flags, see jsapi.h's JSREG_* defines */ + double lastIndex; /* index after last match, for //g iterator */ RENode *ren; /* regular expression tree root */ -#ifdef JS_THREADSAFE - jsword owningThread; /* not quite right if someone intentionally */ - JSDHashTable *lastIndexes; /* passes a regexp from thread A to B */ + JSString *source; /* locked source string, sans // */ +#ifdef JS_THREADSAFE /* extension: lastIndex is thread-specific */ + jsword owningThread; /* (not quite right if someone intentionally */ + JSDHashTable *lastIndexes; /* passes a regexp from thread A to B) */ #endif };