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
2025
April
March
February
January
2024
December
November
October
September
August
July
June
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
wine-commits
September 2016
----- 2025 -----
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 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
wine-commits@winehq.org
2 participants
430 discussions
Start a n
N
ew thread
Alexandre Julliard : winex11: Remove support for exporting the CF_METAFILEPICT format.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 29fc759d529ab69d0af416a547552cfa4099ab17 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=29fc759d529ab69d0af416a54…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 27 21:40:36 2016 +0900 winex11: Remove support for exporting the CF_METAFILEPICT format. It can be synthesized from CF_ENHMETAFILE. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/clipboard.c | 47 ------------------------------------------ dlls/winex11.drv/x11drv.h | 1 - dlls/winex11.drv/x11drv_main.c | 1 - 3 files changed, 49 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 63d11dd..4ee8604 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -110,7 +110,6 @@ struct clipboard_format static HANDLE import_data( Atom type, const void *data, size_t size ); static HANDLE import_enhmetafile( Atom type, const void *data, size_t size ); -static HANDLE import_metafile( Atom type, const void *data, size_t size ); static HANDLE import_pixmap( Atom type, const void *data, size_t size ); static HANDLE import_image_bmp( Atom type, const void *data, size_t size ); static HANDLE import_string( Atom type, const void *data, size_t size ); @@ -125,7 +124,6 @@ static BOOL export_utf8_string( Display *display, Window win, Atom prop, Atom ta static BOOL export_compound_text( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); static BOOL export_pixmap( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); static BOOL export_image_bmp( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); -static BOOL export_metafile( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); static BOOL export_enhmetafile( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); static BOOL export_text_html( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); static BOOL export_hdrop( Display *display, Window win, Atom prop, Atom target, HANDLE handle ); @@ -157,7 +155,6 @@ static const struct { 0, CF_UNICODETEXT, XA_STRING, import_string, export_string }, { 0, CF_UNICODETEXT, XATOM_text_plain, import_string, export_string }, { 0, CF_BITMAP, XATOM_WCF_BITMAP, import_data, NULL }, - { 0, CF_METAFILEPICT, XATOM_WCF_METAFILEPICT, import_metafile, export_metafile }, { 0, CF_SYLK, XATOM_WCF_SYLK, import_data, export_data }, { 0, CF_DIF, XATOM_WCF_DIF, import_data, export_data }, { 0, CF_TIFF, XATOM_WCF_TIFF, import_data, export_data }, @@ -814,24 +811,6 @@ static HANDLE import_image_bmp( Atom type, const void *data, size_t size ) /************************************************************************** - * import_metafile - */ -static HANDLE import_metafile( Atom type, const void *data, size_t size ) -{ - METAFILEPICT *mf; - - if (size < sizeof(METAFILEPICT)) return 0; - if ((mf = GlobalAlloc( GMEM_FIXED, sizeof(METAFILEPICT) ))) - { - memcpy( mf, data, sizeof(METAFILEPICT) ); - mf->hMF = SetMetaFileBitsEx( size - sizeof(METAFILEPICT), - (const BYTE *)data + sizeof(METAFILEPICT) ); - } - return mf; -} - - -/************************************************************************** * import_enhmetafile */ static HANDLE import_enhmetafile( Atom type, const void *data, size_t size ) @@ -1224,32 +1203,6 @@ static BOOL export_image_bmp( Display *display, Window win, Atom prop, Atom targ /************************************************************************** - * export_metafile - * - * Export MetaFilePict. - */ -static BOOL export_metafile( Display *display, Window win, Atom prop, Atom target, HANDLE handle ) -{ - METAFILEPICT *src, *dst; - unsigned int size; - - src = GlobalLock( handle ); - size = GetMetaFileBitsEx(src->hMF, 0, NULL); - - dst = HeapAlloc( GetProcessHeap(), 0, size + sizeof(*dst) ); - if (dst) - { - *dst = *src; - GetMetaFileBitsEx( src->hMF, size, dst + 1 ); - } - GlobalUnlock( handle ); - put_property( display, win, prop, target, 8, dst, size + sizeof(*dst) ); - HeapFree( GetProcessHeap(), 0, dst ); - return TRUE; -} - - -/************************************************************************** * export_enhmetafile * * Export EnhMetaFile. diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index ae0bc9c..f50b798 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -465,7 +465,6 @@ enum x11drv_atoms XATOM_WCF_ENHMETAFILE, XATOM_WCF_HDROP, XATOM_WCF_LOCALE, - XATOM_WCF_METAFILEPICT, XATOM_WCF_OEMTEXT, XATOM_WCF_PALETTE, XATOM_WCF_PENDATA, diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 4391360..e67b4c4 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -176,7 +176,6 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] = "WCF_ENHMETAFILE", "WCF_HDROP", "WCF_LOCALE", - "WCF_METAFILEPICT", "WCF_OEMTEXT", "WCF_PALETTE", "WCF_PENDATA",
1
0
0
0
Alexandre Julliard : winex11: Remove support for owner-displayed clipboard formats.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 82dfbba5c6f79b3668cfe846ba5744635ac8caa6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=82dfbba5c6f79b3668cfe846b…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 27 21:40:15 2016 +0900 winex11: Remove support for owner-displayed clipboard formats. It cannot work across prefixes, and it didn't work previously either. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/clipboard.c | 5 ----- dlls/winex11.drv/x11drv.h | 5 ----- dlls/winex11.drv/x11drv_main.c | 5 ----- 3 files changed, 15 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 611ecee..63d11dd 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -171,11 +171,6 @@ static const struct { 0, CF_HDROP, XATOM_text_uri_list, import_text_uri_list, export_hdrop }, { 0, CF_LOCALE, XATOM_WCF_LOCALE, import_data, export_data }, { 0, CF_DIBV5, XATOM_WCF_DIBV5, import_data, export_data }, - { 0, CF_OWNERDISPLAY, XATOM_WCF_OWNERDISPLAY, import_data, export_data }, - { 0, CF_DSPTEXT, XATOM_WCF_DSPTEXT, import_data, export_data }, - { 0, CF_DSPBITMAP, XATOM_WCF_DSPBITMAP, import_data, export_data }, - { 0, CF_DSPMETAFILEPICT, XATOM_WCF_DSPMETAFILEPICT, import_data, export_data }, - { 0, CF_DSPENHMETAFILE, XATOM_WCF_DSPENHMETAFILE, import_data, export_data }, { 0, CF_DIB, XATOM_image_bmp, import_image_bmp, export_image_bmp }, { RichTextFormatW, 0, XATOM_text_rtf, import_data, export_data }, { RichTextFormatW, 0, XATOM_text_richtext, import_data, export_data }, diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index d622468..ae0bc9c 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -462,16 +462,11 @@ enum x11drv_atoms XATOM_WCF_DIB, XATOM_WCF_DIBV5, XATOM_WCF_DIF, - XATOM_WCF_DSPBITMAP, - XATOM_WCF_DSPENHMETAFILE, - XATOM_WCF_DSPMETAFILEPICT, - XATOM_WCF_DSPTEXT, XATOM_WCF_ENHMETAFILE, XATOM_WCF_HDROP, XATOM_WCF_LOCALE, XATOM_WCF_METAFILEPICT, XATOM_WCF_OEMTEXT, - XATOM_WCF_OWNERDISPLAY, XATOM_WCF_PALETTE, XATOM_WCF_PENDATA, XATOM_WCF_RIFF, diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 41097f4..4391360 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -173,16 +173,11 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] = "WCF_DIB", "WCF_DIBV5", "WCF_DIF", - "WCF_DSPBITMAP", - "WCF_DSPENHMETAFILE", - "WCF_DSPMETAFILEPICT", - "WCF_DSPTEXT", "WCF_ENHMETAFILE", "WCF_HDROP", "WCF_LOCALE", "WCF_METAFILEPICT", "WCF_OEMTEXT", - "WCF_OWNERDISPLAY", "WCF_PALETTE", "WCF_PENDATA", "WCF_RIFF",
1
0
0
0
Alexandre Julliard : winex11: Always go through Unicode for clipboard strings.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: aa4b29b9bc4a7f9a5dcf46e63417fd7081f258d3 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=aa4b29b9bc4a7f9a5dcf46e63…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 27 21:36:13 2016 +0900 winex11: Always go through Unicode for clipboard strings. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/clipboard.c | 59 +++++++++----------------------------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 9f78e3d..611ecee 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -152,8 +152,10 @@ static const struct EXPORTFUNC export; } builtin_formats[] = { - { 0, CF_TEXT, XA_STRING, import_string, export_string }, - { 0, CF_TEXT, XATOM_text_plain, import_string, export_string }, + { 0, CF_UNICODETEXT, XATOM_UTF8_STRING, import_utf8_string, export_utf8_string }, + { 0, CF_UNICODETEXT, XATOM_COMPOUND_TEXT, import_compound_text, export_compound_text }, + { 0, CF_UNICODETEXT, XA_STRING, import_string, export_string }, + { 0, CF_UNICODETEXT, XATOM_text_plain, import_string, export_string }, { 0, CF_BITMAP, XATOM_WCF_BITMAP, import_data, NULL }, { 0, CF_METAFILEPICT, XATOM_WCF_METAFILEPICT, import_metafile, export_metafile }, { 0, CF_SYLK, XATOM_WCF_SYLK, import_data, export_data }, @@ -165,8 +167,6 @@ static const struct { 0, CF_PENDATA, XATOM_WCF_PENDATA, import_data, export_data }, { 0, CF_RIFF, XATOM_WCF_RIFF, import_data, export_data }, { 0, CF_WAVE, XATOM_WCF_WAVE, import_data, export_data }, - { 0, CF_UNICODETEXT, XATOM_UTF8_STRING, import_utf8_string, export_utf8_string }, - { 0, CF_UNICODETEXT, XATOM_COMPOUND_TEXT, import_compound_text, export_compound_text }, { 0, CF_ENHMETAFILE, XATOM_WCF_ENHMETAFILE, import_enhmetafile, export_enhmetafile }, { 0, CF_HDROP, XATOM_text_uri_list, import_text_uri_list, export_hdrop }, { 0, CF_LOCALE, XATOM_WCF_LOCALE, import_data, export_data }, @@ -683,32 +683,11 @@ static HANDLE unicode_text_from_string( UINT codepage, const void *data, size_t /************************************************************************** * import_string * - * Import XA_STRING, converting the string to CF_TEXT. + * Import XA_STRING, converting the string to CF_UNICODETEXT. */ static HANDLE import_string( Atom type, const void *data, size_t size ) { - const char *lpdata = data; - LPSTR lpstr; - size_t i, inlcount = 0; - - for (i = 0; i < size; i++) - { - if (lpdata[i] == '\n') - inlcount++; - } - - if ((lpstr = GlobalAlloc( GMEM_FIXED, size + inlcount + 1 ))) - { - for (i = 0, inlcount = 0; i < size; i++) - { - if (lpdata[i] == '\n') - lpstr[inlcount++] = '\r'; - - lpstr[inlcount++] = lpdata[i]; - } - lpstr[inlcount] = 0; - } - return lpstr; + return unicode_text_from_string( 28591, data, size ); } @@ -1130,32 +1109,16 @@ static char *string_from_unicode_text( UINT codepage, HANDLE handle, UINT *size /************************************************************************** * export_string * - * Export CF_TEXT converting the string to XA_STRING. + * Export CF_UNICODETEXT converting the string to XA_STRING. */ static BOOL export_string( Display *display, Window win, Atom prop, Atom target, HANDLE handle ) { - UINT i, j; UINT size; - LPSTR text, lpstr = NULL; - - text = GlobalLock( handle ); - size = strlen(text); + char *text = string_from_unicode_text( 28591, handle, &size ); - /* remove carriage returns */ - lpstr = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size + 1); - if (lpstr == NULL) - { - GlobalUnlock( handle ); - return FALSE; - } - for (i = 0,j = 0; i < size && text[i]; i++) - { - if (text[i] == '\r' && (text[i+1] == '\n' || text[i+1] == '\0')) - continue; - lpstr[j++] = text[i]; - } - put_property( display, win, prop, target, 8, lpstr, j ); - HeapFree( GetProcessHeap(), 0, lpstr ); + if (!text) return FALSE; + put_property( display, win, prop, target, 8, text, size ); + HeapFree( GetProcessHeap(), 0, text ); GlobalUnlock( handle ); return TRUE; }
1
0
0
0
Alexandre Julliard : winex11: Add a helper function to export a Unicode string.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 8493fc782b8e183bb0a1b777a791d68d5433b23b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8493fc782b8e183bb0a1b777a…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 27 21:24:25 2016 +0900 winex11: Add a helper function to export a Unicode string. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/clipboard.c | 97 +++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 56 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 983ee58..9f78e3d 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1095,6 +1095,39 @@ static BOOL export_data( Display *display, Window win, Atom prop, Atom target, H /************************************************************************** + * string_from_unicode_text + * + * Convert CF_UNICODETEXT data to a string in the specified codepage. + */ +static char *string_from_unicode_text( UINT codepage, HANDLE handle, UINT *size ) +{ + UINT i, j; + char *str; + WCHAR *strW = GlobalLock( handle ); + UINT lenW = GlobalSize( handle ) / sizeof(WCHAR); + DWORD len = WideCharToMultiByte( codepage, 0, strW, lenW, NULL, 0, NULL, NULL ); + + if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) + { + WideCharToMultiByte( codepage, 0, strW, lenW, str, len, NULL, NULL); + GlobalUnlock( handle ); + + /* remove carriage returns */ + for (i = j = 0; i < len; i++) + { + if (str[i] == '\r' && (i == len - 1 || str[i + 1] == '\n')) continue; + str[j++] = str[i]; + } + if (j && !str[j - 1]) j--; /* remove trailing null */ + *size = j; + TRACE( "returning %s\n", debugstr_an( str, j )); + } + GlobalUnlock( handle ); + return str; +} + + +/************************************************************************** * export_string * * Export CF_TEXT converting the string to XA_STRING. @@ -1135,38 +1168,12 @@ static BOOL export_string( Display *display, Window win, Atom prop, Atom target, */ static BOOL export_utf8_string( Display *display, Window win, Atom prop, Atom target, HANDLE handle ) { - UINT i, j; UINT size; - LPSTR text, lpstr; - LPWSTR uni_text = GlobalLock( handle ); - - size = WideCharToMultiByte(CP_UTF8, 0, uni_text, -1, NULL, 0, NULL, NULL); - text = HeapAlloc(GetProcessHeap(), 0, size); - if (!text) - { - GlobalUnlock( handle ); - return FALSE; - } + char *text = string_from_unicode_text( CP_UTF8, handle, &size ); - WideCharToMultiByte(CP_UTF8, 0, uni_text, -1, text, size, NULL, NULL); - GlobalUnlock( handle ); - - /* remove carriage returns */ - lpstr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size--); - if (lpstr == NULL) - { - HeapFree(GetProcessHeap(), 0, text); - return FALSE; - } - for (i = 0,j = 0; i < size && text[i]; i++) - { - if (text[i] == '\r' && (text[i+1] == '\n' || text[i+1] == '\0')) - continue; - lpstr[j++] = text[i]; - } - put_property( display, win, prop, target, 8, lpstr, j ); - HeapFree(GetProcessHeap(), 0, lpstr); - HeapFree(GetProcessHeap(), 0, text); + if (!text) return FALSE; + put_property( display, win, prop, target, 8, text, size ); + HeapFree( GetProcessHeap(), 0, text ); GlobalUnlock( handle ); return TRUE; } @@ -1179,47 +1186,25 @@ static BOOL export_utf8_string( Display *display, Window win, Atom prop, Atom ta */ static BOOL export_compound_text( Display *display, Window win, Atom prop, Atom target, HANDLE handle ) { - char* lpstr; XTextProperty textprop; XICCEncodingStyle style; - UINT i, j; UINT size; - LPWSTR uni_text = GlobalLock( handle ); - - size = WideCharToMultiByte(CP_UNIXCP, 0, uni_text, -1, NULL, 0, NULL, NULL); - lpstr = HeapAlloc(GetProcessHeap(), 0, size); - if (!lpstr) - { - GlobalUnlock( handle ); - return FALSE; - } - - WideCharToMultiByte(CP_UNIXCP, 0, uni_text, -1, lpstr, size, NULL, NULL); - - /* remove carriage returns */ - for (i = 0, j = 0; i < size && lpstr[i]; i++) - { - if (lpstr[i] == '\r' && (lpstr[i+1] == '\n' || lpstr[i+1] == '\0')) - continue; - lpstr[j++] = lpstr[i]; - } - lpstr[j]='\0'; - - GlobalUnlock( handle ); + char *text = string_from_unicode_text( CP_UNIXCP, handle, &size ); + if (!text) return FALSE; if (target == x11drv_atom(COMPOUND_TEXT)) style = XCompoundTextStyle; else style = XStdICCTextStyle; /* Update the X property */ - if (XmbTextListToTextProperty( display, &lpstr, 1, style, &textprop ) == Success) + if (XmbTextListToTextProperty( display, &text, 1, style, &textprop ) == Success) { XSetTextProperty( display, win, &textprop, prop ); XFree( textprop.value ); } - HeapFree(GetProcessHeap(), 0, lpstr); + HeapFree( GetProcessHeap(), 0, text ); return TRUE; }
1
0
0
0
Alexandre Julliard : winex11: Add a helper function to import a Unicode string.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 1e7878cfa57e40e707356eac2542086ddf8e413a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1e7878cfa57e40e707356eac2…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 27 21:13:07 2016 +0900 winex11: Add a helper function to import a Unicode string. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/clipboard.c | 102 +++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 68 deletions(-) diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index d0d301b..983ee58 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -654,6 +654,33 @@ static WCHAR* uri_to_dos(char *encodedURI) /************************************************************************** + * unicode_text_from_string + * + * Convert a string in the specified encoding to CF_UNICODETEXT format. + */ +static HANDLE unicode_text_from_string( UINT codepage, const void *data, size_t size ) +{ + DWORD i, j, count; + WCHAR *strW; + + count = MultiByteToWideChar( codepage, 0, data, size, NULL, 0); + + if (!(strW = GlobalAlloc( GMEM_FIXED, (count * 2 + 1) * sizeof(WCHAR) ))) return 0; + + MultiByteToWideChar( codepage, 0, data, size, strW + count, count ); + for (i = j = 0; i < count; i++) + { + if (strW[i + count] == '\n') strW[j++] = '\r'; + strW[j++] = strW[i + count]; + } + strW[j++] = 0; + GlobalReAlloc( strW, j * sizeof(WCHAR), GMEM_FIXED ); /* release unused space */ + TRACE( "returning %s\n", debugstr_wn( strW, j - 1 )); + return strW; +} + + +/************************************************************************** * import_string * * Import XA_STRING, converting the string to CF_TEXT. @@ -688,55 +715,24 @@ static HANDLE import_string( Atom type, const void *data, size_t size ) /************************************************************************** * import_utf8_string * - * Import XA_UTF8_STRING, converting the string to CF_UNICODE. + * Import XA_UTF8_STRING, converting the string to CF_UNICODETEXT. */ static HANDLE import_utf8_string( Atom type, const void *data, size_t size ) { - const char *lpdata = data; - LPSTR lpstr; - size_t i, inlcount = 0; - WCHAR *textW = NULL; - - for (i = 0; i < size; i++) - { - if (lpdata[i] == '\n') - inlcount++; - } - - if ((lpstr = HeapAlloc( GetProcessHeap(), 0, size + inlcount + 1 ))) - { - UINT count; - - for (i = 0, inlcount = 0; i < size; i++) - { - if (lpdata[i] == '\n') - lpstr[inlcount++] = '\r'; - - lpstr[inlcount++] = lpdata[i]; - } - lpstr[inlcount] = 0; - - count = MultiByteToWideChar(CP_UTF8, 0, lpstr, -1, NULL, 0); - textW = GlobalAlloc( GMEM_FIXED, count * sizeof(WCHAR) ); - if (textW) MultiByteToWideChar( CP_UTF8, 0, lpstr, -1, textW, count ); - HeapFree(GetProcessHeap(), 0, lpstr); - } - return textW; + return unicode_text_from_string( CP_UTF8, data, size ); } /************************************************************************** * import_compound_text * - * Import COMPOUND_TEXT to CF_UNICODE + * Import COMPOUND_TEXT to CF_UNICODETEXT. */ static HANDLE import_compound_text( Atom type, const void *data, size_t size ) { - int i, j; char** srcstr; - int count, lcount; - int srclen, destlen; - WCHAR *deststr; + int count; + HANDLE ret; XTextProperty txtprop; txtprop.value = (BYTE *)data; @@ -746,39 +742,9 @@ static HANDLE import_compound_text( Atom type, const void *data, size_t size ) if (XmbTextPropertyToTextList( thread_display(), &txtprop, &srcstr, &count ) != Success) return 0; if (!count) return 0; - TRACE("Importing %d line(s)\n", count); - - /* Compute number of lines */ - srclen = strlen(srcstr[0]); - for (i = 0, lcount = 0; i <= srclen; i++) - { - if (srcstr[0][i] == '\n') - lcount++; - } - - destlen = MultiByteToWideChar(CP_UNIXCP, 0, srcstr[0], -1, NULL, 0); - - TRACE("lcount = %d, destlen=%d, srcstr %s\n", lcount, destlen, srcstr[0]); - - if ((deststr = GlobalAlloc( GMEM_FIXED, (destlen + lcount + 1) * sizeof(WCHAR) ))) - { - MultiByteToWideChar(CP_UNIXCP, 0, srcstr[0], -1, deststr, destlen); - - if (lcount) - { - for (i = destlen - 1, j = destlen + lcount - 1; i >= 0; i--, j--) - { - deststr[j] = deststr[i]; - - if (deststr[i] == '\n') - deststr[--j] = '\r'; - } - } - } - + ret = unicode_text_from_string( CP_UNIXCP, srcstr[0], strlen(srcstr[0]) + 1 ); XFreeStringList(srcstr); - - return deststr; + return ret; }
1
0
0
0
Alexandre Julliard : user32: Enforce null termination of strings added to the clipboard.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 8f24641ff382a646ff5b7b0c59666c9a305b948c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8f24641ff382a646ff5b7b0c5…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Sep 27 20:28:06 2016 +0900 user32: Enforce null termination of strings added to the clipboard. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/clipboard.c | 42 +++++++++++--- dlls/user32/tests/clipboard.c | 130 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+), 8 deletions(-) diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c index a841d7d..9d80813 100644 --- a/dlls/user32/clipboard.c +++ b/dlls/user32/clipboard.c @@ -173,6 +173,29 @@ static HANDLE marshal_data( UINT format, HANDLE handle, data_size_t *ret_size ) GlobalUnlock( handle ); return mfbits; } + case CF_UNICODETEXT: + { + WCHAR *ptr; + if (!(size = GlobalSize( handle ))) return 0; + if ((data_size_t)size != size) return 0; + if (!(ptr = GlobalLock( handle ))) return 0; + ptr[(size + 1) / sizeof(WCHAR) - 1] = 0; /* enforce null-termination */ + GlobalUnlock( handle ); + *ret_size = size; + return handle; + } + case CF_TEXT: + case CF_OEMTEXT: + { + char *ptr; + if (!(size = GlobalSize( handle ))) return 0; + if ((data_size_t)size != size) return 0; + if (!(ptr = GlobalLock( handle ))) return 0; + ptr[size - 1] = 0; /* enforce null-termination */ + GlobalUnlock( handle ); + *ret_size = size; + return handle; + } default: if (!(size = GlobalSize( handle ))) return 0; if ((data_size_t)size != size) return 0; @@ -382,9 +405,11 @@ static HANDLE render_synthesized_textA( HANDLE data, UINT format, UINT from ) size = len * sizeof(WCHAR); } - len = WideCharToMultiByte( codepage, 0, src, size / sizeof(WCHAR), NULL, 0, NULL, NULL ); - if ((ret = GlobalAlloc( GMEM_FIXED, len ))) - WideCharToMultiByte( codepage, 0, src, size / sizeof(WCHAR), ret, len, NULL, NULL ); + if ((len = WideCharToMultiByte( codepage, 0, src, size / sizeof(WCHAR), NULL, 0, NULL, NULL ))) + { + if ((ret = GlobalAlloc( GMEM_FIXED, len ))) + WideCharToMultiByte( codepage, 0, src, size / sizeof(WCHAR), ret, len, NULL, NULL ); + } done: HeapFree( GetProcessHeap(), 0, srcW ); @@ -396,16 +421,17 @@ done: static HANDLE render_synthesized_textW( HANDLE data, UINT from ) { char *src; - HANDLE ret; + HANDLE ret = 0; UINT len, size = GlobalSize( data ); UINT codepage = get_format_codepage( get_clipboard_locale(), from ); if (!(src = GlobalLock( data ))) return 0; - len = MultiByteToWideChar( codepage, 0, src, size, NULL, 0 ); - if ((ret = GlobalAlloc( GMEM_FIXED, len * sizeof(WCHAR) ))) - MultiByteToWideChar( codepage, 0, src, size, ret, len ); - + if ((len = MultiByteToWideChar( codepage, 0, src, size, NULL, 0 ))) + { + if ((ret = GlobalAlloc( GMEM_FIXED, len * sizeof(WCHAR) ))) + MultiByteToWideChar( codepage, 0, src, size, ret, len ); + } GlobalUnlock( data ); return ret; } diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c index 90e1aaa..832eca6 100644 --- a/dlls/user32/tests/clipboard.c +++ b/dlls/user32/tests/clipboard.c @@ -2264,6 +2264,130 @@ static void test_GetUpdatedClipboardFormats(void) ok( count == 4, "wrong count %u\n", count ); } +static const struct +{ + char strA[12]; + WCHAR strW[12]; + UINT len; +} test_data[] = +{ + { "foo", {}, 3 }, /* 0 */ + { "foo", {}, 4 }, + { "foo\0bar", {}, 7 }, + { "foo\0bar", {}, 8 }, + { "", {'f','o','o'}, 3 * sizeof(WCHAR) }, + { "", {'f','o','o',0}, 4 * sizeof(WCHAR) }, /* 5 */ + { "", {'f','o','o',0,'b','a','r'}, 7 * sizeof(WCHAR) }, + { "", {'f','o','o',0,'b','a','r',0}, 8 * sizeof(WCHAR) }, + { "", {'f','o','o'}, 1 }, + { "", {'f','o','o'}, 2 }, + { "", {'f','o','o'}, 5 }, /* 10 */ + { "", {'f','o','o',0}, 7 }, + { "", {'f','o','o',0}, 9 }, +}; + +static void test_string_data(void) +{ + UINT i; + BOOL r; + HANDLE data; + char cmd[16]; + char bufferA[12]; + WCHAR bufferW[12]; + + for (i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) + { + /* 1-byte Unicode strings crash on Win64 */ +#ifdef _WIN64 + if (!test_data[i].strA[0] && test_data[i].len < sizeof(WCHAR)) continue; +#endif + r = OpenClipboard( 0 ); + ok( r, "gle %d\n", GetLastError() ); + r = EmptyClipboard(); + ok( r, "gle %d\n", GetLastError() ); + data = GlobalAlloc( GMEM_FIXED, test_data[i].len ); + if (test_data[i].strA[0]) + { + memcpy( data, test_data[i].strA, test_data[i].len ); + SetClipboardData( CF_TEXT, data ); + memcpy( bufferA, test_data[i].strA, test_data[i].len ); + bufferA[test_data[i].len - 1] = 0; + ok( !memcmp( data, bufferA, test_data[i].len ), + "%u: wrong data %.*s\n", i, test_data[i].len, (char *)data ); + } + else + { + memcpy( data, test_data[i].strW, test_data[i].len ); + SetClipboardData( CF_UNICODETEXT, data ); + memcpy( bufferW, test_data[i].strW, test_data[i].len ); + bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0; + ok( !memcmp( data, bufferW, test_data[i].len ), + "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (test_data[i].len + 1) / sizeof(WCHAR) )); + } + r = CloseClipboard(); + ok( r, "gle %d\n", GetLastError() ); + sprintf( cmd, "string_data %u", i ); + run_process( cmd ); + } +} + +static void test_string_data_process( int i ) +{ + BOOL r; + HANDLE data; + UINT len, len2; + char bufferA[12]; + WCHAR bufferW[12]; + + r = OpenClipboard( 0 ); + ok( r, "gle %d\n", GetLastError() ); + if (test_data[i].strA[0]) + { + data = GetClipboardData( CF_TEXT ); + ok( data != 0, "%u: could not get data\n", i ); + len = GlobalSize( data ); + ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len ); + memcpy( bufferA, test_data[i].strA, test_data[i].len ); + bufferA[test_data[i].len - 1] = 0; + ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data ); + data = GetClipboardData( CF_UNICODETEXT ); + ok( data != 0, "%u: could not get data\n", i ); + len = GlobalSize( data ); + len2 = MultiByteToWideChar( CP_ACP, 0, bufferA, test_data[i].len, bufferW, 12 ); + ok( len == len2 * sizeof(WCHAR), "%u: wrong size %u / %u\n", i, len, len2 ); + ok( !memcmp( data, bufferW, len ), "%u: wrong data %s\n", i, wine_dbgstr_wn( data, len2 )); + } + else + { + data = GetClipboardData( CF_UNICODETEXT ); + ok( data != 0, "%u: could not get data\n", i ); + len = GlobalSize( data ); + ok( len == test_data[i].len, "%u: wrong size %u / %u\n", i, len, test_data[i].len ); + memcpy( bufferW, test_data[i].strW, test_data[i].len ); + bufferW[(test_data[i].len + 1) / sizeof(WCHAR) - 1] = 0; + ok( !memcmp( data, bufferW, len ), + "%u: wrong data %s\n", i, wine_dbgstr_wn( data, (len + 1) / sizeof(WCHAR) )); + data = GetClipboardData( CF_TEXT ); + if (test_data[i].len >= sizeof(WCHAR)) + { + ok( data != 0, "%u: could not get data\n", i ); + len = GlobalSize( data ); + len2 = WideCharToMultiByte( CP_ACP, 0, bufferW, test_data[i].len / sizeof(WCHAR), + bufferA, 12, NULL, NULL ); + bufferA[len2 - 1] = 0; + ok( len == len2, "%u: wrong size %u / %u\n", i, len, len2 ); + ok( !memcmp( data, bufferA, len ), "%u: wrong data %.*s\n", i, len, (char *)data ); + } + else + { + ok( !data, "%u: got data for empty string\n", i ); + ok( IsClipboardFormatAvailable( CF_TEXT ), "%u: text not available\n", i ); + } + } + r = CloseClipboard(); + ok( r, "gle %d\n", GetLastError() ); +} + START_TEST(clipboard) { char **argv; @@ -2301,6 +2425,11 @@ START_TEST(clipboard) test_handles_process_dib( argv[3] ); return; } + if (argc == 4 && !strcmp( argv[2], "string_data" )) + { + test_string_data_process( atoi( argv[3] )); + return; + } test_RegisterClipboardFormatA(); test_ClipboardOwner(); @@ -2308,4 +2437,5 @@ START_TEST(clipboard) test_messages(); test_data_handles(); test_GetUpdatedClipboardFormats(); + test_string_data(); }
1
0
0
0
Huw Davies : riched20: Pass a ME_Paragraph structure to ME_SetParaFormat() .
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 1d27f9151dce55210e653789db42b8bbbc6e6817 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1d27f9151dce55210e653789d…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Sep 27 09:57:18 2016 +0100 riched20: Pass a ME_Paragraph structure to ME_SetParaFormat(). Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/riched20/para.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/dlls/riched20/para.c b/dlls/riched20/para.c index c762cf0..ebef30c 100644 --- a/dlls/riched20/para.c +++ b/dlls/riched20/para.c @@ -127,12 +127,12 @@ static void ME_UpdateTableFlags(ME_DisplayItem *para) para->member.para.pFmt->wEffects &= ~PFE_TABLE; } -static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const PARAFORMAT2 *pFmt) +static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_Paragraph *para, const PARAFORMAT2 *pFmt) { PARAFORMAT2 copy; DWORD dwMask; - assert(para->member.para.pFmt->cbSize == sizeof(PARAFORMAT2)); + assert(para->pFmt->cbSize == sizeof(PARAFORMAT2)); dwMask = pFmt->dwMask; if (pFmt->cbSize < sizeof(PARAFORMAT)) return FALSE; @@ -141,27 +141,27 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const else dwMask &= PFM_ALL2; - add_undo_set_para_fmt( editor, ¶->member.para ); + add_undo_set_para_fmt( editor, para ); - copy = *para->member.para.pFmt; + copy = *para->pFmt; #define COPY_FIELD(m, f) \ if (dwMask & (m)) { \ - para->member.para.pFmt->dwMask |= m; \ - para->member.para.pFmt->f = pFmt->f; \ + para->pFmt->dwMask |= m; \ + para->pFmt->f = pFmt->f; \ } COPY_FIELD(PFM_NUMBERING, wNumbering); COPY_FIELD(PFM_STARTINDENT, dxStartIndent); if (dwMask & PFM_OFFSETINDENT) - para->member.para.pFmt->dxStartIndent += pFmt->dxStartIndent; + para->pFmt->dxStartIndent += pFmt->dxStartIndent; COPY_FIELD(PFM_RIGHTINDENT, dxRightIndent); COPY_FIELD(PFM_OFFSET, dxOffset); COPY_FIELD(PFM_ALIGNMENT, wAlignment); if (dwMask & PFM_TABSTOPS) { - para->member.para.pFmt->cTabCount = pFmt->cTabCount; - memcpy(para->member.para.pFmt->rgxTabs, pFmt->rgxTabs, pFmt->cTabCount*sizeof(LONG)); + para->pFmt->cTabCount = pFmt->cTabCount; + memcpy(para->pFmt->rgxTabs, pFmt->rgxTabs, pFmt->cTabCount*sizeof(LONG)); } #define EFFECTS_MASK (PFM_RTLPARA|PFM_KEEP|PFM_KEEPNEXT|PFM_PAGEBREAKBEFORE| \ @@ -170,9 +170,9 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const /* we take for granted that PFE_xxx is the hiword of the corresponding PFM_xxx */ if (dwMask & EFFECTS_MASK) { - para->member.para.pFmt->dwMask |= dwMask & EFFECTS_MASK; - para->member.para.pFmt->wEffects &= ~HIWORD(dwMask); - para->member.para.pFmt->wEffects |= pFmt->wEffects & HIWORD(dwMask); + para->pFmt->dwMask |= dwMask & EFFECTS_MASK; + para->pFmt->wEffects &= ~HIWORD(dwMask); + para->pFmt->wEffects |= pFmt->wEffects & HIWORD(dwMask); } #undef EFFECTS_MASK @@ -190,11 +190,11 @@ static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_DisplayItem *para, const COPY_FIELD(PFM_BORDER, wBorderWidth); COPY_FIELD(PFM_BORDER, wBorders); - para->member.para.pFmt->dwMask |= dwMask; + para->pFmt->dwMask |= dwMask; #undef COPY_FIELD - if (memcmp(©, para->member.para.pFmt, sizeof(PARAFORMAT2))) - para->member.para.nFlags |= MEPF_REWRAP; + if (memcmp(©, para->pFmt, sizeof(PARAFORMAT2))) + para->nFlags |= MEPF_REWRAP; return TRUE; } @@ -551,7 +551,7 @@ BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) ME_GetSelectionParas(editor, ¶, ¶_end); do { - ME_SetParaFormat(editor, para, pFmt); + ME_SetParaFormat(editor, ¶->member.para, pFmt); if (para == para_end) break; para = para->member.para.next_para;
1
0
0
0
Piotr Caban : msvcp120: Add _Cnd_{do_broadcast, register, unregister}_at_thread_exit tests.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: dfb03d6cafcc08fbbcdeabce5ab65ca5703f46f0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=dfb03d6cafcc08fbbcdeabce5…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Tue Sep 27 13:29:07 2016 +0200 msvcp120: Add _Cnd_{do_broadcast,register,unregister}_at_thread_exit tests. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcp120/tests/msvcp120.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 354b2d3..bcc82f7 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -257,6 +257,9 @@ static int (__cdecl *p__Cnd_wait)(_Cnd_t*, _Mtx_t*); static int (__cdecl *p__Cnd_timedwait)(_Cnd_t*, _Mtx_t*, const xtime*); static int (__cdecl *p__Cnd_broadcast)(_Cnd_t*); static int (__cdecl *p__Cnd_signal)(_Cnd_t*); +static void (__cdecl *p__Cnd_register_at_thread_exit)(_Cnd_t*, _Mtx_t*, int*); +static void (__cdecl *p__Cnd_unregister_at_thread_exit)(_Mtx_t*); +static void (__cdecl *p__Cnd_do_broadcast_at_thread_exit)(void); /* _Pad */ typedef void (*vtable_ptr)(void); @@ -513,6 +516,12 @@ static BOOL init(void) "_Cnd_broadcast"); SET(p__Cnd_signal, "_Cnd_signal"); + SET(p__Cnd_register_at_thread_exit, + "_Cnd_register_at_thread_exit"); + SET(p__Cnd_unregister_at_thread_exit, + "_Cnd_unregister_at_thread_exit"); + SET(p__Cnd_do_broadcast_at_thread_exit, + "_Cnd_do_broadcast_at_thread_exit"); hdll = GetModuleHandleA("msvcr120.dll"); p_setlocale = (void*)GetProcAddress(hdll, "setlocale"); @@ -1885,10 +1894,36 @@ static void test_cnd(void) ok(!r, "failed to signal\n"); p__Thrd_join(threads[0], NULL); + /* test _Cnd_do_broadcast_at_thread_exit */ + cm.started = 0; + cm.timed_wait = FALSE; + p__Thrd_create(&threads[0], cnd_wait_thread, (void*)&cm); + + WaitForSingleObject(cm.initialized, INFINITE); + p__Mtx_lock(&mtx); + + r = 0xcafe; + p__Cnd_unregister_at_thread_exit((_Mtx_t*)0xdeadbeef); + p__Cnd_register_at_thread_exit(&cnd, &mtx, &r); + ok(r == 0xcafe, "r = %x\n", r); + p__Cnd_register_at_thread_exit(&cnd, &mtx, &r); + p__Cnd_unregister_at_thread_exit(&mtx); + p__Cnd_do_broadcast_at_thread_exit(); + ok(mtx->count == 1, "mtx.count = %d\n", mtx->count); + + p__Cnd_register_at_thread_exit(&cnd, &mtx, &r); + ok(r == 0xcafe, "r = %x\n", r); + + p__Cnd_do_broadcast_at_thread_exit(); + ok(r == 1, "r = %x\n", r); + p__Thrd_join(threads[0], NULL); + + /* crash if _Cnd_do_broadcast_at_thread_exit is called on exit */ + p__Cnd_register_at_thread_exit((_Cnd_t*)0xdeadbeef, (_Mtx_t*)0xdeadbeef, (int*)0xdeadbeef); + /* test _Cnd_broadcast */ cm.started = 0; cm.thread_no = NUM_THREADS; - cm.timed_wait = FALSE; for(i = 0; i < cm.thread_no; i++) p__Thrd_create(&threads[i], cnd_wait_thread, (void*)&cm);
1
0
0
0
Piotr Caban : msvcp110: Add _Cnd_{do_broadcast, register, unregister}_at_thread_exit implementation.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: 4dc7f609e7d70ba2e28163ab5656b45339d95f11 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4dc7f609e7d70ba2e28163ab5…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Tue Sep 27 13:29:00 2016 +0200 msvcp110: Add _Cnd_{do_broadcast,register,unregister}_at_thread_exit implementation. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcp110/msvcp110.spec | 6 +-- dlls/msvcp120/msvcp120.spec | 6 +-- dlls/msvcp120_app/msvcp120_app.spec | 6 +-- dlls/msvcp140/msvcp140.spec | 6 +-- dlls/msvcp90/misc.c | 100 ++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 12 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index 8affc67..02ffa9b 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -3731,12 +3731,12 @@ @ cdecl _Call_onceEx(ptr ptr ptr) @ cdecl _Cnd_broadcast(ptr) @ cdecl _Cnd_destroy(ptr) -@ stub _Cnd_do_broadcast_at_thread_exit +@ cdecl _Cnd_do_broadcast_at_thread_exit() @ cdecl _Cnd_init(ptr) -@ stub _Cnd_register_at_thread_exit +@ cdecl _Cnd_register_at_thread_exit(ptr ptr ptr) @ cdecl _Cnd_signal(ptr) @ cdecl _Cnd_timedwait(ptr ptr ptr) -@ stub _Cnd_unregister_at_thread_exit +@ cdecl _Cnd_unregister_at_thread_exit(ptr) @ cdecl _Cnd_wait(ptr ptr) @ stub _Cosh @ extern _Denorm diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index 3cb81fe..7b8a243 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -3672,12 +3672,12 @@ @ cdecl _Call_onceEx(ptr ptr ptr) @ cdecl _Cnd_broadcast(ptr) @ cdecl _Cnd_destroy(ptr) -@ stub _Cnd_do_broadcast_at_thread_exit +@ cdecl _Cnd_do_broadcast_at_thread_exit() @ cdecl _Cnd_init(ptr) -@ stub _Cnd_register_at_thread_exit +@ cdecl _Cnd_register_at_thread_exit(ptr ptr ptr) @ cdecl _Cnd_signal(ptr) @ cdecl _Cnd_timedwait(ptr ptr ptr) -@ stub _Cnd_unregister_at_thread_exit +@ cdecl _Cnd_unregister_at_thread_exit(ptr) @ cdecl _Cnd_wait(ptr ptr) @ stub _Cosh @ extern _Denorm diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec index b799564..9ce5fea 100644 --- a/dlls/msvcp120_app/msvcp120_app.spec +++ b/dlls/msvcp120_app/msvcp120_app.spec @@ -3672,12 +3672,12 @@ @ cdecl _Call_onceEx(ptr ptr ptr) msvcp120._Call_onceEx @ cdecl _Cnd_broadcast(ptr) msvcp120._Cnd_broadcast @ cdecl _Cnd_destroy(ptr) msvcp120._Cnd_destroy -@ stub _Cnd_do_broadcast_at_thread_exit +@ cdecl _Cnd_do_broadcast_at_thread_exit() msvcp120._Cnd_do_broadcast_at_thread_exit @ cdecl _Cnd_init(ptr) msvcp120._Cnd_init -@ stub _Cnd_register_at_thread_exit +@ cdecl _Cnd_register_at_thread_exit(ptr ptr ptr) msvcp120._Cnd_register_at_thread_exit @ cdecl _Cnd_signal(ptr) msvcp120._Cnd_signal @ cdecl _Cnd_timedwait(ptr ptr ptr) msvcp120._Cnd_timedwait -@ stub _Cnd_unregister_at_thread_exit +@ cdecl _Cnd_unregister_at_thread_exit(ptr) msvcp120._Cnd_unregister_at_thread_exit @ cdecl _Cnd_wait(ptr ptr) msvcp120._Cnd_wait @ stub _Cosh @ extern _Denorm msvcp120._Denorm diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index cad39e9..c8e16fa 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -3624,13 +3624,13 @@ @ cdecl _Cnd_broadcast(ptr) _Cnd_broadcast @ cdecl _Cnd_destroy(ptr) _Cnd_destroy @ stub _Cnd_destroy_in_situ -@ stub _Cnd_do_broadcast_at_thread_exit +@ cdecl _Cnd_do_broadcast_at_thread_exit() @ cdecl _Cnd_init(ptr) _Cnd_init @ cdecl _Cnd_init_in_situ(ptr) -@ stub _Cnd_register_at_thread_exit +@ cdecl _Cnd_register_at_thread_exit(ptr ptr ptr) @ cdecl _Cnd_signal(ptr) _Cnd_signal @ cdecl _Cnd_timedwait(ptr ptr ptr) _Cnd_timedwait -@ stub _Cnd_unregister_at_thread_exit +@ cdecl _Cnd_unregister_at_thread_exit(ptr) @ cdecl _Cnd_wait(ptr ptr) _Cnd_wait @ stub _Copy_file @ stub _Cosh diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index 41f2eeb..885ec6f 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -662,6 +662,105 @@ void __cdecl _Cnd_destroy(_Cnd_arg_t cnd) MSVCRT_operator_delete(CND_T_FROM_ARG(cnd)); } } + +static struct { + int used; + int size; + + struct _to_broadcast { + DWORD thread_id; + _Cnd_arg_t cnd; + _Mtx_arg_t mtx; + int *p; + } *to_broadcast; +} broadcast_at_thread_exit; + +static CRITICAL_SECTION broadcast_at_thread_exit_cs; +static CRITICAL_SECTION_DEBUG broadcast_at_thread_exit_cs_debug = +{ + 0, 0, &broadcast_at_thread_exit_cs, + { &broadcast_at_thread_exit_cs_debug.ProcessLocksList, &broadcast_at_thread_exit_cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": broadcast_at_thread_exit_cs") } +}; +static CRITICAL_SECTION broadcast_at_thread_exit_cs = { &broadcast_at_thread_exit_cs_debug, -1, 0, 0, 0, 0 }; + +void __cdecl _Cnd_register_at_thread_exit(_Cnd_arg_t cnd, _Mtx_arg_t mtx, int *p) +{ + struct _to_broadcast *add; + + TRACE("(%p %p %p)\n", cnd, mtx, p); + + EnterCriticalSection(&broadcast_at_thread_exit_cs); + if(!broadcast_at_thread_exit.size) { + broadcast_at_thread_exit.to_broadcast = HeapAlloc(GetProcessHeap(), + 0, 8*sizeof(broadcast_at_thread_exit.to_broadcast[0])); + if(!broadcast_at_thread_exit.to_broadcast) { + LeaveCriticalSection(&broadcast_at_thread_exit_cs); + return; + } + broadcast_at_thread_exit.size = 8; + } else if(broadcast_at_thread_exit.size == broadcast_at_thread_exit.used) { + add = HeapReAlloc(GetProcessHeap(), 0, broadcast_at_thread_exit.to_broadcast, + broadcast_at_thread_exit.size*2*sizeof(broadcast_at_thread_exit.to_broadcast[0])); + if(!add) { + LeaveCriticalSection(&broadcast_at_thread_exit_cs); + return; + } + broadcast_at_thread_exit.to_broadcast = add; + broadcast_at_thread_exit.size *= 2; + } + + add = broadcast_at_thread_exit.to_broadcast + broadcast_at_thread_exit.used++; + add->thread_id = GetCurrentThreadId(); + add->cnd = cnd; + add->mtx = mtx; + add->p = p; + LeaveCriticalSection(&broadcast_at_thread_exit_cs); +} + +void __cdecl _Cnd_unregister_at_thread_exit(_Mtx_arg_t mtx) +{ + int i; + + TRACE("(%p)\n", mtx); + + EnterCriticalSection(&broadcast_at_thread_exit_cs); + for(i=0; i<broadcast_at_thread_exit.used; i++) { + if(broadcast_at_thread_exit.to_broadcast[i].mtx != mtx) + continue; + + memmove(broadcast_at_thread_exit.to_broadcast+i, broadcast_at_thread_exit.to_broadcast+i+1, + (broadcast_at_thread_exit.used-i-1)*sizeof(broadcast_at_thread_exit.to_broadcast[0])); + broadcast_at_thread_exit.used--; + i--; + } + LeaveCriticalSection(&broadcast_at_thread_exit_cs); +} + +void __cdecl _Cnd_do_broadcast_at_thread_exit(void) +{ + int i, id = GetCurrentThreadId(); + + TRACE("()\n"); + + EnterCriticalSection(&broadcast_at_thread_exit_cs); + for(i=0; i<broadcast_at_thread_exit.used; i++) { + if(broadcast_at_thread_exit.to_broadcast[i].thread_id != id) + continue; + + _Mtx_unlock(broadcast_at_thread_exit.to_broadcast[i].mtx); + _Cnd_broadcast(broadcast_at_thread_exit.to_broadcast[i].cnd); + if(broadcast_at_thread_exit.to_broadcast[i].p) + *broadcast_at_thread_exit.to_broadcast[i].p = 1; + + memmove(broadcast_at_thread_exit.to_broadcast+i, broadcast_at_thread_exit.to_broadcast+i+1, + (broadcast_at_thread_exit.used-i-1)*sizeof(broadcast_at_thread_exit.to_broadcast[0])); + broadcast_at_thread_exit.used--; + i--; + } + LeaveCriticalSection(&broadcast_at_thread_exit_cs); +} + #endif #if _MSVCP_VER == 100 @@ -1195,6 +1294,7 @@ void free_misc(void) #if _MSVCP_VER >= 110 if(keyed_event) NtClose(keyed_event); + HeapFree(GetProcessHeap(), 0, broadcast_at_thread_exit.to_broadcast); #endif }
1
0
0
0
Piotr Caban : msvcp140: Add codecvt<short,char,_Mbstatet> exports.
by Alexandre Julliard
27 Sep '16
27 Sep '16
Module: wine Branch: master Commit: f2267802d0e723695e7e6f8421197bb292a5b3c7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f2267802d0e723695e7e6f842…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Tue Sep 27 09:33:21 2016 +0200 msvcp140: Add codecvt<short,char,_Mbstatet> exports. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcp140/msvcp140.spec | 104 ++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 52 deletions(-) Diff:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=f2267802d0e723695e7e6…
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
...
43
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
Results per page:
10
25
50
100
200