File tree Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Expand file tree Collapse file tree 3 files changed +24
-21
lines changed Original file line number Diff line number Diff line change @@ -227,9 +227,8 @@ pub fn sanitize(s: &str) -> String {
227227 match c {
228228 // Escape these with $ sequences
229229 '@' => result. push_str ( "$SP$" ) ,
230- '~' => result. push_str ( "$UP$" ) ,
231- '*' => result. push_str ( "$RP$" ) ,
232- '&' => result. push_str ( "$BP$" ) ,
230+ '*' => result. push_str ( "$BP$" ) ,
231+ '&' => result. push_str ( "$RF$" ) ,
233232 '<' => result. push_str ( "$LT$" ) ,
234233 '>' => result. push_str ( "$GT$" ) ,
235234 '(' => result. push_str ( "$LP$" ) ,
@@ -247,10 +246,14 @@ pub fn sanitize(s: &str) -> String {
247246 | '_' | '.' | '$' => result. push ( c) ,
248247
249248 _ => {
250- let mut tstr = String :: new ( ) ;
251- for c in c. escape_unicode ( ) { tstr. push ( c) }
252249 result. push ( '$' ) ;
253- result. push_str ( & tstr[ 1 ..] ) ;
250+ for c in c. escape_unicode ( ) . skip ( 1 ) {
251+ match c {
252+ '{' => { } ,
253+ '}' => result. push ( '$' ) ,
254+ c => result. push ( c) ,
255+ }
256+ }
254257 }
255258 }
256259 }
Original file line number Diff line number Diff line change @@ -57,22 +57,22 @@ mod test {
5757
5858 #[ test]
5959 fn demangle_dollars ( ) {
60- t ! ( "_ZN4$UP $E" , "Box " ) ;
61- t ! ( "_ZN8$UP $testE" , "Boxtest " ) ;
62- t ! ( "_ZN8$UP $test4foobE" , "Boxtest ::foob" ) ;
63- t ! ( "_ZN10$u{20} test4foobE" , " test::foob" ) ;
60+ t ! ( "_ZN4$RP $E" , ") " ) ;
61+ t ! ( "_ZN8$RF $testE" , "&test " ) ;
62+ t ! ( "_ZN8$BP $test4foobE" , "*test ::foob" ) ;
63+ t ! ( "_ZN9$u20$ test4foobE" , " test::foob" ) ;
6464 }
6565
6666 #[ test]
6767 fn demangle_many_dollars ( ) {
68- t ! ( "_ZN14test$u{20} test4foobE" , "test test::foob" ) ;
69- t ! ( "_ZN12test$UP $test4foobE" , "testBoxtest ::foob" ) ;
68+ t ! ( "_ZN13test$u20$ test4foobE" , "test test::foob" ) ;
69+ t ! ( "_ZN12test$BP $test4foobE" , "test*test ::foob" ) ;
7070 }
7171
7272 #[ test]
7373 fn demangle_windows ( ) {
7474 t ! ( "ZN4testE" , "test" ) ;
75- t ! ( "ZN14test$u{20} test4foobE" , "test test::foob" ) ;
76- t ! ( "ZN12test$UP $test4foobE" , "testBoxtest ::foob" ) ;
75+ t ! ( "ZN13test$u20$ test4foobE" , "test test::foob" ) ;
76+ t ! ( "ZN12test$RF $test4foobE" , "test&test ::foob" ) ;
7777 }
7878}
Original file line number Diff line number Diff line change @@ -107,9 +107,8 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
107107 // see src/librustc/back/link.rs for these mappings
108108 demangle ! (
109109 "$SP$" , => "@" ,
110- "$UP$" , => "Box" ,
111- "$RP$" , => "*" ,
112- "$BP$" , => "&" ,
110+ "$BP$" , => "*" ,
111+ "$RF$" , => "&" ,
113112 "$LT$" , => "<" ,
114113 "$GT$" , => ">" ,
115114 "$LP$" , => "(" ,
@@ -118,10 +117,11 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
118117
119118 // in theory we can demangle any Unicode code point, but
120119 // for simplicity we just catch the common ones.
121- "$u{20}" , => " " ,
122- "$u{27}" , => "'" ,
123- "$u{5b}" , => "[" ,
124- "$u{5d}" , => "]"
120+ "$u7e$" , => "~" ,
121+ "$u20$" , => " " ,
122+ "$u27$" , => "'" ,
123+ "$u5b$" , => "[" ,
124+ "$u5d$" , => "]"
125125 )
126126 } else {
127127 let idx = match rest. find ( '$' ) {
You can’t perform that action at this time.
0 commit comments