From a8d98187a58df95a5c10ff8fd487becd6bc81ac6 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 27 Jul 2018 17:44:09 +0200 Subject: [PATCH] Revert "allow utf-8 variables names in Python dump" Needs a more in depth analysis... This reverts commit 50b5fac2a8a05b472f332ac1f84ec38c7f305cb5. --- src/SMESH_I/SMESH_PythonDump.cxx | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/SMESH_I/SMESH_PythonDump.cxx b/src/SMESH_I/SMESH_PythonDump.cxx index 0204a498a..e4dfed32c 100644 --- a/src/SMESH_I/SMESH_PythonDump.cxx +++ b/src/SMESH_I/SMESH_PythonDump.cxx @@ -884,25 +884,25 @@ namespace { bool isValidName = true; int nbUnderscore = 0; int p; -// // replace not allowed chars by underscore -// const char* name = aName.ToCString(); -// for ( p = 0; name[p]; ++p ) { -// if ( !isalnum( name[p] ) && name[p] != '_' ) -// { -// if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_') -// { -// aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end -// --p; -// name = aName.ToCString(); -// } -// else -// { -// aName.SetValue( p+1, '_'); -// nbUnderscore++; -// } -// isValidName = false; -// } -// } + // replace not allowed chars by underscore + const char* name = aName.ToCString(); + for ( p = 0; name[p]; ++p ) { + if ( !isalnum( name[p] ) && name[p] != '_' ) + { + if ( p == 0 || p+1 == aName.Length() || name[p-1] == '_') + { + aName.Remove( p+1, 1 ); // remove __ and _ from the start and the end + --p; + name = aName.ToCString(); + } + else + { + aName.SetValue( p+1, '_'); + nbUnderscore++; + } + isValidName = false; + } + } // aName must not start with a digit if ( aName.IsIntegerValue() ) { aName.Insert( 1, 'a' ); -- 2.30.2