summaryrefslogtreecommitdiff
path: root/plugins/lnxsyscalls
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-09-07 22:11:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-09-07 22:11:49 (GMT)
commitf663a08007095e58f60fcf9a815a8b3d31b87c83 (patch)
tree80da49384da78cb9f1b7f81e23e638e5d1dc054e /plugins/lnxsyscalls
parent39ceed9ed4e4484919f9eecc35d0b51372e5a233 (diff)
Rewritten some code managing comments.
Diffstat (limited to 'plugins/lnxsyscalls')
-rw-r--r--plugins/lnxsyscalls/writer.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/plugins/lnxsyscalls/writer.c b/plugins/lnxsyscalls/writer.c
index 743e5c6..0b90d68 100644
--- a/plugins/lnxsyscalls/writer.c
+++ b/plugins/lnxsyscalls/writer.c
@@ -29,6 +29,7 @@
#include <analysis/db/items/comment.h>
+#include <common/extstr.h>
@@ -196,43 +197,60 @@ void write_all_comments(comment_writer *writer, GPreloadInfo *preload)
{
size_t i; /* Boucle de parcours #1 */
comment_data *target; /* Commentaire à éditer */
- GDbComment *comment; /* Commentaire final à intégrer*/
- bool new; /* Nature du commentaire */
+ char *text; /* Texte du commentaire complet*/
size_t k; /* Boucle de parcours #2 */
+ size_t index; /* Indice d'un existant ? */
+ GDbComment *comment; /* Commentaire final à intégrer*/
for (i = 0; i < writer->count; i++)
{
target = &writer->comments[i];
- g_preload_info_lock_comments(preload);
+ /* Construction de la nouveauté */
- comment = _g_preload_info_find_comment_at(preload, &target->addr);
+ text = NULL;
+
+ for (k = 0; k < target->count; k++)
+ {
+ if (k > 0)
+ text = stradd(text, " / ");
- new = (comment == NULL);
+ text = stradd(text, target->text[k]);
+
+ }
+
+ /* Inclusion de l'existant */
+
+ g_preload_info_lock_comments(preload);
+
+ comment = g_preload_info_find_comment_at(preload, &target->addr, &index);
if (comment == NULL)
{
- comment = g_db_comment_new_inlined(&target->addr, BLF_HAS_CODE, false);
+ comment = g_db_comment_new(&target->addr, CET_INLINED, BLF_HAS_CODE, text);
g_db_item_add_flag(G_DB_ITEM(comment), DIF_VOLATILE);
- g_object_ref(G_OBJECT(comment));
-
_g_preload_info_add_comment(preload, comment);
}
- g_preload_info_unlock_comments(preload);
-
- for (k = 0; k < target->count; k++)
+ else
{
- if (k > 0 || !new)
- g_db_comment_add_static_text(comment, " / ");
+ text = strprep(text, " / ");
+ text = strprep(text, g_db_comment_get_text(comment));
- g_db_comment_add_dynamic_text(comment, strdup(target->text[k]));
+ g_object_unref(G_OBJECT(comment));
+
+ comment = g_db_comment_new(&target->addr, CET_INLINED, BLF_HAS_CODE, text);
+ g_db_item_add_flag(G_DB_ITEM(comment), DIF_VOLATILE);
+
+ g_preload_info_replace_comment_at(preload, index, comment);
}
- g_object_unref(G_OBJECT(comment));
+ g_preload_info_unlock_comments(preload);
+
+ free(text);
}