about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-04-19 05:41:26 -0700
committerbors <bors@rust-lang.org>2014-04-19 05:41:26 -0700
commitba25fecfeffdbc96d31172f483bd20cffa635b3e (patch)
tree59d1698aeef428fe08a75e020b2fe46c343f809a /src/libstd/rt
parent2c22ae4378d5f9fc32e2f234121ea98db86201df (diff)
parent55310acbca84abfbb3636440a849a2e77d03992c (diff)
downloadrust-ba25fecfeffdbc96d31172f483bd20cffa635b3e.tar.gz
rust-ba25fecfeffdbc96d31172f483bd20cffa635b3e.zip
auto merge of #13615 : alexcrichton/rust/improve-demangling, r=brson
Previously, symbols with rust escape sequences (denoted with dollar signs)
weren't demangled if the escape sequence showed up in the middle. This alters
the printing loop to look through the entire string for dollar characters.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/backtrace.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs
index bf8c15c20ab..c3bf7a6d12a 100644
--- a/src/libstd/rt/backtrace.rs
+++ b/src/libstd/rt/backtrace.rs
@@ -109,7 +109,7 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
             let i: uint = from_str(s.slice_to(s.len() - rest.len())).unwrap();
             s = rest.slice_from(i);
             rest = rest.slice_to(i);
-            loop {
+            while rest.len() > 0 {
                 if rest.starts_with("$") {
                     macro_rules! demangle(
                         ($($pat:expr => $demangled:expr),*) => ({
@@ -144,8 +144,12 @@ fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
                         "$x5d" => "]"
                     )
                 } else {
-                    try!(writer.write_str(rest));
-                    break;
+                    let idx = match rest.find('$') {
+                        None => rest.len(),
+                        Some(i) => i,
+                    };
+                    try!(writer.write_str(rest.slice_to(idx)));
+                    rest = rest.slice_from(idx);
                 }
             }
         }
@@ -774,4 +778,10 @@ mod test {
         t!("_ZN8$UP$test4foobE", "~test::foob");
         t!("_ZN8$x20test4foobE", " test::foob");
     }
+
+    #[test]
+    fn demangle_many_dollars() {
+        t!("_ZN12test$x20test4foobE", "test test::foob");
+        t!("_ZN12test$UP$test4foobE", "test~test::foob");
+    }
 }