From d8032f4248023bd3eb3eb7a2f7a8977bc89d82d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 3 Jul 2008 12:32:55 +0000 Subject: [PATCH] Fix unnecessary 40 character limit for auto-closing XML tags (closes #2007278). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2743 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 7 +++++++ src/utils.c | 16 ++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index e44f8fea..264d4770 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-07-03 Enrico Tröger + + * src/utils.c: + Fix unnecessary 40 character limit for auto-closing XML tags + (closes #2007278). + + 2008-07-02 Nick Treleaven * src/keybindings.c: diff --git a/src/utils.c b/src/utils.c index cf66d3eb..6d1bcf35 100644 --- a/src/utils.c +++ b/src/utils.c @@ -249,15 +249,12 @@ gint utils_write_file(const gchar *filename, const gchar *text) */ gchar *utils_find_open_xml_tag(const gchar sel[], gint size, gboolean check_tag) { - /* 40 chars per tag should be enough, or not? */ - gint i = 0, max_tag_size = 40; - gchar *result = g_malloc(max_tag_size); + GString *result = g_string_sized_new(64); const gchar *begin, *cur; if (size < 3) - { - /* Smallest tag is "

" which is 3 characters */ - return result; + { /* Smallest tag is "

" which is 3 characters */ + return NULL; } begin = &sel[0]; if (check_tag) @@ -276,16 +273,15 @@ gchar *utils_find_open_xml_tag(const gchar sel[], gint size, gboolean check_tag) if (*cur == '<') { cur++; - while((strchr(":_-.", *cur) || isalnum(*cur)) && i < (max_tag_size - 1)) + while((strchr(":_-.", *cur) || isalnum(*cur))) { - result[i++] = *cur; + g_string_append_c(result, *cur); cur++; } } - result[i] = '\0'; /* Return the tag name or "" */ - return result; + return g_string_free(result, FALSE); }