Author: cwittich Date: Sat Mar 6 13:08:51 2010 New Revision: 45923
URL: http://svn.reactos.org/svn/reactos?rev=45923&view=rev Log: [SHLWAPI] sync shlwapi to wine 1.1.40
Modified: trunk/reactos/dll/win32/shlwapi/ordinal.c trunk/reactos/dll/win32/shlwapi/url.c trunk/reactos/include/psdk/shlwapi.h
Modified: trunk/reactos/dll/win32/shlwapi/ordinal.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/ordinal.c... ============================================================================== --- trunk/reactos/dll/win32/shlwapi/ordinal.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shlwapi/ordinal.c [iso-8859-1] Sat Mar 6 13:08:51 2010 @@ -1082,23 +1082,25 @@ * PARAMS * hWnd [I] Window to get value from * offset [I] Offset of value - * wMask [I] Mask for uiFlags - * wFlags [I] Bits to set in window value + * mask [I] Mask for flags + * flags [I] Bits to set in window value * * RETURNS * The new value as it was set, or 0 if any parameter is invalid. * * NOTES - * Any bits set in uiMask are cleared from the value, then any bits set in - * uiFlags are set in the value. - */ -LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT wMask, UINT wFlags) -{ - LONG ret = GetWindowLongA(hwnd, offset); - LONG newFlags = (wFlags & wMask) | (ret & ~wFlags); - - if (newFlags != ret) - ret = SetWindowLongA(hwnd, offset, newFlags); + * Only bits specified in mask are affected - set if present in flags and + * reset otherwise. + */ +LONG WINAPI SHSetWindowBits(HWND hwnd, INT offset, UINT mask, UINT flags) +{ + LONG ret = GetWindowLongW(hwnd, offset); + LONG new_flags = (flags & mask) | (ret & ~mask); + + TRACE("%p %d %x %x\n", hwnd, offset, mask, flags); + + if (new_flags != ret) + ret = SetWindowLongW(hwnd, offset, new_flags); return ret; }
@@ -4659,7 +4661,7 @@ * fileTime [I] Pointer to FILETIME structure specifying the time * flags [I] Flags specifying the desired output * buf [O] Pointer to buffer for output - * bufSize [I] Number of characters that can be contained in buffer + * size [I] Number of characters that can be contained in buffer * * RETURNS * success: number of characters written to the buffer @@ -4667,10 +4669,65 @@ * */ INT WINAPI SHFormatDateTimeW(const FILETIME UNALIGNED *fileTime, DWORD *flags, - LPWSTR buf, UINT bufSize) -{ - FIXME("%p %p %s %d STUB\n", fileTime, flags, debugstr_w(buf), bufSize); - return 0; + LPWSTR buf, UINT size) +{ +#define SHFORMATDT_UNSUPPORTED_FLAGS (FDTF_RELATIVE | FDTF_LTRDATE | FDTF_RTLDATE | FDTF_NOAUTOREADINGORDER) + DWORD fmt_flags = flags ? *flags : FDTF_DEFAULT; + SYSTEMTIME st; + FILETIME ft; + INT ret = 0; + + TRACE("%p %p %p %u\n", fileTime, flags, buf, size); + + if (!buf || !size) + return 0; + + if (fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS) + FIXME("ignoring some flags - 0x%08x\n", fmt_flags & SHFORMATDT_UNSUPPORTED_FLAGS); + + FileTimeToLocalFileTime(fileTime, &ft); + FileTimeToSystemTime(&ft, &st); + + /* first of all date */ + if (fmt_flags & (FDTF_LONGDATE | FDTF_SHORTDATE)) + { + static const WCHAR sep1[] = {',',' ',0}; + static const WCHAR sep2[] = {' ',0}; + + DWORD date = fmt_flags & FDTF_LONGDATE ? DATE_LONGDATE : DATE_SHORTDATE; + ret = GetDateFormatW(LOCALE_USER_DEFAULT, date, &st, NULL, buf, size); + if (ret >= size) return ret; + + /* add separator */ + if (ret < size && (fmt_flags & (FDTF_LONGTIME | FDTF_SHORTTIME))) + { + if ((fmt_flags & FDTF_LONGDATE) && (ret < size + 2)) + { + if (ret < size + 2) + { + lstrcatW(&buf[ret-1], sep1); + ret += 2; + } + } + else + { + lstrcatW(&buf[ret-1], sep2); + ret++; + } + } + } + /* time part */ + if (fmt_flags & (FDTF_LONGTIME | FDTF_SHORTTIME)) + { + DWORD time = fmt_flags & FDTF_LONGTIME ? 0 : TIME_NOSECONDS; + + if (ret) ret--; + ret += GetTimeFormatW(LOCALE_USER_DEFAULT, time, &st, NULL, &buf[ret], size - ret); + } + + return ret; + +#undef SHFORMATDT_UNSUPPORTED_FLAGS }
/*********************************************************************** @@ -4680,21 +4737,19 @@ * */ INT WINAPI SHFormatDateTimeA(const FILETIME UNALIGNED *fileTime, DWORD *flags, - LPCSTR buf, UINT bufSize) + LPSTR buf, UINT size) { WCHAR *bufW; - DWORD buflenW, convlen; INT retval;
- if (!buf || !bufSize) + if (!buf || !size) return 0;
- buflenW = bufSize; - bufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * buflenW); - retval = SHFormatDateTimeW(fileTime, flags, bufW, buflenW); + bufW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * size); + retval = SHFormatDateTimeW(fileTime, flags, bufW, size);
if (retval != 0) - convlen = WideCharToMultiByte(CP_ACP, 0, bufW, -1, (LPSTR) buf, bufSize, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, size, NULL, NULL);
HeapFree(GetProcessHeap(), 0, bufW); return retval;
Modified: trunk/reactos/dll/win32/shlwapi/url.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/url.c?rev... ============================================================================== --- trunk/reactos/dll/win32/shlwapi/url.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shlwapi/url.c [iso-8859-1] Sat Mar 6 13:08:51 2010 @@ -630,6 +630,8 @@ process_case = 1; } else do { + BOOL manual_search = FALSE; + /* mk is a special case */ if(base.nScheme == URL_SCHEME_MK) { static const WCHAR wsz[] = {':',':',0}; @@ -659,13 +661,45 @@ } }
- /* Change .sizep2 to not have the last leaf in it, - * Note: we need to start after the location (if it exists) - */ - work = strrchrW((base.pszSuffix+sizeloc), '/'); - if (work) { - len = (DWORD)(work - base.pszSuffix + 1); - base.cchSuffix = len; + /* If there is a '#' and the characters immediately preceeding it are + * ".htm[l]", then begin looking for the last leaf starting from + * the '#'. Otherwise the '#' is not meaningful and just start + * looking from the end. */ + if ((work = strchrW(base.pszSuffix + sizeloc, '#'))) { + const WCHAR htmlW[] = {'.','h','t','m','l',0}; + const int len_htmlW = 5; + const WCHAR htmW[] = {'.','h','t','m',0}; + const int len_htmW = 4; + + if (work - base.pszSuffix > len_htmW * sizeof(WCHAR)) { + work -= len_htmW; + if (strncmpiW(work, htmW, len_htmW) == 0) + manual_search = TRUE; + work += len_htmW; + } + + if (!manual_search && + work - base.pszSuffix > len_htmlW * sizeof(WCHAR)) { + work -= len_htmlW; + if (strncmpiW(work, htmlW, len_htmlW) == 0) + manual_search = TRUE; + work += len_htmlW; + } + } + + if (manual_search) { + /* search backwards starting from the current position */ + while (*work != '/' && work > base.pszSuffix + sizeloc) + --work; + if (work > base.pszSuffix + sizeloc) + base.cchSuffix = work - base.pszSuffix + 1; + }else { + /* search backwards starting from the end of the string */ + work = strrchrW((base.pszSuffix+sizeloc), '/'); + if (work) { + len = (DWORD)(work - base.pszSuffix + 1); + base.cchSuffix = len; + } }
/*
Modified: trunk/reactos/include/psdk/shlwapi.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/shlwapi.h?rev=... ============================================================================== --- trunk/reactos/include/psdk/shlwapi.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/shlwapi.h [iso-8859-1] Sat Mar 6 13:08:51 2010 @@ -1092,6 +1092,17 @@ #define TPS_EXECUTEIO 0x00000001 #define TPS_LONGEXECTIME 0x00000008
+/* SHFormatDateTimeA/SHFormatDateTimeW flags */ +#define FDTF_SHORTTIME 0x00000001 +#define FDTF_SHORTDATE 0x00000002 +#define FDTF_DEFAULT (FDTF_SHORTDATE | FDTF_SHORTTIME) +#define FDTF_LONGDATE 0x00000004 +#define FDTF_LONGTIME 0x00000008 +#define FDTF_RELATIVE 0x00000010 +#define FDTF_LTRDATE 0x00000100 +#define FDTF_RTLDATE 0x00000200 +#define FDTF_NOAUTOREADINGORDER 0x00000400 + #include <poppack.h>
#ifdef __cplusplus