diff options
author | Aaron <aaron@10gen.com> | 2010-10-04 14:44:11 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-10-04 14:44:42 -0700 |
commit | 92a5d51100a5b45d06ffafe38af7de43e6502915 (patch) | |
tree | 2313823d96fdf8bb9221a3abf033f6790b7de05c /scripting | |
parent | 9d00c0c7e9d6cf5b04a4a6dc19b9827651170016 (diff) | |
download | mongo-92a5d51100a5b45d06ffafe38af7de43e6502915.tar.gz |
SERVER-1840 make eval function construction logic in v8 more consistent with sm
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/engine_v8.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/scripting/engine_v8.cpp b/scripting/engine_v8.cpp index 92312008af4..b883a45ca42 100644 --- a/scripting/engine_v8.cpp +++ b/scripting/engine_v8.cpp @@ -250,10 +250,17 @@ namespace mongo { // --- functions ----- + bool hasFunctionIdentifier( const string& code ){ + if ( code.size() < 9 || code.find( "function" ) != 0 ) + return false; + + return code[8] == ' ' || code[8] == '('; + } + Local< v8::Function > V8Scope::__createFunction( const char * raw ){ for(; isspace( *raw ); ++raw ); // skip whitespace string code = raw; - if ( code.find( "function" ) == string::npos ){ + if ( !hasFunctionIdentifier( code ) ) { if ( code.find( "\n" ) == string::npos && ! hasJSReturn( code ) && ( code.find( ";" ) == string::npos || code.find( ";" ) == code.size() - 1 ) ){ |