File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed
Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -921,25 +921,37 @@ string make_cname(string name)
921921 if ( name == "" )
922922 return "" ;
923923
924- string [ ] bits = Regex . Split ( name , @"[\W]+" ) ;
924+ Regex splitter = new Regex ( @"[\W]+" ) ;
925925
926- string output = "" ;
926+ //string[] bits = Regex.Split(name,@"[\W]+");
927+ var bits = splitter . Split ( name ) . Where ( s => s != String . Empty ) ;
927928
928-
929+ string output = "" ;
929930
930931 char lastchar = ' ' ;
931932 foreach ( string s in bits )
932933 {
933934 if ( Char . IsUpper ( lastchar ) && Char . IsUpper ( s . First ( ) ) )
934935 output += "_" ;
935936
936- output += char . ToUpper ( s [ 0 ] ) + s . Substring ( 1 ) ;
937+ if ( s . Length > 1 )
938+ {
939+ output += char . ToUpper ( s [ 0 ] ) + s . Substring ( 1 ) ;
940+ }
941+ else
942+ {
943+ output += output . ToUpper ( ) ;
944+ }
945+
946+ if ( output . Length > 0 )
947+ lastchar = output . Last ( ) ;
937948
938- lastchar = output . Last ( ) ;
939949 }
940950
941- if ( Char . IsLower ( output [ 1 ] ) )
951+ if ( output . Length > 1 && Char . IsLower ( output [ 1 ] ) )
942952 output = Char . ToLower ( output [ 0 ] ) + output . Substring ( 1 ) ;
953+ else
954+ output = output . ToLower ( ) ; //single character
943955
944956 return output ;
945957 }
You can’t perform that action at this time.
0 commit comments