From: akl Date: Fri, 5 Dec 2008 09:11:29 +0000 (+0000) Subject: To correct parsing of commands like object.command(obj, 'str=value'), X-Git-Tag: V5_1_0rc2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1dfc797eaf54b3cca566b5849d6d924c03e840ff;p=modules%2Fsmesh.git To correct parsing of commands like object.command(obj, 'str=value'), when '=' character takes place between '' or "" symbols. --- diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index f3e8d5746..cc189fd64 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1714,8 +1714,22 @@ const TCollection_AsciiString & _pyCommand::GetObject() { // beginning int begPos = GetBegPos( RESULT_IND ) + myRes.Length(); - if ( begPos < 1 ) + if ( begPos < 1 ) { begPos = myString.Location( "=", 1, Length() ) + 1; + // is '=' in the string argument (for example, name) or not + int nb1 = 0; // number of ' character at the left of = + int nb2 = 0; // number of " character at the left of = + for ( int i = 1; i < begPos-1; i++ ) { + if ( IsEqual(myString.Value( i ), "'" ) ) + nb1 += 1; + else if ( IsEqual( myString.Value( i ), '"' ) ) + nb2 += 1; + } + // if number of ' or " is not divisible by 2, + // then get an object at the start of the command + if ( fmod( nb1, 2 ) != 0 || fmod( nb2, 2 ) != 0 ) + begPos = 1; + } // store myObj = GetWord( myString, begPos, true ); SetBegPos( OBJECT_IND, begPos );