static void end_element (GMarkupParseContext *context, const gchar *element_name, gpointer user_data, GError **error) { TextTableParseInfo *info = user_data; pop_attribute_value (&info->gettext_domain); pop_attribute_value (&info->schema_id); pop_attribute_value (&info->key_name); if (info->string) { GHashTable *source_table = NULL; const gchar *gettext_domain; const gchar *schema_id; const gchar *key_name; gettext_domain = get_attribute_value (info->gettext_domain); schema_id = get_attribute_value (info->schema_id); key_name = get_attribute_value (info->key_name); if (g_str_equal (element_name, "summary")) source_table = info->summaries; else if (g_str_equal (element_name, "description")) source_table = info->descriptions; if (source_table && schema_id && key_name) { GHashTable *schema_table; gchar *normalised; schema_table = g_hash_table_lookup (source_table, schema_id); if (schema_table == NULL) { schema_table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); g_hash_table_insert (source_table, g_strdup (schema_id), schema_table); } normalised = normalise_whitespace (info->string->str); if (gettext_domain) { gchar *translated; translated = g_strdup (g_dgettext (gettext_domain, normalised)); g_free (normalised); normalised = translated; } g_hash_table_insert (schema_table, g_strdup (key_name), normalised); } g_string_free (info->string, TRUE); info->string = NULL; } }
char * demangle(const char *sym) { #ifdef HAVE_LIBBFD string_var dem = cplus_demangle(sym, DMGL_ANSI|DMGL_PARAMS); return (dem == 0 ? g_strdup(sym) : normalise_whitespace(dem)); #else return g_strdup(sym); #endif }
char * normalise_mangled(const char *sym) { #ifdef HAVE_LIBBFD string_var buf = sym; int func_count = 0; char *p; p = (char *)buf.data() + strlen(buf.data()) - 1; if (strchr(buf.data(), LEFT_BRACKET) == 0) return buf.take(); /* not mangled */ /* * Use a simple state machine to strip off the return type. * It's simple (rather than trivial) to handle return types * which are pointers to functions. */ do { while (p > buf.data() && isspace(*p)) p--; if (*p == RIGHT_BRACKET) { int bracket_count = 0; do { switch (*p--) { case LEFT_BRACKET: bracket_count--; break; case RIGHT_BRACKET: bracket_count++; break; } } while (p > buf.data() && bracket_count > 0); } while (p > buf.data() && isspace(*p)) p--; if (*p == RIGHT_BRACKET) { *p-- = '\0'; func_count++; } else if (*p == LEFT_BRACKET) { *p = ' '; --func_count; } else { while (p > buf.data() && issym(*p)) p--; if (p > buf.data() && (*p == '*' || *p == '&')) *p-- = ' '; } } while (func_count); /* * At this point `p' points to (some whitespace before) * the symbol with the return type stripped. Now normalise * the whitespace. */ buf = normalise_whitespace(p); /* * The C++ main routine is mangled as just "main". */ if (!strcmp(buf, "main(int,char**)") || !strcmp(buf, "main(int,char**,char**)")) buf = "main"; return buf.take(); #else return g_strdup(sym); #endif }