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
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
July 2024
----- 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
519 discussions
Start a n
N
ew thread
Brendan McGrath : winegstreamer: Use thread_count to determine 'max-threads' value.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: ff5a198a8b35d19f772086ca70beee1c34b9a93c URL:
https://gitlab.winehq.org/wine/wine/-/commit/ff5a198a8b35d19f772086ca70beee…
Author: Brendan McGrath <bmcgrath(a)codeweavers.com> Date: Wed Jun 26 11:41:11 2024 +1000 winegstreamer: Use thread_count to determine 'max-threads' value. GStreamer uses _SC_NPROCESSORS_CONF to determine 'max-threads'. On the Steam Deck, this is configured to be 16 (which is double its number of logical cores). _SC_NPROCESSORS_CONF also disregards a process's CPU affinity, thus it can create more threads than is useful, which ultimately wastes memory resources. Using thread_count to set 'max-threads' addresses both these problems. --- dlls/winegstreamer/unix_private.h | 1 + dlls/winegstreamer/unixlib.c | 34 ++++++++++++++++++++++++++++++++++ dlls/winegstreamer/wg_parser.c | 7 +++++++ dlls/winegstreamer/wg_transform.c | 2 ++ 4 files changed, 44 insertions(+) diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index 0c285457d78..b2cc036c914 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -46,6 +46,7 @@ extern bool link_src_to_sink(GstPad *src_pad, GstPad *sink_pad); extern bool link_src_to_element(GstPad *src_pad, GstElement *element); extern bool link_element_to_sink(GstElement *element, GstPad *sink_pad); extern bool push_event(GstPad *pad, GstEvent *event); +extern void set_max_threads(GstElement *element); /* wg_format.c */ diff --git a/dlls/winegstreamer/unixlib.c b/dlls/winegstreamer/unixlib.c index fe432070cd8..3558cf45423 100644 --- a/dlls/winegstreamer/unixlib.c +++ b/dlls/winegstreamer/unixlib.c @@ -302,3 +302,37 @@ NTSTATUS wg_init_gstreamer(void *arg) gst_version_string(), GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO); return STATUS_SUCCESS; } + +static bool element_has_property(const GstElement *element, const gchar *property) +{ + return !!g_object_class_find_property(G_OBJECT_CLASS(GST_ELEMENT_GET_CLASS(element)), property); +} + +void set_max_threads(GstElement *element) +{ + const char *shortname = NULL; + GstElementFactory *factory = gst_element_get_factory(element); + + if (factory) + shortname = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(factory)); + + /* By default, GStreamer will use the result of sysconf(_SC_NPROCESSORS_CONF) to determine the number + * of decoder threads to be used by libva. This has two issues: + * 1. It can return an inaccurate result (for example, on the Steam Deck this returns 16); and + * 2. It disregards process affinity + * + * Both of these scenarios result in more threads being allocated than logical cores made available, meaning + * they provide little (or possibly detrimental) performance benefit and for 4K video can occupy 32MB + * of RAM each (w * h * bpp). + * + * So we will instead explictly set 'max-threads' to the minimum of thread_count (process affinity at time of + * initialization) or 16. + */ + + if (shortname && strstr(shortname, "avdec_") && element_has_property(element, "max-threads")) + { + gint32 max_threads = MIN(thread_count, 16); + GST_DEBUG("%s found, setting max-threads to %d.", shortname, max_threads); + g_object_set(element, "max-threads", max_threads, NULL); + } +} diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 8690e6baf81..710cfe6a0a5 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -567,6 +567,12 @@ static void no_more_pads_cb(GstElement *element, gpointer user) pthread_cond_signal(&parser->init_cond); } +static void deep_element_added_cb(GstBin *self, GstBin *sub_bin, GstElement *element, gpointer user) +{ + if (element) + set_max_threads(element); +} + static gboolean sink_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) { struct wg_parser_stream *stream = gst_pad_get_element_private(pad); @@ -1797,6 +1803,7 @@ static BOOL decodebin_parser_init_gst(struct wg_parser *parser) g_signal_connect(element, "autoplug-continue", G_CALLBACK(autoplug_continue_cb), parser); g_signal_connect(element, "autoplug-select", G_CALLBACK(autoplug_select_cb), parser); g_signal_connect(element, "no-more-pads", G_CALLBACK(no_more_pads_cb), parser); + g_signal_connect(element, "deep-element-added", G_CALLBACK(deep_element_added_cb), parser); pthread_mutex_lock(&parser->mutex); parser->no_more_pads = false; diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index cd6bb9c8f52..76dbd347064 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -555,6 +555,8 @@ NTSTATUS wg_transform_create(void *args) if (!(element = find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, parsed_caps, sink_caps)) || !append_element(transform->container, element, &first, &last)) goto out; + + set_max_threads(element); } if (g_str_has_prefix(output_mime, "audio/"))
1
0
0
0
Brendan McGrath : winegstreamer: Use process affinity to calculate thread_count.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: d4e95ede4f44a5c06278a27df929e8d9f6ce9263 URL:
https://gitlab.winehq.org/wine/wine/-/commit/d4e95ede4f44a5c06278a27df929e8…
Author: Brendan McGrath <bmcgrath(a)codeweavers.com> Date: Wed Jun 26 11:35:32 2024 +1000 winegstreamer: Use process affinity to calculate thread_count. --- dlls/winegstreamer/unixlib.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dlls/winegstreamer/unixlib.c b/dlls/winegstreamer/unixlib.c index 175ab92ecdc..fe432070cd8 100644 --- a/dlls/winegstreamer/unixlib.c +++ b/dlls/winegstreamer/unixlib.c @@ -47,6 +47,8 @@ GST_DEBUG_CATEGORY(wine); +static UINT thread_count; + GstStreamType stream_type_from_caps(GstCaps *caps) { const gchar *media_type; @@ -244,6 +246,17 @@ bool push_event(GstPad *pad, GstEvent *event) return true; } +static ULONG popcount(ULONG val) +{ +#if HAVE___BUILTIN_POPCOUNT + return __builtin_popcount(val); +#else + val -= val >> 1 & 0x55555555; + val = (val & 0x33333333) + (val >> 2 & 0x33333333); + return ((val + (val >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24; +#endif +} + NTSTATUS wg_init_gstreamer(void *arg) { struct wg_init_gstreamer_params *params = arg; @@ -253,6 +266,7 @@ NTSTATUS wg_init_gstreamer(void *arg) int argc = ARRAY_SIZE(args) - 1; char **argv = args; GError *err; + DWORD_PTR process_mask; if (params->trace_on) setenv("GST_DEBUG", "WINE:9,4", FALSE); @@ -276,6 +290,12 @@ NTSTATUS wg_init_gstreamer(void *arg) return STATUS_UNSUCCESSFUL; } + if (!NtQueryInformationProcess(GetCurrentProcess(), + ProcessAffinityMask, &process_mask, sizeof(process_mask), NULL)) + thread_count = popcount(process_mask); + else + thread_count = 0; + GST_DEBUG_CATEGORY_INIT(wine, "WINE", GST_DEBUG_FG_RED, "Wine GStreamer support"); GST_INFO("GStreamer library version %s; wine built with %d.%d.%d.",
1
0
0
0
Elizabeth Figura : wined3d: Invalidate the FFP VS when diffuse presence changes.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: 003b338102b76c8693af9ab46b170654a4047568 URL:
https://gitlab.winehq.org/wine/wine/-/commit/003b338102b76c8693af9ab46b1706…
Author: Elizabeth Figura <zfigura(a)codeweavers.com> Date: Tue Jul 2 19:52:50 2024 -0500 wined3d: Invalidate the FFP VS when diffuse presence changes. Regardless of WINED3D_RS_COLORVERTEX. Fixes: 95999accf6c1ece887788bf6f827a34288744fba Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=56895
--- dlls/wined3d/glsl_shader.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 41e6949b7af..3c97eebe124 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -11799,10 +11799,10 @@ static void glsl_vertex_pipe_vdecl(struct wined3d_context *context, * always output all the texture coordinates. * * Likewise, we have to invalidate the shader when using per-vertex - * colours and diffuse/specular attribute presence changes, or when - * normal presence changes. */ - if (!shader_glsl_full_ffp_varyings(gl_info) || (state->render_states[WINED3D_RS_COLORVERTEX] - && (diffuse != context->last_was_diffuse || specular != context->last_was_specular)) + * colours and specular attribute presence changes, or when + * normal, diffuse, or point size presence changes. */ + if (!shader_glsl_full_ffp_varyings(gl_info) || diffuse != context->last_was_diffuse + || (state->render_states[WINED3D_RS_COLORVERTEX] && specular != context->last_was_specular) || normal != context->last_was_normal || point_size != context->last_was_point_size) context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_VERTEX;
1
0
0
0
Rémi Bernon : win32u: Use the shared memory to read the desktop flags.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: 821c95aa6ad120048edeef25d6b329f95fc1b686 URL:
https://gitlab.winehq.org/wine/wine/-/commit/821c95aa6ad120048edeef25d6b329…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Jun 21 22:30:23 2024 +0200 win32u: Use the shared memory to read the desktop flags. --- dlls/win32u/winstation.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c index 1a1b37f6eda..0500d510fd4 100644 --- a/dlls/win32u/winstation.c +++ b/dlls/win32u/winstation.c @@ -256,12 +256,16 @@ NTSTATUS get_shared_queue( struct object_lock *lock, const queue_shm_t **queue_s BOOL is_virtual_desktop(void) { - HANDLE desktop = NtUserGetThreadDesktop( GetCurrentThreadId() ); - USEROBJECTFLAGS flags = {0}; - DWORD len; + struct object_lock lock = OBJECT_LOCK_INIT; + const desktop_shm_t *desktop_shm; + BOOL ret = FALSE; + UINT status; - if (!NtUserGetObjectInformation( desktop, UOI_FLAGS, &flags, sizeof(flags), &len )) return FALSE; - return !!(flags.dwFlags & DF_WINE_VIRTUAL_DESKTOP); + while ((status = get_shared_desktop( &lock, &desktop_shm )) == STATUS_PENDING) + ret = !!(desktop_shm->flags & DF_WINE_VIRTUAL_DESKTOP); + if (status) ret = FALSE; + + return ret; } /***********************************************************************
1
0
0
0
Rémi Bernon : server: Move the desktop flags to the shared memory.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: d0d94195a683a8c42c14283ad4dabe836161356a URL:
https://gitlab.winehq.org/wine/wine/-/commit/d0d94195a683a8c42c14283ad4dabe…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Fri Jun 21 22:27:44 2024 +0200 server: Move the desktop flags to the shared memory. --- include/wine/server_protocol.h | 3 ++- server/protocol.def | 1 + server/user.h | 1 - server/winstation.c | 25 ++++++++++++++++++------- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 2598ecc1817..89a2dcb778f 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -893,6 +893,7 @@ struct shared_cursor typedef volatile struct { + unsigned int flags; struct shared_cursor cursor; unsigned char keystate[256]; } desktop_shm_t; @@ -6591,7 +6592,7 @@ union generic_reply /* ### protocol_version begin ### */ -#define SERVER_PROTOCOL_VERSION 821 +#define SERVER_PROTOCOL_VERSION 822 /* ### protocol_version end ### */ diff --git a/server/protocol.def b/server/protocol.def index 21e35204ed0..39c8de7ef69 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -909,6 +909,7 @@ struct shared_cursor typedef volatile struct { + unsigned int flags; /* desktop flags */ struct shared_cursor cursor; /* global cursor information */ unsigned char keystate[256]; /* asynchronous key state */ } desktop_shm_t; diff --git a/server/user.h b/server/user.h index 4633c7dae7f..6f10f296200 100644 --- a/server/user.h +++ b/server/user.h @@ -67,7 +67,6 @@ struct key_repeat struct desktop { struct object obj; /* object header */ - unsigned int flags; /* desktop flags */ struct winstation *winstation; /* winstation this desktop belongs to */ timeout_t input_time; /* last time this desktop had the input */ struct list entry; /* entry in winstation list of desktops */ diff --git a/server/winstation.c b/server/winstation.c index 75b604ae1c3..76a23b197a4 100644 --- a/server/winstation.c +++ b/server/winstation.c @@ -274,13 +274,11 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned { /* initialize it if it didn't already exist */ - desktop->flags = flags; - /* inherit DF_WINE_*_DESKTOP flags if none of them are specified */ if (!(flags & (DF_WINE_ROOT_DESKTOP | DF_WINE_VIRTUAL_DESKTOP)) && (current_desktop = get_thread_desktop( current, 0 ))) { - desktop->flags |= current_desktop->flags & (DF_WINE_VIRTUAL_DESKTOP | DF_WINE_ROOT_DESKTOP); + flags |= current_desktop->shared->flags & (DF_WINE_VIRTUAL_DESKTOP | DF_WINE_ROOT_DESKTOP); release_object( current_desktop ); } @@ -308,6 +306,7 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned SHARED_WRITE_BEGIN( desktop->shared, desktop_shm_t ) { + shared->flags = flags; shared->cursor.x = 0; shared->cursor.y = 0; shared->cursor.last_change = 0; @@ -321,7 +320,12 @@ static struct desktop *create_desktop( const struct unicode_str *name, unsigned } else { - desktop->flags |= flags & (DF_WINE_VIRTUAL_DESKTOP | DF_WINE_ROOT_DESKTOP); + SHARED_WRITE_BEGIN( desktop->shared, desktop_shm_t ) + { + shared->flags |= flags & (DF_WINE_VIRTUAL_DESKTOP | DF_WINE_ROOT_DESKTOP); + } + SHARED_WRITE_END; + clear_error(); } } @@ -333,7 +337,7 @@ static void desktop_dump( struct object *obj, int verbose ) struct desktop *desktop = (struct desktop *)obj; fprintf( stderr, "Desktop flags=%x winstation=%p top_win=%p hooks=%p\n", - desktop->flags, desktop->winstation, desktop->top_window, desktop->global_hooks ); + desktop->shared->flags, desktop->winstation, desktop->top_window, desktop->global_hooks ); } static int desktop_link_name( struct object *obj, struct object_name *name, struct object *parent ) @@ -839,8 +843,15 @@ DECL_HANDLER(set_user_object_info) { struct desktop *desktop = (struct desktop *)obj; reply->is_desktop = 1; - reply->old_obj_flags = desktop->flags; - if (req->flags & SET_USER_OBJECT_SET_FLAGS) desktop->flags = req->obj_flags; + reply->old_obj_flags = desktop->shared->flags; + if (req->flags & SET_USER_OBJECT_SET_FLAGS) + { + SHARED_WRITE_BEGIN( desktop->shared, desktop_shm_t ) + { + shared->flags = req->obj_flags; + } + SHARED_WRITE_END; + } } else if (obj->ops == &winstation_ops) {
1
0
0
0
Piotr Caban : xcopy: Add support for parsing concatenated switches.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: 1e1fb212ad683c11f4f01e05767154ba6e58c7ec URL:
https://gitlab.winehq.org/wine/wine/-/commit/1e1fb212ad683c11f4f01e05767154…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Jul 3 12:50:15 2024 +0200 xcopy: Add support for parsing concatenated switches. --- programs/xcopy/tests/xcopy.c | 6 ++++++ programs/xcopy/xcopy.c | 34 ++++++++++------------------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/programs/xcopy/tests/xcopy.c b/programs/xcopy/tests/xcopy.c index 4c51f941dfc..61fbad9ccaf 100644 --- a/programs/xcopy/tests/xcopy.c +++ b/programs/xcopy/tests/xcopy.c @@ -111,6 +111,12 @@ static void test_parms_syntax(void) ok(rc == 4, "xcopy /D/S/\"E\" test failed rc=%lu\n", rc); ok(GetFileAttributesA("xcopytest2") == INVALID_FILE_ATTRIBUTES, "xcopy copied empty directory incorrectly\n"); + + rc = runcmd("xcopy xcopytest xcopytest2\\/DSE"); + ok(rc == 0, "xcopy /DSE test failed rc=%lu\n", rc); + ok(GetFileAttributesA("xcopytest2") != INVALID_FILE_ATTRIBUTES, + "xcopy failed to copy empty directory\n"); + RemoveDirectoryA("xcopytest2"); } static void test_keep_attributes(void) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 84f2d312b6f..46a2727dd49 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -738,13 +738,12 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, Note: Windows docs say /P prompts when dest is created but tests show it is done for each src file regardless of the destination */ - int skip=0; - WCHAR *p = word, *rest; + WCHAR *p = word + 1, *rest; while (*p) { - rest = NULL; + rest = p + 1; - switch (toupper(p[1])) { + switch (toupper(*p)) { case 'I': flags |= OPT_ASSUMEDIR; break; case 'S': flags |= OPT_RECURSIVE; break; case 'Q': flags |= OPT_QUIET; break; @@ -766,14 +765,12 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, /* E can be /E or /EXCLUDE */ case 'E': if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, - &p[1], 8, L"EXCLUDE:", -1) == CSTR_EQUAL) { - if (XCOPY_ProcessExcludeList(&p[9])) { + p, 8, L"EXCLUDE:", -1) == CSTR_EQUAL) { + if (XCOPY_ProcessExcludeList(&p[8])) { XCOPY_FailMessage(ERROR_INVALID_PARAMETER); exit(RC_INITERROR); } else { flags |= OPT_EXCLUDELIST; - - /* Do not support concatenated switches onto exclude lists yet */ rest = p + wcslen(p); } } else { @@ -782,9 +779,9 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, break; /* D can be /D or /D: */ - case 'D': if (p[2]==':' && is_digit(p[3])) { + case 'D': if (p[1]==':' && is_digit(p[2])) { SYSTEMTIME st; - WCHAR *pos = &p[3]; + WCHAR *pos = &p[2]; BOOL isError = FALSE; memset(&st, 0x00, sizeof(st)); @@ -835,9 +832,9 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, } break; - case '-': if (toupper(p[2])=='Y') { + case '-': if (toupper(p[1])=='Y') { flags &= ~OPT_NOPROMPT; - rest = &p[3]; /* Skip over 3 characters */ + rest = &p[2]; /* Skip over 2 characters */ } break; case '?': XCOPY_wprintf(XCOPY_LoadMessage(STRING_HELP)); @@ -851,18 +848,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, exit(RC_INITERROR); } - /* Unless overridden above, skip over the '/' and the first character */ - if (rest == NULL) rest = &p[2]; - - /* By now, rest should point either to the null after the - switch, or the beginning of the next switch if there - was no whitespace between them */ - if (!skip && *rest && *rest != '/') { - WINE_FIXME("Unexpected characters found and ignored '%s'\n", wine_dbgstr_w(rest)); - skip=1; - } else { - p = rest; - } + p = rest; } } free(word);
1
0
0
0
Piotr Caban : xcopy: Handle switch options concatenated with path.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: c9314151d9a8568b0b18a48cfa7197bb9f0823ff URL:
https://gitlab.winehq.org/wine/wine/-/commit/c9314151d9a8568b0b18a48cfa7197…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Thu Jun 27 08:47:52 2024 +0200 xcopy: Handle switch options concatenated with path. --- programs/xcopy/tests/xcopy.c | 2 +- programs/xcopy/xcopy.c | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/programs/xcopy/tests/xcopy.c b/programs/xcopy/tests/xcopy.c index 2745ead97a5..4c51f941dfc 100644 --- a/programs/xcopy/tests/xcopy.c +++ b/programs/xcopy/tests/xcopy.c @@ -101,7 +101,7 @@ static void test_parms_syntax(void) ok(GetFileAttributesA("xcopytest2") == INVALID_FILE_ATTRIBUTES, "xcopy copied empty directory incorrectly\n"); - rc = runcmd("xcopy /D/S/E xcopytest xcopytest2\\"); + rc = runcmd("xcopy xcopytest xcopytest2\\/D/S/E"); ok(rc == 0, "xcopy /D/S/E test failed rc=%lu\n", rc); ok(GetFileAttributesA("xcopytest2") != INVALID_FILE_ATTRIBUTES, "xcopy failed to copy empty directory\n"); diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 715fd8f167b..84f2d312b6f 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -665,21 +665,16 @@ static inline BOOL is_digit(WCHAR c) static int get_arg(const WCHAR **cmdline, WCHAR **arg) { const WCHAR *ptr = *cmdline; - BOOL in_quotes = FALSE; int len; - for (;;) { - for (; *ptr != '\0' && *ptr != '"' && - (in_quotes || !is_whitespace(*ptr)); ptr++); + if (*ptr == '/') ptr++; + while (*ptr && !is_whitespace(*ptr) && *ptr != '/') { if (*ptr == '"') { - in_quotes = !in_quotes; - ptr++; + while (*ptr && *ptr != '"') ptr++; + /* Odd number of double quotes is illegal for XCOPY */ + if (!*ptr) return RC_INITERROR; } - /* Odd number of double quotes is illegal for XCOPY */ - if (in_quotes && *ptr == '\0') - return RC_INITERROR; - if (*ptr == '\0' || (!in_quotes && is_whitespace(*ptr))) - break; + ptr++; } len = ptr - *cmdline;
1
0
0
0
Piotr Caban : xcopy: Introduce get_arg helper that duplicates first argument to new string.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: 28831f9df951c0c7e06feda99c48693df24e48c1 URL:
https://gitlab.winehq.org/wine/wine/-/commit/28831f9df951c0c7e06feda99c4869…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Jul 3 11:35:12 2024 +0200 xcopy: Introduce get_arg helper that duplicates first argument to new string. --- programs/xcopy/xcopy.c | 67 +++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 072d44728a3..715fd8f167b 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -647,7 +647,7 @@ static inline BOOL is_whitespace(WCHAR c) return c == ' ' || c == '\t'; } -static WCHAR *skip_whitespace(WCHAR *p) +static const WCHAR *skip_whitespace(const WCHAR *p) { for (; *p && is_whitespace(*p); p++); return p; @@ -662,10 +662,12 @@ static inline BOOL is_digit(WCHAR c) that lacks the escaped-quote logic of build_argv(), because literal double quotes are illegal in any of its arguments. Example: 'XCOPY "c:\DIR A" "c:DIR B\"' is OK. */ -static int find_end_of_word(const WCHAR *word, WCHAR **end) +static int get_arg(const WCHAR **cmdline, WCHAR **arg) { + const WCHAR *ptr = *cmdline; BOOL in_quotes = FALSE; - const WCHAR *ptr = word; + int len; + for (;;) { for (; *ptr != '\0' && *ptr != '"' && (in_quotes || !is_whitespace(*ptr)); ptr++); @@ -679,7 +681,15 @@ static int find_end_of_word(const WCHAR *word, WCHAR **end) if (*ptr == '\0' || (!in_quotes && is_whitespace(*ptr))) break; } - *end = (WCHAR*)ptr; + + len = ptr - *cmdline; + *arg = malloc((len + 1) * sizeof(WCHAR)); + if (!*arg) + return RC_INITERROR; + memcpy(*arg, *cmdline, len * sizeof(WCHAR)); + (*arg)[len] = 0; + + *cmdline = skip_whitespace(ptr); return RC_OK; } @@ -701,25 +711,20 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, WCHAR *supplieddestination, DWORD *pflags) { DWORD flags = *pflags; - WCHAR *cmdline, *word, *end, *next; + const WCHAR *cmdline; + WCHAR *word; int rc; - cmdline = _wcsdup(GetCommandLineW()); - if (cmdline == NULL) - exit(RC_INITERROR); - + cmdline = GetCommandLineW(); /* Skip first arg, which is the program name */ - if ((rc = find_end_of_word(cmdline, &word)) != RC_OK) + if ((rc = get_arg(&cmdline, &word)) != RC_OK) exit(rc); - word = skip_whitespace(word); + free(word); - while (*word) + while (*cmdline) { - if ((rc = find_end_of_word(word, &end)) != RC_OK) + if ((rc = get_arg(&cmdline, &word)) != RC_OK) exit(rc); - - next = skip_whitespace(end); - *end = '\0'; WINE_TRACE("Processing Arg: '%s'\n", wine_dbgstr_w(word)); /* First non-switch parameter is source, second is destination */ @@ -739,12 +744,12 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, but tests show it is done for each src file regardless of the destination */ int skip=0; - WCHAR *rest; + WCHAR *p = word, *rest; - while (word[0]) { + while (*p) { rest = NULL; - switch (toupper(word[1])) { + switch (toupper(p[1])) { case 'I': flags |= OPT_ASSUMEDIR; break; case 'S': flags |= OPT_RECURSIVE; break; case 'Q': flags |= OPT_QUIET; break; @@ -766,15 +771,15 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, /* E can be /E or /EXCLUDE */ case 'E': if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, - &word[1], 8, L"EXCLUDE:", -1) == CSTR_EQUAL) { - if (XCOPY_ProcessExcludeList(&word[9])) { + &p[1], 8, L"EXCLUDE:", -1) == CSTR_EQUAL) { + if (XCOPY_ProcessExcludeList(&p[9])) { XCOPY_FailMessage(ERROR_INVALID_PARAMETER); exit(RC_INITERROR); } else { flags |= OPT_EXCLUDELIST; /* Do not support concatenated switches onto exclude lists yet */ - rest = end; + rest = p + wcslen(p); } } else { flags |= OPT_EMPTYDIR | OPT_RECURSIVE; @@ -782,9 +787,9 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, break; /* D can be /D or /D: */ - case 'D': if (word[2]==':' && is_digit(word[3])) { + case 'D': if (p[2]==':' && is_digit(p[3])) { SYSTEMTIME st; - WCHAR *pos = &word[3]; + WCHAR *pos = &p[3]; BOOL isError = FALSE; memset(&st, 0x00, sizeof(st)); @@ -835,9 +840,9 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, } break; - case '-': if (toupper(word[2])=='Y') { + case '-': if (toupper(p[2])=='Y') { flags &= ~OPT_NOPROMPT; - rest = &word[3]; /* Skip over 3 characters */ + rest = &p[3]; /* Skip over 3 characters */ } break; case '?': XCOPY_wprintf(XCOPY_LoadMessage(STRING_HELP)); @@ -846,13 +851,13 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, WINE_FIXME("ignoring /V\n"); break; default: - WINE_TRACE("Unhandled parameter '%s'\n", wine_dbgstr_w(word)); - XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARM), word); + WINE_TRACE("Unhandled parameter '%s'\n", wine_dbgstr_w(p)); + XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARM), p); exit(RC_INITERROR); } /* Unless overridden above, skip over the '/' and the first character */ - if (rest == NULL) rest = &word[2]; + if (rest == NULL) rest = &p[2]; /* By now, rest should point either to the null after the switch, or the beginning of the next switch if there @@ -861,11 +866,11 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, WINE_FIXME("Unexpected characters found and ignored '%s'\n", wine_dbgstr_w(rest)); skip=1; } else { - word = rest; + p = rest; } } } - word = next; + free(word); } /* Default the destination if not supplied */
1
0
0
0
Piotr Caban : xcopy: Strip quotes only from source and destination arguments.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: eab62c31f3a935eded6750db58f594384d3fe525 URL:
https://gitlab.winehq.org/wine/wine/-/commit/eab62c31f3a935eded6750db58f594…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Jul 3 11:08:38 2024 +0200 xcopy: Strip quotes only from source and destination arguments. --- programs/xcopy/tests/xcopy.c | 5 +++++ programs/xcopy/xcopy.c | 19 ++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/programs/xcopy/tests/xcopy.c b/programs/xcopy/tests/xcopy.c index fa3d5328a1b..2745ead97a5 100644 --- a/programs/xcopy/tests/xcopy.c +++ b/programs/xcopy/tests/xcopy.c @@ -106,6 +106,11 @@ static void test_parms_syntax(void) ok(GetFileAttributesA("xcopytest2") != INVALID_FILE_ATTRIBUTES, "xcopy failed to copy empty directory\n"); RemoveDirectoryA("xcopytest2"); + + rc = runcmd("xcopy xcopytest xcopytest2\\ /D/S/\"E\""); + ok(rc == 4, "xcopy /D/S/\"E\" test failed rc=%lu\n", rc); + ok(GetFileAttributesA("xcopytest2") == INVALID_FILE_ATTRIBUTES, + "xcopy copied empty directory incorrectly\n"); } static void test_keep_attributes(void) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 202ce903407..072d44728a3 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -684,18 +684,17 @@ static int find_end_of_word(const WCHAR *word, WCHAR **end) } /* Remove all double quotes from a word */ -static void strip_quotes(WCHAR *word, WCHAR **end) +static void strip_quotes(WCHAR *word) { - WCHAR *rp, *wp; - for (rp = word, wp = word; *rp != '\0'; rp++) { - if (*rp == '"') + WCHAR *wp; + for (wp = word; *word != '\0'; word++) { + if (*word == '"') continue; - if (wp < rp) - *wp = *rp; + if (wp < word) + *wp = *word; wp++; } *wp = '\0'; - *end = wp; } static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, @@ -716,18 +715,16 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, while (*word) { - WCHAR first; if ((rc = find_end_of_word(word, &end)) != RC_OK) exit(rc); next = skip_whitespace(end); - first = word[0]; *end = '\0'; - strip_quotes(word, &end); WINE_TRACE("Processing Arg: '%s'\n", wine_dbgstr_w(word)); /* First non-switch parameter is source, second is destination */ - if (first != '/') { + if (word[0] != '/') { + strip_quotes(word); if (suppliedsource[0] == 0x00) { lstrcpyW(suppliedsource, word); } else if (supplieddestination[0] == 0x00) {
1
0
0
0
Piotr Caban : xcopy: Exit on invalid command line argument.
by Alexandre Julliard
03 Jul '24
03 Jul '24
Module: wine Branch: master Commit: f5448260505bcb5078c5016287f44edfc52fef7e URL:
https://gitlab.winehq.org/wine/wine/-/commit/f5448260505bcb5078c5016287f44e…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Jul 3 10:55:43 2024 +0200 xcopy: Exit on invalid command line argument. --- programs/xcopy/xcopy.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 57adf1d6b84..202ce903407 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -703,22 +703,22 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, { DWORD flags = *pflags; WCHAR *cmdline, *word, *end, *next; - int rc = RC_INITERROR; + int rc; cmdline = _wcsdup(GetCommandLineW()); if (cmdline == NULL) - return rc; + exit(RC_INITERROR); /* Skip first arg, which is the program name */ if ((rc = find_end_of_word(cmdline, &word)) != RC_OK) - goto out; + exit(rc); word = skip_whitespace(word); while (*word) { WCHAR first; if ((rc = find_end_of_word(word, &end)) != RC_OK) - goto out; + exit(rc); next = skip_whitespace(end); first = word[0]; @@ -734,7 +734,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, lstrcpyW(supplieddestination, word); } else { XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARMS)); - goto out; + exit(RC_INITERROR); } } else { /* Process all the switch options @@ -772,7 +772,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, &word[1], 8, L"EXCLUDE:", -1) == CSTR_EQUAL) { if (XCOPY_ProcessExcludeList(&word[9])) { XCOPY_FailMessage(ERROR_INVALID_PARAMETER); - goto out; + exit(RC_INITERROR); } else { flags |= OPT_EXCLUDELIST; @@ -831,7 +831,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, wine_dbgstr_w(datestring), wine_dbgstr_w(timestring)); } else { XCOPY_FailMessage(ERROR_INVALID_PARAMETER); - goto out; + exit(RC_INITERROR); } } else { flags |= OPT_DATENEWER; @@ -851,7 +851,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, default: WINE_TRACE("Unhandled parameter '%s'\n", wine_dbgstr_w(word)); XCOPY_wprintf(XCOPY_LoadMessage(STRING_INVPARM), word); - goto out; + exit(RC_INITERROR); } /* Unless overridden above, skip over the '/' and the first character */ @@ -876,11 +876,7 @@ static int XCOPY_ParseCommandLine(WCHAR *suppliedsource, lstrcpyW(supplieddestination, L"."); *pflags = flags; - rc = RC_OK; - - out: - free(cmdline); - return rc; + return RC_OK; }
1
0
0
0
← Newer
1
...
41
42
43
44
45
46
47
...
52
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
Results per page:
10
25
50
100
200