[PATCH 17/45] [WinHelp]: implement macros as link target

Eric Pouech eric.pouech at orange.fr
Sun Mar 23 04:18:56 CDT 2008




A+
---

 programs/winhelp/hlpfile.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)


diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c
index bc297d9..194fed0 100644
--- a/programs/winhelp/hlpfile.c
+++ b/programs/winhelp/hlpfile.c
@@ -878,21 +878,22 @@ static BOOL HLPFILE_SkipParagraph(HLPFILE *hlpfile, BYTE *buf, BYTE *end, unsign
 }
 
 static HLPFILE_LINK*    alloc_link(struct RtfData* rd, int cookie,
-                                   const char* string, unsigned long hash,
+                                   const char* string, int len, unsigned long hash,
                                    int window)
 {
     HLPFILE_LINK*       link;
     char*               where;
-
+    if (len == -1) len = strlen(string);
     /* FIXME: should build a string table for the lpszPath,
      * they are reallocated for each link
      */
-    link = HeapAlloc(GetProcessHeap(), 0, sizeof(HLPFILE_LINK) + strlen(string) + 1);
+    link = HeapAlloc(GetProcessHeap(), 0, sizeof(HLPFILE_LINK) + len + 1);
     if (!link) return NULL;
 
     link->cookie     = cookie;
     link->string     = where = (char*)(link + 1);
-    strcpy(where, string);
+    memcpy(where, string, len);
+    where[len] = '\0';
     link->hash       = hash;
     link->window     = window;
     link->next       = rd->first_link;
@@ -1130,9 +1131,6 @@ BOOL HLPFILE_BrowseParagraph(HLPFILE *hlpfile, struct RtfData* rd, BYTE *buf, BY
                 break;
 
 	    case 0x89:
-                if (!rd->current_link)
-                    WINE_FIXME("No existing link\n");
-                else
                 rd->current_link->cpMax = rd->char_pos;
                 rd->current_link = NULL;
                 rd->force_color = FALSE;
@@ -1154,6 +1152,9 @@ BOOL HLPFILE_BrowseParagraph(HLPFILE *hlpfile, struct RtfData* rd, BYTE *buf, BY
             case 0xC8:
             case 0xCC:
                 WINE_TRACE("macro => %s\n", format + 3);
+                alloc_link(rd, hlp_link_macro,
+                           (char*)format + 3, GET_USHORT(format, 1), 0, -1);
+                rd->force_color = !(*format & 4);
                 format += 3 + GET_USHORT(format, 1);
                 break;
 
@@ -1169,7 +1170,7 @@ BOOL HLPFILE_BrowseParagraph(HLPFILE *hlpfile, struct RtfData* rd, BYTE *buf, BY
             case 0xE6:
             case 0xE7:
                 alloc_link(rd, (*format & 1) ? hlp_link_link : hlp_link_popup,
-                           hlpfile->lpszPath, GET_UINT(format, 1), -1);
+                           hlpfile->lpszPath, -1, GET_UINT(format, 1), -1);
                 rd->force_color = !(*format & 4);
                 format += 5;
                 break;
@@ -1206,7 +1207,7 @@ BOOL HLPFILE_BrowseParagraph(HLPFILE *hlpfile, struct RtfData* rd, BYTE *buf, BY
                         WINE_WARN("Unknown link type %d\n", type);
                         break;
                     }
-                    alloc_link(rd, hlp_link_link, ptr, GET_UINT(format, 4), wnd);
+                    alloc_link(rd, hlp_link_link, ptr, -1, GET_UINT(format, 4), wnd);
                     rd->force_color = !(*format & 4);
                 }
                 format += 3 + GET_USHORT(format, 1);





More information about the wine-patches mailing list