Aric Stewart : commdlg: File name and extension offsets are not guaranteed to be the same in W-> A conversions.
Alexandre Julliard
julliard at winehq.org
Wed Dec 5 06:56:57 CST 2007
Module: wine
Branch: master
Commit: 9649ca2aa29d869453b682354053d1e88ac63397
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9649ca2aa29d869453b682354053d1e88ac63397
Author: Aric Stewart <aric at codeweavers.com>
Date: Mon Dec 3 20:24:23 2007 +0900
commdlg: File name and extension offsets are not guaranteed to be the same in W->A conversions.
---
dlls/comdlg32/filedlg.c | 43 ++++++++++++++++++++++++++++++++++---------
1 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 67fefd1..3e9c692 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -2140,7 +2140,6 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
if(lstrlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
{
- LPWSTR lpszTemp;
/* fill destination buffer */
if (fodInfos->ofnInfos->lpstrFile)
@@ -2164,13 +2163,31 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
}
}
- /* set filename offset */
- lpszTemp = PathFindFileNameW(lpstrPathAndFile);
- fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+ if(fodInfos->unicode)
+ {
+ LPWSTR lpszTemp;
+
+ /* set filename offset */
+ lpszTemp = PathFindFileNameW(lpstrPathAndFile);
+ fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
+
+ /* set extension offset */
+ lpszTemp = PathFindExtensionW(lpstrPathAndFile);
+ fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+ }
+ else
+ {
+ LPSTR lpszTemp;
+ LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
+
+ /* set filename offset */
+ lpszTemp = PathFindFileNameA(ofn->lpstrFile);
+ fodInfos->ofnInfos->nFileOffset = (lpszTemp - ofn->lpstrFile);
- /* set extension offset */
- lpszTemp = PathFindExtensionW(lpstrPathAndFile);
- fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
+ /* set extension offset */
+ lpszTemp = PathFindExtensionA(ofn->lpstrFile);
+ fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - ofn->lpstrFile) + 1 : 0;
+ }
/* set the lpstrFileTitle */
if(fodInfos->ofnInfos->lpstrFileTitle)
@@ -3658,12 +3675,20 @@ static void CALLBACK FD32_UpdateResult(const FD31_DATA *lfs)
if (priv->ofnA)
{
+ LPSTR lpszTemp;
if (ofnW->nMaxFile &&
!WideCharToMultiByte( CP_ACP, 0, ofnW->lpstrFile, -1,
priv->ofnA->lpstrFile, ofnW->nMaxFile, NULL, NULL ))
priv->ofnA->lpstrFile[ofnW->nMaxFile-1] = 0;
- priv->ofnA->nFileOffset = ofnW->nFileOffset;
- priv->ofnA->nFileExtension = ofnW->nFileExtension;
+
+ /* offsets are not guarenteed to be the same in WCHAR to MULTIBYTE conversion */
+ /* set filename offset */
+ lpszTemp = PathFindFileNameA(priv->ofnA->lpstrFile);
+ priv->ofnA->nFileOffset = (lpszTemp - priv->ofnA->lpstrFile);
+
+ /* set extension offset */
+ lpszTemp = PathFindExtensionA(priv->ofnA->lpstrFile);
+ priv->ofnA->nFileExtension = (*lpszTemp) ? (lpszTemp - priv->ofnA->lpstrFile) + 1 : 0;
}
}
More information about the wine-cvs
mailing list