[PATCH 1/2] [WinHelp]: fix trailing space in window name for JumpID macro
Eric Pouech
eric.pouech at orange.fr
Sat Jun 12 14:54:59 CDT 2010
A+
---
programs/winhlp32/macro.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/programs/winhlp32/macro.c b/programs/winhlp32/macro.c
index cd497ef..f75b63d 100644
--- a/programs/winhlp32/macro.c
+++ b/programs/winhlp32/macro.c
@@ -575,13 +575,17 @@ static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id)
if ((ptr = strchr(lpszPathWindow, '>')) != NULL)
{
LPSTR tmp;
- size_t sz = ptr - lpszPathWindow;
+ size_t sz;
- tmp = HeapAlloc(GetProcessHeap(), 0, sz + 1);
+ tmp = HeapAlloc(GetProcessHeap(), 0, strlen(lpszPathWindow) + 1);
if (tmp)
{
- memcpy(tmp, lpszPathWindow, sz);
- tmp[sz] = '\0';
+ strcpy(tmp, lpszPathWindow);
+ tmp[ptr - lpszPathWindow] = '\0';
+ ptr += tmp - lpszPathWindow; /* ptr now points to '>' in tmp buffer */
+ /* in some cases, we have a trailing space that we need to get rid of */
+ /* FIXME: check if it has to be done in lexer rather than here */
+ for (sz = strlen(ptr + 1); sz >= 1 && ptr[sz] == ' '; sz--) ptr[sz] = '\0';
MACRO_JumpHash(tmp, ptr + 1, HLPFILE_Hash(topic_id));
HeapFree(GetProcessHeap(), 0, tmp);
}
More information about the wine-patches
mailing list