* c-typeprint.c (c_type_print_base, TYPE_FN_FIELD_STUB code):
authorJim Kingdon <jkingdon@engr.sgi.com>
Thu, 30 Sep 1993 22:14:03 +0000 (22:14 +0000)
committerJim Kingdon <jkingdon@engr.sgi.com>
Thu, 30 Sep 1993 22:14:03 +0000 (22:14 +0000)
If demangled name lacks a colon, don't dump core.

gdb/c-typeprint.c

index c51e6078b012541c2452836ccfe8a431f85cce19..fa4035b00ac872762c2cf19db9cbf789c2a92706 100644 (file)
@@ -680,15 +680,24 @@ c_type_print_base (type, stream, show, level)
                      /* Build something we can demangle.  */
                      mangled_name = gdb_mangle_name (type, i, j);
                      demangled_name =
-                         cplus_demangle (mangled_name,
-                                         DMGL_ANSI | DMGL_PARAMS);
+                       cplus_demangle (mangled_name,
+                                       DMGL_ANSI | DMGL_PARAMS);
                      if (demangled_name == NULL)
                        fprintf_filtered (stream, "<badly mangled name %s>",
-                           mangled_name);
-                     else 
+                                         mangled_name);
+                     else
                        {
-                         fprintf_filtered (stream, "%s",
-                             strchr (demangled_name, ':') + 2);
+                         char *demangled_no_class =
+                           strchr (demangled_name, ':');
+
+                         if (demangled_no_class == NULL)
+                           demangled_no_class = demangled_name;
+                         else
+                           {
+                             if (*++demangled_no_class == ':')
+                               ++demangled_no_class;
+                           }
+                         fputs_filtered (demangled_no_class, stream);
                          free (demangled_name);
                        }
                      free (mangled_name);