shlwapi: Resupply array sizes stripped by function interface (Try 2)

Andrew Talbot Andrew.Talbot at talbotville.com
Tue Sep 26 17:09:12 CDT 2006


This version makes use of the alternative mode of GetLocaleInfoW() to calculate
how much space within each supplied buffer it needs when used in its principal
mode. Please reword the changelog line, if you wish: I found it hard to express
the problem succinctly.

Thanks,

-- Andy.
---
Changelog:
    shlwapi: Resupply array sizes stripped by function interface.

diff -urN a/dlls/shlwapi/string.c b/dlls/shlwapi/string.c
--- a/dlls/shlwapi/string.c	2006-08-23 22:37:14.000000000 +0100
+++ b/dlls/shlwapi/string.c	2006-09-26 22:35:32.000000000 +0100
@@ -66,19 +66,22 @@
 static HRESULT WINAPI _SHStrDupAW(LPCWSTR,LPSTR*);
 
 
-static void FillNumberFmt(NUMBERFMTW *fmt, WCHAR decimal_buffer[8], WCHAR thousand_buffer[8])
+static void FillNumberFmt(NUMBERFMTW *fmt, LPWSTR decimal_buffer, LPWSTR thousand_buffer)
 {
   WCHAR grouping[64];
   WCHAR *c;
+  int decimal_buflen, thousand_buflen;
 
   GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ILZERO|LOCALE_RETURN_NUMBER, (LPWSTR)&fmt->LeadingZero, sizeof(fmt->LeadingZero)/sizeof(WCHAR));
   GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER|LOCALE_RETURN_NUMBER, (LPWSTR)&fmt->LeadingZero, sizeof(fmt->NegativeOrder)/sizeof(WCHAR));
   fmt->NumDigits = 0;
-  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal_buffer, sizeof(decimal_buffer)/sizeof(WCHAR));
-  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousand_buffer, sizeof(thousand_buffer)/sizeof(WCHAR));
+  decimal_buflen = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, NULL, 0);
+  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, decimal_buffer, decimal_buflen);
+  thousand_buflen = GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, NULL, 0);
+  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, thousand_buffer, thousand_buflen);
   fmt->lpThousandSep = thousand_buffer;
   fmt->lpDecimalSep = decimal_buffer;
-  
+
   /* 
    * Converting grouping string to number as described on 
    * http://blogs.msdn.com/oldnewthing/archive/2006/04/18/578251.aspx



More information about the wine-patches mailing list