Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handle comments at the beginning of code SERVER-398

  • Loading branch information...
commit 8af511ef9b8fab64893960b776b3682de6fb7932 1 parent 62ff89a
@erh erh authored
Showing with 19 additions and 0 deletions.
  1. +9 −0 jstests/evala.js
  2. +10 −0 scripting/engine.cpp
View
9 jstests/evala.js
@@ -0,0 +1,9 @@
+
+t = db.evala;
+t.drop()
+
+t.save( { x : 5 } )
+
+assert.eq( 5 , db.eval( "function(){ return db.evala.findOne().x; }" ) , "A" );
+assert.eq( 5 , db.eval( "/* abc */function(){ return db.evala.findOne().x; }" ) , "B" );
+
View
10 scripting/engine.cpp
@@ -149,6 +149,16 @@ namespace mongo {
}
ScriptingFunction Scope::createFunction( const char * code ){
+ if ( code[0] == '/' && code [1] == '*' ){
+ code += 2;
+ while ( code[0] && code[1] ){
+ if ( code[0] == '*' && code[1] == '/' ){
+ code += 2;
+ break;
+ }
+ code++;
+ }
+ }
map<string,ScriptingFunction>::iterator i = _cachedFunctions.find( code );
if ( i != _cachedFunctions.end() )
return i->second;
Please sign in to comment.
Something went wrong with that request. Please try again.