winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
wine-devel
July 2018
----- 2024 -----
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
[email protected]
74 participants
637 discussions
Start a n
N
ew thread
[PATCH] msvcrt: Use the ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/msvcrt/console.c | 2 +- dlls/msvcrt/ctype.c | 2 +- dlls/msvcrt/errno.c | 2 +- dlls/msvcrt/except.c | 3 +-- dlls/msvcrt/exit.c | 3 +-- dlls/msvcrt/file.c | 20 ++++++++++---------- dlls/msvcrt/locale.c | 12 ++++++------ dlls/msvcrt/printf.h | 4 ++-- dlls/msvcrt/process.c | 2 +- dlls/msvcrt/scheduler.c | 8 ++++---- dlls/msvcrt/wcs.c | 2 +- 11 files changed, 29 insertions(+), 31 deletions(-) diff --git a/dlls/msvcrt/console.c b/dlls/msvcrt/console.c index 75e95ebcfc..3a2301ef18 100644 --- a/dlls/msvcrt/console.c +++ b/dlls/msvcrt/console.c @@ -124,7 +124,7 @@ static BOOL handle_enhanced_keys(INPUT_RECORD *ir, unsigned char *ch1, unsigned { int i; - for (i = 0; i < sizeof(enh_map) / sizeof(enh_map[0]); i++) + for (i = 0; i < ARRAY_SIZE(enh_map); i++) { if (ir->Event.KeyEvent.wVirtualScanCode == enh_map[i].vk) { diff --git a/dlls/msvcrt/ctype.c b/dlls/msvcrt/ctype.c index 2c39a56686..758411a7a4 100644 --- a/dlls/msvcrt/ctype.c +++ b/dlls/msvcrt/ctype.c @@ -493,7 +493,7 @@ unsigned short __cdecl wctype(const char *property) }; unsigned int i; - for(i=0; i<sizeof(properties)/sizeof(properties[0]); i++) + for(i=0; i<ARRAY_SIZE(properties); i++) if(!strcmp(property, properties[i].name)) return properties[i].mask; diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c index c5fbae21a8..a80ac61f11 100644 --- a/dlls/msvcrt/errno.c +++ b/dlls/msvcrt/errno.c @@ -123,7 +123,7 @@ char *MSVCRT__sys_errlist[] = str_generic_error }; -unsigned int MSVCRT__sys_nerr = sizeof(MSVCRT__sys_errlist)/sizeof(MSVCRT__sys_errlist[0]) - 1; +unsigned int MSVCRT__sys_nerr = ARRAY_SIZE(MSVCRT__sys_errlist) - 1; static MSVCRT_invalid_parameter_handler invalid_parameter_handler = NULL; diff --git a/dlls/msvcrt/except.c b/dlls/msvcrt/except.c index 8fccd8ed5d..da0ac9219e 100644 --- a/dlls/msvcrt/except.c +++ b/dlls/msvcrt/except.c @@ -136,8 +136,7 @@ static LONG msvcrt_exception_filter(struct _EXCEPTION_POINTERS *except) int float_signal = MSVCRT__FPE_INVALID; sighandlers[MSVCRT_SIGFPE] = MSVCRT_SIG_DFL; - for (i = 0; i < sizeof(float_exception_map) / - sizeof(float_exception_map[0]); i++) + for (i = 0; i < ARRAY_SIZE(float_exception_map); i++) { if (float_exception_map[i].status == except->ExceptionRecord->ExceptionCode) diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c index b84c50adbc..51bc6f07e1 100644 --- a/dlls/msvcrt/exit.c +++ b/dlls/msvcrt/exit.c @@ -209,8 +209,7 @@ static void DoMessageBoxW(const MSVCRT_wchar_t *lead, const MSVCRT_wchar_t *mess MSVCRT_wchar_t text[2048]; INT ret; - MSVCRT__snwprintf(text, sizeof(text)/sizeof(text[0]), message_format, - lead, MSVCRT__wpgmptr, message); + MSVCRT__snwprintf(text, ARRAY_SIZE(text), message_format, lead, MSVCRT__wpgmptr, message); msgbox.cbSize = sizeof(msgbox); msgbox.hwndOwner = GetActiveWindow(); diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 2c05f25c6a..224e6eae0c 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -1223,7 +1223,7 @@ void msvcrt_free_io(void) MSVCRT__flushall(); MSVCRT__fcloseall(); - for(i=0; i<sizeof(MSVCRT___pioinfo)/sizeof(MSVCRT___pioinfo[0]); i++) + for(i=0; i<ARRAY_SIZE(MSVCRT___pioinfo); i++) { if(!MSVCRT___pioinfo[i]) continue; @@ -1246,7 +1246,7 @@ void msvcrt_free_io(void) } } - for(i=0; i<sizeof(MSVCRT_fstream)/sizeof(MSVCRT_fstream[0]); i++) + for(i=0; i<ARRAY_SIZE(MSVCRT_fstream); i++) MSVCRT_free(MSVCRT_fstream[i]); } @@ -1606,29 +1606,29 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st mode++; while(*mode == ' ') mode++; - if(!MSVCRT_CHECK_PMT(!strncmpW(ccs, mode, sizeof(ccs)/sizeof(ccs[0])))) + if(!MSVCRT_CHECK_PMT(!strncmpW(ccs, mode, ARRAY_SIZE(ccs)))) return -1; - mode += sizeof(ccs)/sizeof(ccs[0]); + mode += ARRAY_SIZE(ccs); while(*mode == ' ') mode++; if(!MSVCRT_CHECK_PMT(*mode == '=')) return -1; mode++; while(*mode == ' ') mode++; - if(!strncmpiW(utf8, mode, sizeof(utf8)/sizeof(utf8[0]))) + if(!strncmpiW(utf8, mode, ARRAY_SIZE(utf8))) { *open_flags |= MSVCRT__O_U8TEXT; - mode += sizeof(utf8)/sizeof(utf8[0]); + mode += ARRAY_SIZE(utf8); } - else if(!strncmpiW(utf16le, mode, sizeof(utf16le)/sizeof(utf16le[0]))) + else if(!strncmpiW(utf16le, mode, ARRAY_SIZE(utf16le))) { *open_flags |= MSVCRT__O_U16TEXT; - mode += sizeof(utf16le)/sizeof(utf16le[0]); + mode += ARRAY_SIZE(utf16le); } - else if(!strncmpiW(unicode, mode, sizeof(unicode)/sizeof(unicode[0]))) + else if(!strncmpiW(unicode, mode, ARRAY_SIZE(unicode))) { *open_flags |= MSVCRT__O_WTEXT; - mode += sizeof(unicode)/sizeof(unicode[0]); + mode += ARRAY_SIZE(unicode); } else { diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index 8c9bece774..1e56395dbb 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -94,7 +94,7 @@ static const char * const _country_synonyms[] = static void remap_synonym(char *name) { unsigned int i; - for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 ) + for (i = 0; i < ARRAY_SIZE(_country_synonyms); i += 2) { if (!strcasecmp(_country_synonyms[i],name)) { @@ -595,7 +595,7 @@ void* CDECL _Gettnames(void) TRACE("\n"); - for(i=0; i<sizeof(cur->str.str)/sizeof(cur->str.str[0]); i++) + for(i=0; i<ARRAY_SIZE(cur->str.str); i++) size += strlen(cur->str.str[i])+1; ret = MSVCRT_malloc(size); @@ -604,7 +604,7 @@ void* CDECL _Gettnames(void) memcpy(ret, cur, size); size = 0; - for(i=0; i<sizeof(cur->str.str)/sizeof(cur->str.str[0]); i++) { + for(i=0; i<ARRAY_SIZE(cur->str.str); i++) { ret->str.str[i] = &ret->data[size]; size += strlen(&ret->data[size])+1; } @@ -1605,7 +1605,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, size = sizeof(MSVCRT___lc_time_data); lcid_tmp = lcid[MSVCRT_LC_TIME] ? lcid[MSVCRT_LC_TIME] : MAKELCID(LANG_ENGLISH, SORT_DEFAULT); - for(i=0; i<sizeof(time_data)/sizeof(time_data[0]); i++) { + for(i=0; i<ARRAY_SIZE(time_data); i++) { if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) { size += sizeof(cloc_short_date) + sizeof(cloc_short_dateW); }else if(time_data[i]==LOCALE_SLONGDATE && !lcid[MSVCRT_LC_TIME]) { @@ -1637,7 +1637,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, } ret = 0; - for(i=0; i<sizeof(time_data)/sizeof(time_data[0]); i++) { + for(i=0; i<ARRAY_SIZE(time_data); i++) { locinfo->lc_time_curr->str.str[i] = &locinfo->lc_time_curr->data[ret]; if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) { memcpy(&locinfo->lc_time_curr->data[ret], cloc_short_date, sizeof(cloc_short_date)); @@ -1653,7 +1653,7 @@ static MSVCRT_pthreadlocinfo create_locinfo(int category, &locinfo->lc_time_curr->data[ret], size-ret); } } - for(i=0; i<sizeof(time_data)/sizeof(time_data[0]); i++) { + for(i=0; i<ARRAY_SIZE(time_data); i++) { locinfo->lc_time_curr->wstr.wstr[i] = (MSVCRT_wchar_t*)&locinfo->lc_time_curr->data[ret]; if(time_data[i]==LOCALE_SSHORTDATE && !lcid[MSVCRT_LC_TIME]) { memcpy(&locinfo->lc_time_curr->data[ret], cloc_short_dateW, sizeof(cloc_short_dateW)); diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h index ee8120e149..077dafa550 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -518,7 +518,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API flags.PadZero = '0'; i = flags.Precision; flags.Precision = 2*sizeof(void*); - FUNC_NAME(pf_integer_conv)(buf, sizeof(buf)/sizeof(APICHAR), &flags, + FUNC_NAME(pf_integer_conv)(buf, ARRAY_SIZE(buf), &flags, (ULONG_PTR)pf_args(args_ctx, pos, VT_PTR, valist).get_ptr); flags.PadZero = 0; flags.Precision = i; @@ -549,7 +549,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API flags.Precision = flags.FieldLength - 2; max_len = (flags.FieldLength>flags.Precision ? flags.FieldLength : flags.Precision) + 10; - if(max_len > sizeof(buf)/sizeof(APICHAR)) + if(max_len > ARRAY_SIZE(buf)) tmp = HeapAlloc(GetProcessHeap(), 0, max_len); if(!tmp) return -1; diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c index fac3bd4d20..9a192e7e9b 100644 --- a/dlls/msvcrt/process.c +++ b/dlls/msvcrt/process.c @@ -345,7 +345,7 @@ static MSVCRT_wchar_t *msvcrt_get_comspec(void) MSVCRT_wchar_t *ret; unsigned int len; - if (!(len = GetEnvironmentVariableW(comspec, NULL, 0))) len = sizeof(cmd)/sizeof(MSVCRT_wchar_t); + if (!(len = GetEnvironmentVariableW(comspec, NULL, 0))) len = ARRAY_SIZE(cmd); if ((ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t)))) { if (!GetEnvironmentVariableW(comspec, ret, len)) strcpyW(ret, cmd); diff --git a/dlls/msvcrt/scheduler.c b/dlls/msvcrt/scheduler.c index c6c0fa7e38..55ab1c549e 100644 --- a/dlls/msvcrt/scheduler.c +++ b/dlls/msvcrt/scheduler.c @@ -344,7 +344,7 @@ static void ExternalContextBase_dtor(ExternalContextBase *this) int i; /* TODO: move the allocator cache to scheduler so it can be reused */ - for(i=0; i<sizeof(this->allocator_cache)/sizeof(this->allocator_cache[0]); i++) { + for(i=0; i<ARRAY_SIZE(this->allocator_cache); i++) { for(cur = this->allocator_cache[i]; cur; cur=next) { next = cur->free.next; MSVCRT_operator_delete(cur); @@ -413,10 +413,10 @@ void * CDECL Concurrency_Alloc(MSVCRT_size_t size) int i; C_ASSERT(sizeof(union allocator_cache_entry) <= 1 << 4); - for(i=0; i<sizeof(context->allocator_cache)/sizeof(context->allocator_cache[0]); i++) + for(i=0; i<ARRAY_SIZE(context->allocator_cache); i++) if (1 << (i+4) >= size) break; - if(i==sizeof(context->allocator_cache)/sizeof(context->allocator_cache[0])) { + if(i==ARRAY_SIZE(context->allocator_cache)) { p = MSVCRT_operator_new(size); p->alloc.bucket = -1; }else if (context->allocator_cache[i]) { @@ -446,7 +446,7 @@ void CDECL Concurrency_Free(void* mem) if (context->context.vtable != &MSVCRT_ExternalContextBase_vtable) { MSVCRT_operator_delete(p); }else { - if(bucket >= 0 && bucket < sizeof(context->allocator_cache)/sizeof(context->allocator_cache[0]) && + if(bucket >= 0 && bucket < ARRAY_SIZE(context->allocator_cache) && (!context->allocator_cache[bucket] || context->allocator_cache[bucket]->free.depth < 20)) { p->free.next = context->allocator_cache[bucket]; p->free.depth = p->free.next ? p->free.next->free.depth+1 : 0; diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 098e0d5ba8..ed73fc6163 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -2109,7 +2109,7 @@ static int wctoint(WCHAR c, int base) 0xd66, 0xe50, 0xed0, 0xf20, 0x1040, 0x17e0, 0x1810, 0xff10 }; int i; - for (i = 0; i < sizeof(zeros)/sizeof(zeros[0]) && c >= zeros[i]; ++i) { + for (i = 0; i < ARRAY_SIZE(zeros) && c >= zeros[i]; ++i) { if (zeros[i] <= c && c <= zeros[i] + 9) { v = c - zeros[i]; break; -- 2.14.4
5 years, 9 months
2
1
0
0
[PATCH] urlmon: Use the ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/urlmon/urlmon_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/urlmon/urlmon_main.c b/dlls/urlmon/urlmon_main.c index 5968a6ce55..06f0698efa 100644 --- a/dlls/urlmon/urlmon_main.c +++ b/dlls/urlmon/urlmon_main.c @@ -409,7 +409,7 @@ static void init_session(void) { unsigned int i; - for(i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) { + for(i = 0; i < ARRAY_SIZE(object_creation); i++) { if(object_creation[i].protocol) register_namespace(object_creation[i].cf, object_creation[i].clsid, object_creation[i].protocol, TRUE); @@ -438,10 +438,10 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) { unsigned int i; HRESULT hr; - + TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); - - for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++) + + for (i = 0; i < ARRAY_SIZE(object_creation); i++) { if (IsEqualGUID(object_creation[i].clsid, rclsid)) return IClassFactory_QueryInterface(object_creation[i].cf, riid, ppv); -- 2.14.4
5 years, 9 months
2
1
0
0
[PATCH] localspl: Use the ARRAY_SIZE() macro
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> --- dlls/localspl/localmon.c | 10 +++++----- dlls/localspl/provider.c | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dlls/localspl/localmon.c b/dlls/localspl/localmon.c index 4be1ad6101..8553aa2297 100644 --- a/dlls/localspl/localmon.c +++ b/dlls/localspl/localmon.c @@ -279,10 +279,10 @@ static DWORD get_type_from_name(LPCWSTR name) { HANDLE hfile; - if (!strncmpW(name, portname_LPT, sizeof(portname_LPT) / sizeof(WCHAR) -1)) + if (!strncmpW(name, portname_LPT, ARRAY_SIZE(portname_LPT) - 1)) return PORT_IS_LPT; - if (!strncmpW(name, portname_COM, sizeof(portname_COM) / sizeof(WCHAR) -1)) + if (!strncmpW(name, portname_COM, ARRAY_SIZE(portname_COM) - 1)) return PORT_IS_COM; if (!strcmpW(name, portname_FILE)) @@ -294,10 +294,10 @@ static DWORD get_type_from_name(LPCWSTR name) if (name[0] == '|') return PORT_IS_PIPE; - if (!strncmpW(name, portname_CUPS, sizeof(portname_CUPS) / sizeof(WCHAR) -1)) + if (!strncmpW(name, portname_CUPS, ARRAY_SIZE(portname_CUPS) - 1)) return PORT_IS_CUPS; - if (!strncmpW(name, portname_LPR, sizeof(portname_LPR) / sizeof(WCHAR) -1)) + if (!strncmpW(name, portname_LPR, ARRAY_SIZE(portname_LPR) - 1)) return PORT_IS_LPR; /* Must be a file or a directory. Does the file exist ? */ @@ -704,7 +704,7 @@ static DWORD WINAPI localmon_XcvDataPort(HANDLE hXcv, LPCWSTR pszDataName, PBYTE { ptr = ((xcv_t *)hXcv)->nameW; } - lstrcpynW(buffer, ptr, sizeof(buffer)/sizeof(WCHAR)); + lstrcpynW(buffer, ptr, ARRAY_SIZE(buffer)); if (buffer[0]) buffer[lstrlenW(buffer)-1] = '\0'; /* remove the ':' */ res = SetDefaultCommConfigW(buffer, (LPCOMMCONFIG) pInputData, cbInputData); TRACE("got %u with %u\n", res, GetLastError() ); diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c index 3538947281..c17d982fa7 100644 --- a/dlls/localspl/provider.c +++ b/dlls/localspl/provider.c @@ -275,7 +275,7 @@ static LONG copy_servername_from_name(LPCWSTR name, LPWSTR target) target[serverlen] = '\0'; } - len = sizeof(buffer) / sizeof(buffer[0]); + len = ARRAY_SIZE(buffer); if (GetComputerNameW(buffer, &len)) { if ((serverlen == len) && (strncmpiW(server, buffer, len) == 0)) { /* The requested Servername is our computername */ @@ -693,7 +693,7 @@ static const printenv_t * validate_envW(LPCWSTR env) TRACE("(%s)\n", debugstr_w(env)); if (env && env[0]) { - for (i = 0; i < sizeof(all_printenv)/sizeof(all_printenv[0]); i++) + for (i = 0; i < ARRAY_SIZE(all_printenv); i++) { if (lstrcmpiW(env, all_printenv[i]->envname) == 0) { @@ -749,7 +749,7 @@ static DWORD get_local_monitors(DWORD level, LPBYTE pMonitors, DWORD cbBuf, LPDW ptr = (LPWSTR) &pMonitors[len]; numentries = 0; - len = sizeof(buffer)/sizeof(buffer[0]); + len = ARRAY_SIZE(buffer); buffer[0] = '\0'; /* Windows creates the "Monitors"-Key on reboot / start "spooler" */ @@ -802,7 +802,7 @@ static DWORD get_local_monitors(DWORD level, LPBYTE pMonitors, DWORD cbBuf, LPDW } } index++; - len = sizeof(buffer)/sizeof(buffer[0]); + len = ARRAY_SIZE(buffer); buffer[0] = '\0'; } RegCloseKey(hroot); @@ -838,7 +838,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb ptr = (LPWSTR) &pPPInfo[len]; numentries = 0; - len = sizeof(buffer)/sizeof(buffer[0]); + len = ARRAY_SIZE(buffer); buffer[0] = '\0'; if (RegCreateKeyW(HKEY_LOCAL_MACHINE, regpathW, &hroot) == ERROR_SUCCESS) { @@ -852,7 +852,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb TRACE("%p: writing PRINTPROCESSOR_INFO_1W #%d\n", ppi, numentries); ppi->pName = ptr; lstrcpyW(ptr, winprintW); /* Name of the Print Processor */ - ptr += sizeof(winprintW) / sizeof(WCHAR); + ptr += ARRAY_SIZE(winprintW); } /* Scan all Printprocessor Keys */ @@ -888,7 +888,7 @@ static DWORD get_local_printprocessors(LPWSTR regpathW, LPBYTE pPPInfo, DWORD cb } } index++; - len = sizeof(buffer)/sizeof(buffer[0]); + len = ARRAY_SIZE(buffer); buffer[0] = '\0'; } RegCloseKey(hroot); @@ -1196,7 +1196,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault) printer = NULL; } if (printername) { - len = sizeof(XcvMonitorW)/sizeof(WCHAR) - 1; + len = ARRAY_SIZE(XcvMonitorW) - 1; if (strncmpW(printername, XcvMonitorW, len) == 0) { /* OpenPrinter(",XcvMonitor ", ...) detected */ TRACE(",XcvMonitor: %s\n", debugstr_w(&printername[len])); @@ -1210,7 +1210,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault) } else { - len = sizeof(XcvPortW)/sizeof(WCHAR) - 1; + len = ARRAY_SIZE(XcvPortW) - 1; if (strncmpW( printername, XcvPortW, len) == 0) { /* OpenPrinter(",XcvPort ", ...) detected */ TRACE(",XcvPort: %s\n", debugstr_w(&printername[len])); @@ -1303,7 +1303,7 @@ static BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCo DRIVER_INFO, that the caller supplied */ ZeroMemory(&di, sizeof(di)); - if (pDriverInfo && (level < (sizeof(di_sizeof) / sizeof(di_sizeof[0])))) { + if (pDriverInfo && (level < ARRAY_SIZE(di_sizeof))) { memcpy(&di, pDriverInfo, di_sizeof[level]); } -- 2.14.4
5 years, 9 months
2
1
0
0
[PATCH v2 8/8] comctl32/taskdialog: Fix center positioning.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 6875b9ce4f..f69fa6aaa3 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -2,6 +2,7 @@ * Task dialog control * * Copyright 2017 Fabian Maurer + * Copyright 2018 Zhiyi Zhang * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1101,8 +1102,8 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info) if (first_time) { - x = (ref_rect.left + ref_rect.right + dialog_width) / 2; - y = (ref_rect.top + ref_rect.bottom + dialog_height) / 2; + x = (ref_rect.left + ref_rect.right - dialog_width) / 2; + y = (ref_rect.top + ref_rect.bottom - dialog_height) / 2; SetWindowPos(dialog_info->hwnd, 0, x, y, dialog_width, dialog_height, SWP_NOZORDER); first_time = FALSE; } -- 2.18.0
5 years, 9 months
2
1
0
0
[PATCH v2 7/8] comctl32/taskdialog: Add vertical spacing for radio buttons.
by Zhiyi Zhang
Add vertical spacing to make dialog look nicer. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 1bc37861f8..6875b9ce4f 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -939,7 +939,7 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info) for (i = 0; i < dialog_info->radio_button_count; i++) { x = main_icon_right + h_spacing; - y = dialog_height; + y = dialog_height + v_spacing; taskdialog_get_radio_button_size(dialog_info, dialog_info->radio_buttons[i], dialog_width - x - h_spacing, &size); size.cx = dialog_width - x - h_spacing; SetWindowPos(dialog_info->radio_buttons[i], 0, x, y, size.cx, size.cy, SWP_NOZORDER); -- 2.18.0
5 years, 9 months
2
1
0
0
[PATCH v2 6/8] comctl32/taskdialog: Add support for TDM_UPDATE_ICON.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 6154e76be1..1bc37861f8 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -1306,6 +1306,9 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE: taskdialog_button_set_shield(dialog_info, wParam, lParam); break; + case TDM_UPDATE_ICON: + taskdialog_set_icon(dialog_info, wParam, (HICON)lParam); + break; case WM_INITDIALOG: dialog_info = (struct taskdialog_info *)lParam; -- 2.18.0
5 years, 9 months
2
1
0
0
[PATCH v2 5/8] comctl32/taskdialog: Add support for TDF_SIZE_TO_CONTENT.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index ffa8ee2fe8..6154e76be1 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -828,6 +828,36 @@ static void taskdialog_add_footer_text(struct taskdialog_info *dialog_info) dialog_info->font, taskdialog_hyperlink_enabled(dialog_info)); } +static LONG taskdialog_get_dialog_width(struct taskdialog_info *dialog_info) +{ + const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig; + BOOL syslink = taskdialog_hyperlink_enabled(dialog_info); + LONG max_width, main_icon_width, screen_width; + RECT rect; + SIZE size; + + screen_width = taskdialog_get_reference_rect(taskconfig, &rect); + if ((taskconfig->dwFlags & TDF_SIZE_TO_CONTENT) && !taskconfig->cxWidth) + { + max_width = DIALOG_MIN_WIDTH; + taskdialog_du_to_px(dialog_info, &max_width, NULL); + main_icon_width = dialog_info->m.h_spacing; + if (dialog_info->main_icon) main_icon_width += GetSystemMetrics(SM_CXICON); + if (dialog_info->content) + { + taskdialog_get_label_size(dialog_info, dialog_info->content, 0, &size, syslink); + max_width = max(max_width, size.cx + main_icon_width + dialog_info->m.h_spacing * 2); + } + } + else + { + max_width = max(taskconfig->cxWidth, DIALOG_MIN_WIDTH); + taskdialog_du_to_px(dialog_info, &max_width, NULL); + } + max_width = min(max_width, screen_width); + return max_width; +} + static void taskdialog_label_layout(struct taskdialog_info *dialog_info, HWND hwnd, INT start_x, LONG dialog_width, LONG *dialog_height, BOOL syslink) { @@ -850,7 +880,7 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info) BOOL syslink = taskdialog_hyperlink_enabled(dialog_info); static BOOL first_time = TRUE; RECT ref_rect; - LONG screen_width, dialog_width, dialog_height = 0; + LONG dialog_width, dialog_height = 0; LONG h_spacing, v_spacing; LONG main_icon_right, main_icon_bottom; LONG expando_right, expando_bottom; @@ -862,10 +892,8 @@ static void taskdialog_layout(struct taskdialog_info *dialog_info) SIZE size; INT i; - screen_width = taskdialog_get_reference_rect(dialog_info->taskconfig, &ref_rect); - dialog_width = max(taskconfig->cxWidth, DIALOG_MIN_WIDTH); - taskdialog_du_to_px(dialog_info, &dialog_width, 0); - dialog_width = min(dialog_width, screen_width); + taskdialog_get_reference_rect(dialog_info->taskconfig, &ref_rect); + dialog_width = taskdialog_get_dialog_width(dialog_info); h_spacing = dialog_info->m.h_spacing; v_spacing = dialog_info->m.v_spacing; -- 2.18.0
5 years, 9 months
2
1
0
0
[PATCH v2 4/8] comctl32/taskdialog: Add support for TDM_{SET,UPDATE}_ELEMENT_TEXT.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index dd7369645f..ffa8ee2fe8 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -542,6 +542,28 @@ static void taskdialog_set_icon(struct taskdialog_info *dialog_info, INT element SendMessageW(dialog_info->footer_icon, STM_SETICON, (WPARAM)hicon, 0); } +static void taskdialog_set_element_text(struct taskdialog_info *dialog_info, TASKDIALOG_ELEMENTS element, + const WCHAR *text) +{ + HWND hwnd = NULL; + WCHAR *textW; + + if (element == TDE_CONTENT) + hwnd = dialog_info->content; + else if (element == TDE_EXPANDED_INFORMATION) + hwnd = dialog_info->expanded_info; + else if (element == TDE_FOOTER) + hwnd = dialog_info->footer_text; + else if (element == TDE_MAIN_INSTRUCTION) + hwnd = dialog_info->main_instruction; + + if (!hwnd) return; + + textW = taskdialog_gettext(dialog_info, TRUE, text); + SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)textW); + Free(textW); +} + static void taskdialog_check_default_radio_buttons(struct taskdialog_info *dialog_info) { const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig; @@ -1227,6 +1249,13 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case TDM_SET_PROGRESS_BAR_MARQUEE: SendMessageW(dialog_info->progress_bar, PBM_SETMARQUEE, wParam, lParam); break; + case TDM_SET_ELEMENT_TEXT: + taskdialog_set_element_text(dialog_info, wParam, (const WCHAR *)lParam); + taskdialog_layout(dialog_info); + break; + case TDM_UPDATE_ELEMENT_TEXT: + taskdialog_set_element_text(dialog_info, wParam, (const WCHAR *)lParam); + break; case TDM_CLICK_RADIO_BUTTON: taskdialog_click_radio_button(dialog_info, wParam); break; -- 2.18.0
5 years, 9 months
2
1
0
0
[PATCH v2 3/8] comctl32/taskdialog: Add support for TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index efe159f891..dd7369645f 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -212,6 +212,13 @@ static void taskdialog_click_button(struct taskdialog_info *dialog_info, INT id) if (hwnd) taskdialog_on_button_click(dialog_info, hwnd); } +static void taskdialog_button_set_shield(const struct taskdialog_info *dialog_info, INT id, BOOL elevate) +{ + HWND hwnd = taskdialog_find_button(dialog_info->command_links, dialog_info->command_link_count, id); + if (!hwnd) hwnd = taskdialog_find_button(dialog_info->buttons, dialog_info->button_count, id); + if (hwnd) SendMessageW(hwnd, BCM_SETSHIELD, 0, elevate); +} + static void taskdialog_enable_radio_button(const struct taskdialog_info *dialog_info, INT id, BOOL enable) { HWND hwnd = taskdialog_find_button(dialog_info->radio_buttons, dialog_info->radio_button_count, id); @@ -1239,6 +1246,9 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR } break; } + case TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE: + taskdialog_button_set_shield(dialog_info, wParam, lParam); + break; case WM_INITDIALOG: dialog_info = (struct taskdialog_info *)lParam; -- 2.18.0
5 years, 9 months
2
1
0
0
[PATCH v2 2/8] comctl32/taskdialog: Add support for navigating page.
by Zhiyi Zhang
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/taskdialog.c | 17 ++++++++++ dlls/comctl32/tests/taskdialog.c | 58 ++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index c6a3aa7ae5..efe159f891 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -1142,8 +1142,16 @@ static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd) taskdialog_layout(dialog_info); } +static BOOL CALLBACK takdialog_destroy_control(HWND hwnd, LPARAM lParam) +{ + DestroyWindow(hwnd); + return TRUE; +} + static void taskdialog_destroy(struct taskdialog_info *dialog_info) { + EnumChildWindows(dialog_info->hwnd, takdialog_destroy_control, 0); + if (dialog_info->taskconfig->dwFlags & TDF_CALLBACK_TIMER) KillTimer(dialog_info->hwnd, ID_TIMER); if (dialog_info->font) DeleteObject(dialog_info->font); if (dialog_info->main_instruction_font) DeleteObject(dialog_info->main_instruction_font); @@ -1167,6 +1175,15 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR switch (msg) { + case TDM_NAVIGATE_PAGE: + dialog_info->taskconfig = (const TASKDIALOGCONFIG *)lParam; + taskdialog_destroy(dialog_info); + taskdialog_init(dialog_info, hwnd); + taskdialog_notify(dialog_info, TDN_DIALOG_CONSTRUCTED, 0, 0); + /* Default radio button click notification is sent before TDN_NAVIGATED */ + taskdialog_check_default_radio_buttons(dialog_info); + taskdialog_notify(dialog_info, TDN_NAVIGATED, 0, 0); + break; case TDM_CLICK_BUTTON: taskdialog_click_button(dialog_info, wParam); break; diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c index 8d60fb2eb8..093671c30f 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -271,6 +271,25 @@ static const struct message_info msg_return_verification_checked[] = { 0 } }; +static TASKDIALOGCONFIG navigated_info = {0}; + +static const struct message_info msg_send_navigate[] = +{ + { TDM_NAVIGATE_PAGE, 0, (LPARAM)&navigated_info, 0}, + { 0 } +}; + +static const struct message_info msg_return_navigated_page[] = +{ + { TDN_CREATED, 0, 0, S_OK, NULL }, + { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON, 0, S_OK, msg_send_navigate }, + { TDN_DIALOG_CONSTRUCTED, 0, 0, S_OK, NULL }, + { TDN_RADIO_BUTTON_CLICKED, ID_START_RADIO_BUTTON, 0, S_OK, NULL }, + { TDN_NAVIGATED, 0, 0, S_OK, msg_send_click_ok }, + { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, NULL }, + { 0 } +}; + static void init_test_message(UINT message, WPARAM wParam, LPARAM lParam, struct message *msg) { msg->message = WM_TD_CALLBACK; @@ -682,6 +701,44 @@ static void test_verification_box(void) "default verification box: default unchecked and then checked"); } +static void test_navigate_page(void) +{ + TASKDIALOGCONFIG info = {0}; + static const WCHAR textW[] = {'t', 'e', 'x', 't', 0}; + static const WCHAR button_format[] = {'%', '0', '2', 'd', 0}; + TASKDIALOG_BUTTON radio_buttons[TEST_NUM_RADIO_BUTTONS]; + WCHAR radio_button_titles[TEST_NUM_BUTTONS * 3]; + int i; + + /* Init radio buttons */ + for (i = 0; i < TEST_NUM_RADIO_BUTTONS; i++) + { + WCHAR *text = &radio_button_titles[i * 3]; + wsprintfW(text, button_format, i); + + radio_buttons[i].pszButtonText = text; + radio_buttons[i].nButtonID = ID_START_RADIO_BUTTON + i; + } + + info.cbSize = sizeof(TASKDIALOGCONFIG); + info.pfCallback = taskdialog_callback_proc; + info.lpCallbackData = test_ref_data; + info.dwCommonButtons = TDCBF_OK_BUTTON; + info.cRadioButtons = TEST_NUM_RADIO_BUTTONS; + info.pRadioButtons = radio_buttons; + + navigated_info = info; + navigated_info.pszVerificationText = textW; + navigated_info.dwFlags = TDF_VERIFICATION_FLAG_CHECKED; + + run_test(&info, IDOK, ID_START_RADIO_BUTTON, TRUE, msg_return_navigated_page, "navigate page: default"); + + /* TDM_NAVIGATE_PAGE doesn't check cbSize. + * And null taskconfig pointer crash applicatioin, thus doesn't check pointer either */ + navigated_info.cbSize = 0; + run_test(&info, IDOK, ID_START_RADIO_BUTTON, TRUE, msg_return_navigated_page, "navigate page: invalid taskconfig cbSize"); +} + START_TEST(taskdialog) { ULONG_PTR ctx_cookie; @@ -722,6 +779,7 @@ START_TEST(taskdialog) test_timer(); test_progress_bar(); test_verification_box(); + test_navigate_page(); unload_v6_module(ctx_cookie, hCtx); } -- 2.18.0
5 years, 9 months
2
1
0
0
← Newer
1
2
3
4
5
...
64
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Results per page:
10
25
50
100
200