patch for "GetFileTitleW: illegal call to GetFileTitleA" 2ed
liu spider
liuspider at yahoo.com
Mon Jan 13 20:02:04 CST 2003
Thanks to Dmitry Timoshkov. This patch is the second
edition, adopted his suggestions.
ChangeLog:
-dlls/commdlg/filetitle.c
implemented GetFileTitleW
GetFileTitleA now is a call to GetFileTitleW
(The patch seems to be ignored without any comments.
Could anyone give some clues on how to improve this
patch? thanks.)
liuspider
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
-------------- next part --------------
Index: dlls/commdlg/filetitle.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filetitle.c,v
retrieving revision 1.12
diff -u -r1.12 filetitle.c
--- dlls/commdlg/filetitle.c 31 May 2002 23:25:45 -0000 1.12
+++ dlls/commdlg/filetitle.c 12 Jan 2003 07:09:56 -0000
@@ -3,6 +3,7 @@
*
* Copyright 1994 Martin Ayotte
* Copyright 1996 Albrecht Kleine
+ * Copyright 2003 liuspider
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -24,10 +25,10 @@
#include "winbase.h"
#include "winnls.h"
#include "commdlg.h"
+#include "wine/unicode.h"
+#include "winternl.h"
#include "wine/debug.h"
-#include "heap.h" /* Has to go */
-
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
#include "cdlg.h"
@@ -38,19 +39,39 @@
*/
short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
{
- int i, len;
+ int ret;
+ UNICODE_STRING strWFile, strWTitle;
+ RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
+ RtlCreateUnicodeStringFromAsciiz(&strWTitle,lpTitle);
+ ret = GetFileTitleW(strWFile.Buffer, strWTitle.Buffer, cbBuf * sizeof(WCHAR));
+ if (!ret){
+ WideCharToMultiByte( CP_ACP, 0, strWTitle.Buffer, -1, lpTitle, cbBuf, NULL, NULL );
+ }
+ RtlFreeUnicodeString( &strWFile );
+ RtlFreeUnicodeString( &strWTitle );
+ return ret;
+}
+
+/***********************************************************************
+ * GetFileTitleW (COMDLG32.@)
+ *
+ */
+short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
+{
+ int i, len;
+ WCHAR brkpoint[] = {'*','[',']'};
TRACE("(%p %p %d); \n", lpFile, lpTitle, cbBuf);
if(lpFile == NULL || lpTitle == NULL)
return -1;
- len = strlen(lpFile);
+ len = strlenW(lpFile);
if (len == 0)
return -1;
- if(strpbrk(lpFile, "*[]"))
+ if(strpbrkW(lpFile, brkpoint))
return -1;
len--;
@@ -70,34 +91,14 @@
if(i == -1)
i++;
- TRACE("---> '%s' \n", &lpFile[i]);
+ TRACE("---> '%s' \n", debugstr_w(&lpFile[i]));
- len = strlen(lpFile+i)+1;
+ len = strlenW(lpFile+i)+1;
if(cbBuf < len)
return len;
- strncpy(lpTitle, &lpFile[i], len);
+ strncpyW(lpTitle, &lpFile[i], len);
return 0;
-}
-
-
-/***********************************************************************
- * GetFileTitleW (COMDLG32.@)
- *
- */
-short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, UINT cbBuf)
-{
- LPSTR file = HEAP_strdupWtoA(GetProcessHeap(), 0, lpFile); /* Has to go */
- LPSTR title = HeapAlloc(GetProcessHeap(), 0, cbBuf);
- short ret;
-
- ret = GetFileTitleA(file, title, cbBuf);
-
- if (cbBuf > 0 && !MultiByteToWideChar( CP_ACP, 0, title, -1, lpTitle, cbBuf ))
- lpTitle[cbBuf-1] = 0;
- HeapFree(GetProcessHeap(), 0, file);
- HeapFree(GetProcessHeap(), 0, title);
- return ret;
}
More information about the wine-patches
mailing list