Salome HOME
0020217: EDF SMESH: Dump file with mesh and group on geom is wrong
authoreap <eap@opencascade.com>
Mon, 16 Mar 2009 07:56:53 +0000 (07:56 +0000)
committereap <eap@opencascade.com>
Mon, 16 Mar 2009 07:56:53 +0000 (07:56 +0000)
    fix _pyCommand::GetWord() for case of names with white spaces inside

src/SMESH_I/SMESH_2smeshpy.cxx

index 157e0f41cac3c1a5a519ab9facf82be40a33a905..aca8d4165299574b4204fe6c7c44352a27786965 100644 (file)
@@ -1841,9 +1841,18 @@ TCollection_AsciiString _pyCommand::GetWord( const TCollection_AsciiString & the
       return theEmptyString; // no word found
     // end
     end = beg + 1;
-    while ( end <= theString.Length() && isWord( theString.Value( end ), dotIsWord))
-      ++end;
-    --end;
+    char begChar = theString.Value( beg );
+    if ( begChar == '"' || begChar == '\'' ) {
+      // end is at the corresponding quoting mark
+      while ( end < theString.Length() &&
+              ( theString.Value( end ) != begChar || theString.Value( end-1 ) == '\\'))
+        ++end;
+    }
+    else {
+      while ( end <= theString.Length() && isWord( theString.Value( end ), dotIsWord))
+        ++end;
+      --end;
+    }
   }
   else {  // search backward
     // end
@@ -1852,9 +1861,18 @@ TCollection_AsciiString _pyCommand::GetWord( const TCollection_AsciiString & the
     if ( end == 0 )
       return theEmptyString; // no word found
     beg = end - 1;
-    while ( beg > 0 && isWord( theString.Value( beg ), dotIsWord))
-      --beg;
-    ++beg;
+    char endChar = theString.Value( end );
+    if ( endChar == '"' || endChar == '\'' ) {
+      // beg is at the corresponding quoting mark
+      while ( beg > 1 &&
+              ( theString.Value( beg ) != endChar || theString.Value( beg-1 ) == '\\'))
+        --beg;
+    }
+    else {
+      while ( beg > 0 && isWord( theString.Value( beg ), dotIsWord))
+        --beg;
+      ++beg;
+    }
   }
   theStartPos = beg;
   //cout << theString << " ---- " << beg << " - " << end << endl;