0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

fix comment parsing in v8

This commit is contained in:
Eliot Horowitz 2010-11-29 01:50:57 -05:00
parent 4da350d1f6
commit 4e51d779c6
4 changed files with 19 additions and 12 deletions

View File

@ -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;
}
}

View File

@ -234,5 +234,7 @@ namespace mongo {
bool hasJSReturn( const string& s );
const char * jsSkipWhiteSpace( const char * raw );
extern ScriptEngine * globalScriptEngine;
}

View File

@ -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;

View File

@ -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 &&