[anjuta] libanjuta: Fix a bug when the first token of a merge is a compound token
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] libanjuta: Fix a bug when the first token of a merge is a compound token
- Date: Sat, 5 Nov 2011 20:58:00 +0000 (UTC)
commit 3ddb9bb24e99d0e7578695915fa4b1cb3df75876
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sat Nov 5 17:52:21 2011 +0100
libanjuta: Fix a bug when the first token of a merge is a compound token
libanjuta/anjuta-token.c | 24 ++++++++++++++++++------
libanjuta/tests/anjuta-token-test.c | 9 +++++++++
2 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/libanjuta/anjuta-token.c b/libanjuta/anjuta-token.c
index 7d08480..457c0b0 100644
--- a/libanjuta/anjuta-token.c
+++ b/libanjuta/anjuta-token.c
@@ -989,18 +989,30 @@ anjuta_token_delete_parent (AnjutaToken *parent)
/* Merge function
*---------------------------------------------------------------------------*/
+/* anjuta_token_merge can be used with first or end being a floating token and
+ * on already grouped tokens to change the group organisation */
AnjutaToken *
anjuta_token_merge (AnjutaToken *first, AnjutaToken *end)
{
+ AnjutaToken *next;
+
if ((first == end) || (end == NULL)) return first;
- if (first->parent == NULL)
- {
- first->parent = end->parent;
- }
- if (first->next == NULL)
+ /* Insert first or end in the same sequence if it is not already the case */
+ for (next = first; next != end; next = anjuta_token_next (next))
{
- anjuta_token_insert_before (end, first);
+ if (next == NULL)
+ {
+ if (first->parent == NULL)
+ {
+ anjuta_token_insert_before (end, first);
+ }
+ else
+ {
+ anjuta_token_insert_after (first, end);
+ }
+ break;
+ }
}
first->last = end;
if ((end->group != NULL) && (end->group != first) && (end->group->last == end)) end->group->last = first;
diff --git a/libanjuta/tests/anjuta-token-test.c b/libanjuta/tests/anjuta-token-test.c
index 48b116f..9b9832a 100644
--- a/libanjuta/tests/anjuta-token-test.c
+++ b/libanjuta/tests/anjuta-token-test.c
@@ -193,5 +193,14 @@ main(int argc, char *argv[])
fprintf(stdout, "%s %d\n", value, ok);
g_free (value);
+ // Check bug in anjuta_token_merge
+ list = anjuta_token_new_static (ANJUTA_TOKEN_NAME, "tip");
+ anjuta_token_merge (list, anjuta_token_new_static (ANJUTA_TOKEN_NAME, "tup"));
+ anjuta_token_merge (list, anjuta_token_new_static (ANJUTA_TOKEN_NAME, "tap"));
+ value = anjuta_token_evaluate_name (list);
+ ok = ok && (strcmp(value, "tiptuptap") == 0);
+ fprintf(stdout, "%s %d\n", value, ok);
+ g_free (value);
+
return ok ? 0 : 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]