[oleaut32 1/2] Resend: Implements function varformat:VarWeekdayName

Benjamin Arai me at benjaminarai.com
Tue Jul 25 21:10:12 CDT 2006


Skipped content of type multipart/alternative-------------- next part --------------
From 43d65ab7aed55f1989ee2824bc617a0173701bfd Mon Sep 17 00:00:00 2001
From: Benjamin Arai <me at benjaminarai.com>
Date: Tue, 25 Jul 2006 11:19:31 -0700
Subject: [PATCH] [oleaut32 1/2] Resend: Implements function varformat:VarWeekdayName

Addresses error code and helper function issues exposed by Robert Shearman

Changelog:
 - Implements oleaut32 VarWeekdayName
 - Removes stub from oleaut32.spec
 - 2/2 Conformance test for VarWeekdayName
---
 dlls/oleaut32/oleaut32.spec |    2 +
 dlls/oleaut32/varformat.c   |   66 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletions(-)

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 77d1196..46dca16 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -2,6 +2,7 @@
  * Variant formatting functions
  *
  * Copyright 2003 Jon Griffiths
+ * Copyright 2006 (Google) Benjamin Arai
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -2452,6 +2453,71 @@ 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;
+  WCHAR *str;
+
+  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());
+  }
+  str = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*size);
+  if (!str)
+    return E_OUTOFMEMORY;
+  size = GetLocaleInfoW(LOCALE_USER_DEFAULT,localeValue, str, size);
+  if (!size) {
+    ERR("GetLocaleInfo of 0x%lx failed in 2nd stage?!\n", localeValue);
+    HeapFree(GetProcessHeap(),0,str);
+    return HRESULT_FROM_WIN32(GetLastError());
+  }
+  *pbstrOut = SysAllocString(str);
+  HeapFree(GetProcessHeap(),0,str);
+  if (!*pbstrOut)
+    return E_OUTOFMEMORY;
+  return S_OK;
+}
+
+/**********************************************************************
  *              VarMonthName [OLEAUT32.129]
  *
  * Print the specified month as localized name.
-- 
1.4.0


More information about the wine-patches mailing list