Revision: 1146 http://svn.sourceforge.net/geany/?rev=1146&view=rev Author: ntrel Date: 2006-12-26 07:43:50 -0800 (Tue, 26 Dec 2006)
Log Message: ----------- Fix missed matches in tm_tags_find().
Modified Paths: -------------- trunk/ChangeLog trunk/tagmanager/include/tm_tag.h trunk/tagmanager/tm_tag.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-12-24 12:32:52 UTC (rev 1145) +++ trunk/ChangeLog 2006-12-26 15:43:50 UTC (rev 1146) @@ -1,3 +1,9 @@ +2006-12-26 Nick Treleaven nick.treleaven@btinternet.com + + * tagmanager/tm_tag.c, tagmanager/include/tm_tag.h: + Fix missed matches in tm_tags_find(). + + 2006-12-24 Nick Treleaven nick.treleaven@btinternet.com
* src/utils.c, src/sci_cb.c:
Modified: trunk/tagmanager/include/tm_tag.h =================================================================== --- trunk/tagmanager/include/tm_tag.h 2006-12-24 12:32:52 UTC (rev 1145) +++ trunk/tagmanager/include/tm_tag.h 2006-12-26 15:43:50 UTC (rev 1146) @@ -281,7 +281,8 @@ \param name Name of the tag to locate. \param partial If TRUE, matches the first part of the name instead of doing exact match. */ -TMTag **tm_tags_find(GPtrArray *sorted_tags_array, const char *name, gboolean partial, int * tagCount); +TMTag **tm_tags_find(const GPtrArray *sorted_tags_array, const char *name, + gboolean partial, int * tagCount);
/*! Completely frees an array of tags.
Modified: trunk/tagmanager/tm_tag.c =================================================================== --- trunk/tagmanager/tm_tag.c 2006-12-24 12:32:52 UTC (rev 1145) +++ trunk/tagmanager/tm_tag.c 2006-12-26 15:43:50 UTC (rev 1146) @@ -562,7 +562,8 @@ } }
-TMTag **tm_tags_find(GPtrArray *sorted_tags_array, const char *name, gboolean partial, int * tagCount) +TMTag **tm_tags_find(const GPtrArray *sorted_tags_array, const char *name, + gboolean partial, int * tagCount) { static TMTag *tag = NULL; TMTag **result; @@ -578,15 +579,30 @@ s_partial = partial; result = (TMTag **) bsearch(&tag, sorted_tags_array->pdata, sorted_tags_array->len , sizeof(gpointer), tm_tag_compare); + // there can be matches on both sides of result if (result) { - for (; result >= (TMTag **) sorted_tags_array->pdata; -- result) { + TMTag **last = (TMTag **) &sorted_tags_array->pdata[sorted_tags_array->len - 1]; + TMTag **adv; + + // First look for any matches after result + adv = result; + adv++; + for (; *adv && adv <= last; ++ adv) + { + if (0 != tm_tag_compare(&tag, adv)) + break; + ++tagMatches; + } + // Now look for matches from result and below + for (; result >= (TMTag **) sorted_tags_array->pdata; -- result) + { if (0 != tm_tag_compare(&tag, (TMTag **) result)) break; ++tagMatches; } *tagCount=tagMatches; - ++ result; + ++ result; // correct address for the last successful match } s_partial = FALSE; return (TMTag **) result;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.