From: "Erich E. Hoover" Subject: [PATCH 1/2] hhctrl.ocx: Turn multiple index entries of the same name into a single entry. Message-Id: Date: Tue, 26 Jun 2012 13:51:04 -0600 Some HTML Help files have several index entries with exactly the same name. The native behavior for these entries is to collapse all of the entries into one and cause the "Select Topic" dialog to appear upon choosing that entry (allowing the user to select the appropriate entry). The attached patch implements this feature for index entries of exactly the same name when they occur one after the other in the index (so if the entries are not in order then this code will not collapse the entries), thereby fixing Bug #31016. From 37ec8c616de1e1b71cbcf12a5d6f313390570347 Mon Sep 17 00:00:00 2001 From: Erich Hoover Date: Mon, 25 Jun 2012 13:46:26 -0600 Subject: hhctrl.ocx: Turn multiple index entries of the same name into a single entry. --- dlls/hhctrl.ocx/index.c | 33 ++++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 9 deletions(-) diff --git a/dlls/hhctrl.ocx/index.c b/dlls/hhctrl.ocx/index.c index 2cc79a6..af1efb8 100644 --- a/dlls/hhctrl.ocx/index.c +++ b/dlls/hhctrl.ocx/index.c @@ -54,6 +54,15 @@ static void fill_index_tree(HWND hwnd, IndexItem *item) } } +static void item_realloc(IndexItem *item, int num_items) +{ + item->nItems = num_items; + item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems); + item->items[item->nItems-1].name = NULL; + item->items[item->nItems-1].local = NULL; + item->itemFlags = 0x00; +} + /* Parse the attributes correspond to a list item, including sub-topics. * * Each list item has, at minimum, a param of type "keyword" and two @@ -77,13 +86,8 @@ static void parse_index_obj_node_param(IndexItem *item, const char *text, UINT c /* Allocate a new sub-item, either on the first run or whenever a * sub-topic has filled out both the "name" and "local" params. */ - if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) { - item->nItems++; - item->items = heap_realloc(item->items, sizeof(IndexSubItem)*item->nItems); - item->items[item->nItems-1].name = NULL; - item->items[item->nItems-1].local = NULL; - item->itemFlags = 0x00; - } + if(item->itemFlags == 0x11 && (!strncasecmp("name", ptr, len) || !strncasecmp("local", ptr, len))) + item_realloc(item, item->nItems+1); if(!strncasecmp("keyword", ptr, len)) { param = &item->keyword; }else if(!item->keyword && !strncasecmp("name", ptr, len)) { @@ -228,8 +232,19 @@ static void parse_hhindex(HHInfo *info, IStream *str, IndexItem *item) TRACE("%s\n", node.buf); if(!strcasecmp(node_name.buf, "li")) { - item->next = parse_li(info, &stream); - if(item->next) { + IndexItem *new_item; + + new_item = parse_li(info, &stream); + if(new_item && item->keyword && strcmpW(new_item->keyword, item->keyword) == 0) { + int num_items = item->nItems; + + item_realloc(item, num_items+1); + memcpy(&item->items[num_items], &new_item->items[0], sizeof(IndexSubItem)); + heap_free(new_item->keyword); + heap_free(new_item->items); + heap_free(new_item); + } else if(new_item) { + item->next = new_item; item->next->merge = item->merge; item = item->next; item->indentLevel = indent_level; -- 1.7.5.4