File tree 3 files changed +24
-21
lines changed
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 {
227
227
match c {
228
228
// Escape these with $ sequences
229
229
'@' => 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$" ) ,
233
232
'<' => result. push_str ( "$LT$" ) ,
234
233
'>' => result. push_str ( "$GT$" ) ,
235
234
'(' => result. push_str ( "$LP$" ) ,
@@ -247,10 +246,14 @@ pub fn sanitize(s: &str) -> String {
247
246
| '_' | '.' | '$' => result. push ( c) ,
248
247
249
248
_ => {
250
- let mut tstr = String :: new ( ) ;
251
- for c in c. escape_unicode ( ) { tstr. push ( c) }
252
249
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
+ }
254
257
}
255
258
}
256
259
}
Original file line number Diff line number Diff line change @@ -57,22 +57,22 @@ mod test {
57
57
58
58
#[ test]
59
59
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" ) ;
64
64
}
65
65
66
66
#[ test]
67
67
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" ) ;
70
70
}
71
71
72
72
#[ test]
73
73
fn demangle_windows ( ) {
74
74
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" ) ;
77
77
}
78
78
}
Original file line number Diff line number Diff line change @@ -107,9 +107,8 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
107
107
// see src/librustc/back/link.rs for these mappings
108
108
demangle ! (
109
109
"$SP$" , => "@" ,
110
- "$UP$" , => "Box" ,
111
- "$RP$" , => "*" ,
112
- "$BP$" , => "&" ,
110
+ "$BP$" , => "*" ,
111
+ "$RF$" , => "&" ,
113
112
"$LT$" , => "<" ,
114
113
"$GT$" , => ">" ,
115
114
"$LP$" , => "(" ,
@@ -118,10 +117,11 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
118
117
119
118
// in theory we can demangle any Unicode code point, but
120
119
// 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$" , => "]"
125
125
)
126
126
} else {
127
127
let idx = match rest. find ( '$' ) {
You can’t perform that action at this time.
0 commit comments