summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-11-29 01:50:57 -0500
committerEliot Horowitz <eliot@10gen.com>2010-11-29 01:50:57 -0500
commit4e51d779c611fb9bef4671a01c917cd9c8bf197a (patch)
tree1552496f0fd0604b44f75dfcadfa6c52dfd2c1d6 /scripting
parent4da350d1f6704d15e2e3596ee706af85e1990efb (diff)
downloadmongo-4e51d779c611fb9bef4671a01c917cd9c8bf197a.tar.gz
fix comment parsing in v8
Diffstat (limited to 'scripting')
-rw-r--r--scripting/engine.cpp15
-rw-r--r--scripting/engine.h2
-rw-r--r--scripting/engine_spidermonkey.cpp12
-rw-r--r--scripting/engine_v8.cpp2
4 files changed, 19 insertions, 12 deletions
diff --git a/scripting/engine.cpp b/scripting/engine.cpp
index ae67b469029..a28cff2983b 100644
--- a/scripting/engine.cpp
+++ b/scripting/engine.cpp
@@ -457,5 +457,20 @@ namespace mongo {
( x == 0 || ! isalpha( code[x-1] ) ) &&
! isalpha( code[x+6] );
}
+
+ const char * jsSkipWhiteSpace( const char * raw ){
+ while ( raw[0] ){
+ while (isspace(*raw)) {
+ raw++;
+ }
+
+ if ( raw[0] != '/' || raw[1] != '/' )
+ break;
+
+ while ( raw[0] && raw[0] != '\n' )
+ raw++;
+ }
+ return raw;
+ }
}
diff --git a/scripting/engine.h b/scripting/engine.h
index e9ffd98caba..5b5c480ce77 100644
--- a/scripting/engine.h
+++ b/scripting/engine.h
@@ -234,5 +234,7 @@ namespace mongo {
bool hasJSReturn( const string& s );
+ const char * jsSkipWhiteSpace( const char * raw );
+
extern ScriptEngine * globalScriptEngine;
}
diff --git a/scripting/engine_spidermonkey.cpp b/scripting/engine_spidermonkey.cpp
index 3c5ed2b155b..f39d9d4f19c 100644
--- a/scripting/engine_spidermonkey.cpp
+++ b/scripting/engine_spidermonkey.cpp
@@ -427,18 +427,8 @@ namespace mongo {
JSFunction * _compileFunction( const char * raw , JSObject * assoc , const char *& gcName ){
if ( ! assoc )
assoc = JS_GetGlobalObject( _context );
-
- while ( raw[0] ){
- while (isspace(*raw)) {
- raw++;
- }
- if ( raw[0] != '/' || raw[1] != '/' )
- break;
-
- while ( raw[0] && raw[0] != '\n' )
- raw++;
- }
+ raw = jsSkipWhiteSpace( raw );
//cout << "RAW\n---\n" << raw << "\n---" << endl;
diff --git a/scripting/engine_v8.cpp b/scripting/engine_v8.cpp
index b883a45ca42..cb32f7c24cf 100644
--- a/scripting/engine_v8.cpp
+++ b/scripting/engine_v8.cpp
@@ -258,7 +258,7 @@ namespace mongo {
}
Local< v8::Function > V8Scope::__createFunction( const char * raw ){
- for(; isspace( *raw ); ++raw ); // skip whitespace
+ raw = jsSkipWhiteSpace( raw );
string code = raw;
if ( !hasFunctionIdentifier( code ) ) {
if ( code.find( "\n" ) == string::npos &&