[oleaut32 1/2] Implements function varformat:VarWeekdayName [RESEND]
Benjamin Arai
me at benjaminarai.com
Wed Aug 9 20:30:58 CDT 2006
Hi,
Fixes bug http://bugs.winehq.org/show_bug.cgi?id=5884
GetLocaleInfoW directly allocates into the destination string instead of
allocating another buffer as suggested by Alexandre Julliard.
Changelog:
- Implements oleaut32 VarWeekdayName
- Removes stub from oleaut32.spec
- 2/2 Conformance test for VarWeekdayName
---
dlls/oleaut32/oleaut32.spec | 2 +
dlls/oleaut32/varformat.c | 60 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletions(-)
--
Benjamin Arai
http://www.benjaminarai.com
-------------- next part --------------
diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec
index ad110c7..9e1f1db 100644
--- a/dlls/oleaut32/oleaut32.spec
+++ b/dlls/oleaut32/oleaut32.spec
@@ -124,7 +124,7 @@
125 stdcall VarBoolFromStr(wstr long long ptr)
126 stdcall VarBoolFromDisp(ptr long ptr)
127 stdcall VarFormatCurrency(ptr long long long long long ptr)
-128 stub VarWeekdayName # stdcall (long long long long ptr)
+128 stdcall VarWeekdayName(long long long long ptr)
129 stdcall VarMonthName(long long long ptr)
130 stdcall VarUI1FromI2(long ptr)
131 stdcall VarUI1FromI4(long ptr)
diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c
index 836fa69..deb3e65 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -2452,6 +2452,66 @@ HRESULT WINAPI VarFormatCurrency(LPVARIA
}
/**********************************************************************
+ * VarWeekdayName [OLEAUT32.128]
+ *
+ * Print the specified weekday as localized name.
+ *
+ * PARAMS
+ * iWeekday [I] day number of week 0 = sys default, 1 = Monday, etc
+ * fAbbrev [I] 0 - full name, !0 - abbreviated name
+ * iFirstDay [I] first day of week, 0 = sys default, 1 = Monday, etc
+ * dwFlags [I] VAR_CALENDAR_HIJRI is the only possible flag.
+ * pbstrOut [O] Destination for weekday name
+ *
+ * RETURNS
+ * Success: S_OK. pbstrOut contains the name.
+ * Failure: E_INVALIDARG, if any parameter is invalid.
+ * E_OUTOFMEMORY, if enough memory cannot be allocated.
+ *
+ */
+HRESULT WINAPI VarWeekdayName(INT iWeekday, INT fAbbrev, INT iFirstDay,
+ ULONG dwFlags, BSTR *pbstrOut)
+{
+ DWORD localeValue;
+ INT size;
+
+ if ((iWeekday < 1) || (iWeekday > 7) ||
+ (iFirstDay < 0) || (iFirstDay > 7) ||
+ (pbstrOut == NULL))
+ return E_INVALIDARG;
+
+ if (dwFlags)
+ FIXME("Does not support dwFlags 0x%lx, ignoring.\n", dwFlags);
+
+ if (fAbbrev)
+ if (iFirstDay == 0)
+ localeValue = LOCALE_SABBREVDAYNAME1 + ((iWeekday + iFirstDay + 5) % 7);
+ else
+ localeValue = LOCALE_SABBREVDAYNAME1 + ((iWeekday + iFirstDay + 4) % 7);
+ else
+ if (iFirstDay == 0)
+ localeValue = LOCALE_SDAYNAME1 + ((iWeekday + iFirstDay + 5) % 7);
+ else
+ localeValue = LOCALE_SDAYNAME1 + ((iWeekday + iFirstDay + 4) % 7);
+
+ size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, NULL, 0);
+ if (!size) {
+ ERR("GetLocaleInfo 0x%lx failed.\n", localeValue);
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+ *pbstrOut = SysAllocStringLen(NULL,size - 1);
+ if (!*pbstrOut)
+ return E_OUTOFMEMORY;
+ size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, *pbstrOut, size);
+ if (!size) {
+ ERR("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue);
+ SysFreeString(*pbstrOut);
+ return HRESULT_FROM_WIN32(GetLastError());
+ }
+ return S_OK;
+}
+
+/**********************************************************************
* VarMonthName [OLEAUT32.129]
*
* Print the specified month as localized name.
--
1.4.0
More information about the wine-patches
mailing list