summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-02-21 21:34:55 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-02-21 21:34:55 (GMT)
commita60e1fe19d09eb379c88fdbbe018ca086dc05bcb (patch)
treee72fa012a465517fe3b2f728d750b008ba88d707 /src
parent0769fafb253b846b58cd97c4a1df98ca7417ae1c (diff)
Cut symbol labels using words instead of single characters.
Diffstat (limited to 'src')
-rw-r--r--src/common/extstr.c46
-rw-r--r--src/common/extstr.h3
-rw-r--r--src/gui/panels/symbols.c38
3 files changed, 68 insertions, 19 deletions
diff --git a/src/common/extstr.c b/src/common/extstr.c
index bd561ba..83dcace 100644
--- a/src/common/extstr.c
+++ b/src/common/extstr.c
@@ -251,6 +251,52 @@ char *_strxxx(char *str, int (* fn) (int))
/******************************************************************************
* *
+* Paramètres : str = chaîne de caractères à traiter. [OUT] *
+* delim = mot de séparation entre les mots identifiés. *
+* *
+* Description : Extrait un mot d'une chaîne selon des séparations longues. *
+* *
+* Retour : Chaîne de caractères cernée ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+char *strtok_w(char **str, const char *delim)
+{
+ char *result;
+ char *haystack;
+ char *next;
+ const char *diter;
+
+ haystack = *str;
+
+ if (haystack == NULL)
+ result = NULL;
+
+ else
+ {
+ result = haystack;
+
+ next = strstr(haystack, delim);
+
+ if (next != NULL)
+ {
+ for (diter = delim; *diter; diter++, next++)
+ *next = '\0';
+ }
+
+ *str = next;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : str = chaîne de caractères à traiter. *
* delim = séparateur entre les mots. *
* count = nombre de mots trouvés. [OUT] *
diff --git a/src/common/extstr.h b/src/common/extstr.h
index f803129..d5bbee6 100644
--- a/src/common/extstr.h
+++ b/src/common/extstr.h
@@ -52,6 +52,9 @@ char *_strxxx(char *, int (* fn) (int));
#define strlower(str) _strxxx(str, tolower)
#define strupper(str) _strxxx(str, toupper)
+/* Extrait un mot d'une chaîne selon des séparations longues. */
+char *strtok_w(char **, const char *);
+
/* Extrait une liste de mots d'une chaîne. */
char **strtoka(const char *, const char *, size_t *);
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index 6b0b999..d1e60fc 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -39,6 +39,7 @@
#include "panel-int.h"
#include "updating-int.h"
#include "../core/global.h"
+#include "../../common/extstr.h"
#include "../../format/format.h"
#include "../../format/symiter.h"
#include "../../gtkext/easygtk.h"
@@ -56,6 +57,7 @@ struct _GSymbolsPanel
GPanelItem parent; /* A laisser en premier */
GLoadedBinary *binary; /* Binaire à prendre en compte */
+ const char *sep; /* Délimitateur à utiliser */
size_t count; /* Quantité de symboles utiles */
@@ -164,7 +166,7 @@ static gboolean show_all_classes_in_tree_view(GtkTreeModel *, GtkTreePath *, Gtk
static GtkTreeIter update_symbol_partial_name_in_tree_view(GtkTreeStore *, GtkTreeIter *, const char *, const regmatch_t *, size_t);
/* Met en surbrillance les éléments recherchés dans les noms. */
-static void update_symbol_name_in_tree_view(GtkTreeStore *, const GBinSymbol *, const regmatch_t *);
+static void update_symbol_name_in_tree_view(const GSymbolsPanel *, GtkTreeStore *, const GBinSymbol *, const regmatch_t *);
@@ -655,8 +657,13 @@ static void change_symbols_panel_current_binary(GSymbolsPanel *panel, GLoadedBin
/* Si le panneau actif représente un binaire, actualisation de l'affichage */
if (binary != NULL)
+ {
+ panel->sep = "."/*"::"*/; /* FIXME */
+
run_panel_update(G_UPDATABLE_PANEL(panel), PUI_0);
+ }
+
}
@@ -941,10 +948,8 @@ static bool find_parent_for_symbol(const GSymbolsPanel *panel, const GBinSymbol
bool result; /* Bilan à retourner */
const char *label; /* Etiquette immuable */
char *string; /* Etiquette modifiable */
- const char *sep; /* Délimitateur à utiliser */
char *start; /* Début de boucle de parcours */
char *token; /* Partie de texte isolée */
- char *saveptr; /* Ctx. interne de découpage */
char *next; /* Prochaine partie à traiter */
result = false;
@@ -956,18 +961,16 @@ static bool find_parent_for_symbol(const GSymbolsPanel *panel, const GBinSymbol
string = strdup(label);
- sep = "."/*"::"*/; /* FIXME */
-
- for (start = string, token = strtok_r(start, sep, &saveptr); ; start = NULL, token = next)
+ for (start = string, token = strtok_w(&start, panel->sep); ; token = next)
{
- next = strtok_r(NULL, sep, &saveptr);
+ next = strtok_w(&start, panel->sep);
if (next == NULL)
{
*last = (token - string);
break;
}
- *parent = ensure_symbol_node_exist(panel, (start == string ? NULL : parent), token, match, token - string);
+ *parent = ensure_symbol_node_exist(panel, (token == string ? NULL : parent), token, match, token - string);
result = true;
@@ -1245,9 +1248,10 @@ static GtkTreeIter update_symbol_partial_name_in_tree_view(GtkTreeStore *store,
/******************************************************************************
* *
-* Paramètres : store = gestionnaire de données en arborescence. *
+* Paramètres : panel = panneau à mettre à jour. *
+* store = gestionnaire de données en arborescence. *
* symbol = routine ou objet à intégrer. *
-* match = portion de texte à mettre en évidence. *
+* match = portion de texte à mettre en évidence. *
* *
* Description : Met en surbrillance les éléments recherchés dans les noms. *
* *
@@ -1257,15 +1261,13 @@ static GtkTreeIter update_symbol_partial_name_in_tree_view(GtkTreeStore *store,
* *
******************************************************************************/
-static void update_symbol_name_in_tree_view(GtkTreeStore *store, const GBinSymbol *symbol, const regmatch_t *match)
+static void update_symbol_name_in_tree_view(const GSymbolsPanel *panel, GtkTreeStore *store, const GBinSymbol *symbol, const regmatch_t *match)
{
const char *label; /* Etiquette immuable */
char *string; /* Etiquette modifiable */
- const char *sep; /* Délimitateur à utiliser */
GtkTreeIter parent; /* Point d'analyse courant */
char *start; /* Début de boucle de parcours */
char *token; /* Partie de texte isolée */
- char *saveptr; /* Ctx. interne de découpage */
label = g_binary_symbol_get_label(symbol);
@@ -1273,13 +1275,11 @@ static void update_symbol_name_in_tree_view(GtkTreeStore *store, const GBinSymbo
{
string = strdup(label);
- sep = "."/*"::"*/; /* FIXME */
-
- for (start = string, token = strtok_r(start, sep, &saveptr);
+ for (start = string, token = strtok_w(&start, panel->sep);
token != NULL;
- start = NULL, token = strtok_r(NULL, sep, &saveptr))
+ token = strtok_w(&start, panel->sep))
{
- parent = update_symbol_partial_name_in_tree_view(store, (start == string ? NULL : &parent),
+ parent = update_symbol_partial_name_in_tree_view(store, (token == string ? NULL : &parent),
token, match, token - string);
}
@@ -1429,7 +1429,7 @@ static void do_filtering_on_symbols(const GSymbolsPanel *panel, GtkStatusStack *
if (*as_list)
update_symbol_name_in_list_view(store, iter, &match);
else
- update_symbol_name_in_tree_view(store, symbol, &match);
+ update_symbol_name_in_tree_view(panel, store, symbol, &match);
if (!shown)
update_symbol_visibility(store, iter, true);