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
July
June
May
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 2012
----- 2025 -----
July 2025
June 2025
May 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
828 discussions
Start a n
N
ew thread
Alexandre Julliard : server: Get rid of the waitpid wrapper.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 1fd55b7334bd743fb7e83b2eb10b428eca1bff84 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1fd55b7334bd743fb7e83b2eb…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Sep 24 20:29:43 2012 +0200 server: Get rid of the waitpid wrapper. --- server/ptrace.c | 25 ++++++------------------- 1 files changed, 6 insertions(+), 19 deletions(-) diff --git a/server/ptrace.c b/server/ptrace.c index efcdec0..19ec7da 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -98,6 +98,10 @@ static inline int ptrace(int req, ...) { errno = EPERM; return -1; /*FAIL*/ } #endif /* HAVE_SYS_PTRACE_H */ +#ifndef __WALL +#define __WALL 0 +#endif + /* handle a status returned by waitpid */ static int handle_child_status( struct thread *thread, int pid, int status, int want_sig ) { @@ -130,23 +134,6 @@ static int handle_child_status( struct thread *thread, int pid, int status, int return 0; } -/* waitpid wrapper to handle missing __WALL flag in older kernels */ -static inline pid_t waitpid_wrapper( pid_t pid, int *status, int options ) -{ -#ifdef __WALL - static int wall_flag = __WALL; - - for (;;) - { - pid_t ret = waitpid( pid, status, options | wall_flag ); - if (ret != -1 || !wall_flag || errno != EINVAL) return ret; - wall_flag = 0; - } -#else - return waitpid( pid, status, options ); -#endif -} - /* handle a SIGCHLD signal */ void sigchld_callback(void) { @@ -154,7 +141,7 @@ void sigchld_callback(void) for (;;) { - if (!(pid = waitpid_wrapper( -1, &status, WUNTRACED | WNOHANG ))) break; + if (!(pid = waitpid( -1, &status, WUNTRACED | WNOHANG | __WALL ))) break; if (pid != -1) { struct thread *thread = get_thread_from_tid( pid ); @@ -189,7 +176,7 @@ static int waitpid_thread( struct thread *thread, int signal ) start_watchdog(); for (;;) { - if ((res = waitpid_wrapper( get_ptrace_pid(thread), &status, WUNTRACED )) == -1) + if ((res = waitpid( get_ptrace_pid(thread), &status, WUNTRACED | __WALL )) == -1) { if (errno == EINTR) {
1
0
0
0
Adrian Bunk : server: Use waitpid() instead of wait4().
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 9d5c178b241e12c601ad4d986e658792932f343a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9d5c178b241e12c601ad4d986…
Author: Adrian Bunk <bunk(a)stusta.de> Date: Mon Sep 24 16:20:09 2012 +0300 server: Use waitpid() instead of wait4(). --- configure | 4 +--- configure.ac | 4 +--- include/config.h.in | 6 ------ server/ptrace.c | 22 +++++++++++----------- server/request.c | 2 +- tools/winapi/nativeapi.dat | 1 - 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/configure b/configure index 21044af..911f387 100755 --- a/configure +++ b/configure @@ -12994,9 +12994,7 @@ for ac_func in \ thr_kill2 \ timegm \ usleep \ - vsnprintf \ - wait4 \ - waitpid \ + vsnprintf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.ac b/configure.ac index 84b5de8..79b1175 100644 --- a/configure.ac +++ b/configure.ac @@ -2046,9 +2046,7 @@ AC_CHECK_FUNCS(\ thr_kill2 \ timegm \ usleep \ - vsnprintf \ - wait4 \ - waitpid \ + vsnprintf ) CFLAGS="$ac_save_CFLAGS" diff --git a/include/config.h.in b/include/config.h.in index a00fc1c..c1f29bc 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1076,12 +1076,6 @@ /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF -/* Define to 1 if you have the `wait4' function. */ -#undef HAVE_WAIT4 - -/* Define to 1 if you have the `waitpid' function. */ -#undef HAVE_WAITPID - /* Define to 1 if you have the <X11/extensions/shape.h> header file. */ #undef HAVE_X11_EXTENSIONS_SHAPE_H diff --git a/server/ptrace.c b/server/ptrace.c index 912f90e..efcdec0 100644 --- a/server/ptrace.c +++ b/server/ptrace.c @@ -98,7 +98,7 @@ static inline int ptrace(int req, ...) { errno = EPERM; return -1; /*FAIL*/ } #endif /* HAVE_SYS_PTRACE_H */ -/* handle a status returned by wait4 */ +/* handle a status returned by waitpid */ static int handle_child_status( struct thread *thread, int pid, int status, int want_sig ) { if (WIFSTOPPED(status)) @@ -130,20 +130,20 @@ static int handle_child_status( struct thread *thread, int pid, int status, int return 0; } -/* wait4 wrapper to handle missing __WALL flag in older kernels */ -static inline pid_t wait4_wrapper( pid_t pid, int *status, int options, struct rusage *usage ) +/* waitpid wrapper to handle missing __WALL flag in older kernels */ +static inline pid_t waitpid_wrapper( pid_t pid, int *status, int options ) { #ifdef __WALL static int wall_flag = __WALL; for (;;) { - pid_t ret = wait4( pid, status, options | wall_flag, usage ); + pid_t ret = waitpid( pid, status, options | wall_flag ); if (ret != -1 || !wall_flag || errno != EINVAL) return ret; wall_flag = 0; } #else - return wait4( pid, status, options, usage ); + return waitpid( pid, status, options ); #endif } @@ -154,7 +154,7 @@ void sigchld_callback(void) for (;;) { - if (!(pid = wait4_wrapper( -1, &status, WUNTRACED | WNOHANG, NULL ))) break; + if (!(pid = waitpid_wrapper( -1, &status, WUNTRACED | WNOHANG ))) break; if (pid != -1) { struct thread *thread = get_thread_from_tid( pid ); @@ -182,26 +182,26 @@ static int get_ptrace_tid( struct thread *thread ) } /* wait for a ptraced child to get a certain signal */ -static int wait4_thread( struct thread *thread, int signal ) +static int waitpid_thread( struct thread *thread, int signal ) { int res, status; start_watchdog(); for (;;) { - if ((res = wait4_wrapper( get_ptrace_pid(thread), &status, WUNTRACED, NULL )) == -1) + if ((res = waitpid_wrapper( get_ptrace_pid(thread), &status, WUNTRACED )) == -1) { if (errno == EINTR) { if (!watchdog_triggered()) continue; - if (debug_level) fprintf( stderr, "%04x: *watchdog* wait4 aborted\n", thread->id ); + if (debug_level) fprintf( stderr, "%04x: *watchdog* waitpid aborted\n", thread->id ); } else if (errno == ECHILD) /* must have died */ { thread->unix_pid = -1; thread->unix_tid = -1; } - else perror( "wait4" ); + else perror( "waitpid" ); stop_watchdog(); return 0; } @@ -292,7 +292,7 @@ static int suspend_for_ptrace( struct thread *thread ) if (errno == ESRCH) thread->unix_pid = thread->unix_tid = -1; /* thread got killed */ goto error; } - if (wait4_thread( thread, SIGSTOP )) return 1; + if (waitpid_thread( thread, SIGSTOP )) return 1; resume_after_ptrace( thread ); error: set_error( STATUS_ACCESS_DENIED ); diff --git a/server/request.c b/server/request.c index 05c7464..8d6a7f9 100644 --- a/server/request.c +++ b/server/request.c @@ -801,7 +801,7 @@ void open_master_socket(void) if (read( sync_pipe[0], &dummy, 1 ) == 1) _exit(0); /* child terminated, propagate exit status */ - wait4( pid, &status, 0, NULL ); + waitpid( pid, &status, 0 ); if (WIFEXITED(status)) _exit( WEXITSTATUS(status) ); _exit(1); } diff --git a/tools/winapi/nativeapi.dat b/tools/winapi/nativeapi.dat index bc25152..ade20b5 100644 --- a/tools/winapi/nativeapi.dat +++ b/tools/winapi/nativeapi.dat @@ -251,7 +251,6 @@ utime vfprintf vsnprintf vsprintf -wait4 write y0 y1
1
0
0
0
Józef Kucia : d3dx9: Implement conversion from D3DFORMAT to DDS pixel format for RGB pixel formats .
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 934293c1ecd3b4cd31043eae44c45792eb3731eb URL:
http://source.winehq.org/git/wine.git/?a=commit;h=934293c1ecd3b4cd31043eae4…
Author: Józef Kucia <joseph.kucia(a)gmail.com> Date: Mon Sep 24 13:46:40 2012 +0200 d3dx9: Implement conversion from D3DFORMAT to DDS pixel format for RGB pixel formats. --- dlls/d3dx9_36/surface.c | 71 +++++++++++++++++++++++++--------------------- 1 files changed, 39 insertions(+), 32 deletions(-) diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 770a2e5..9f215c7 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -166,33 +166,34 @@ static D3DFORMAT dds_fourcc_to_d3dformat(DWORD fourcc) return D3DFMT_UNKNOWN; } +static const struct { + DWORD bpp; + DWORD rmask; + DWORD gmask; + DWORD bmask; + DWORD amask; + D3DFORMAT format; +} rgb_pixel_formats[] = { + { 8, 0xe0, 0x1c, 0x03, 0, D3DFMT_R3G3B2 }, + { 16, 0xf800, 0x07e0, 0x001f, 0x0000, D3DFMT_R5G6B5 }, + { 16, 0x7c00, 0x03e0, 0x001f, 0x8000, D3DFMT_A1R5G5B5 }, + { 16, 0x7c00, 0x03e0, 0x001f, 0x0000, D3DFMT_X1R5G5B5 }, + { 16, 0x0f00, 0x00f0, 0x000f, 0xf000, D3DFMT_A4R4G4B4 }, + { 16, 0x0f00, 0x00f0, 0x000f, 0x0000, D3DFMT_X4R4G4B4 }, + { 16, 0x00e0, 0x001c, 0x0003, 0xff00, D3DFMT_A8R3G3B2 }, + { 24, 0xff0000, 0x00ff00, 0x0000ff, 0x000000, D3DFMT_R8G8B8 }, + { 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000, D3DFMT_A8R8G8B8 }, + { 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000, D3DFMT_X8R8G8B8 }, + { 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000, D3DFMT_A2B10G10R10 }, + { 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000, D3DFMT_A2R10G10B10 }, + { 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000, D3DFMT_G16R16 }, + { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, D3DFMT_A8B8G8R8 }, + { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, D3DFMT_X8B8G8R8 }, +}; + static D3DFORMAT dds_rgb_to_d3dformat(const struct dds_pixel_format *pixel_format) { int i; - static const struct { - DWORD bpp; - DWORD rmask; - DWORD gmask; - DWORD bmask; - DWORD amask; - D3DFORMAT format; - } rgb_pixel_formats[] = { - { 8, 0xe0, 0x1c, 0x03, 0, D3DFMT_R3G3B2 }, - { 16, 0xf800, 0x07e0, 0x001f, 0x0000, D3DFMT_R5G6B5 }, - { 16, 0x7c00, 0x03e0, 0x001f, 0x8000, D3DFMT_A1R5G5B5 }, - { 16, 0x7c00, 0x03e0, 0x001f, 0x0000, D3DFMT_X1R5G5B5 }, - { 16, 0x0f00, 0x00f0, 0x000f, 0xf000, D3DFMT_A4R4G4B4 }, - { 16, 0x0f00, 0x00f0, 0x000f, 0x0000, D3DFMT_X4R4G4B4 }, - { 16, 0x00e0, 0x001c, 0x0003, 0xff00, D3DFMT_A8R3G3B2 }, - { 24, 0xff0000, 0x00ff00, 0x0000ff, 0x000000, D3DFMT_R8G8B8 }, - { 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000, D3DFMT_A8R8G8B8 }, - { 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000, D3DFMT_X8R8G8B8 }, - { 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000, D3DFMT_A2B10G10R10 }, - { 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000, D3DFMT_A2R10G10B10 }, - { 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000, D3DFMT_G16R16 }, - { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000, D3DFMT_A8B8G8R8 }, - { 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000, D3DFMT_X8B8G8R8 }, - }; for (i = 0; i < sizeof(rgb_pixel_formats) / sizeof(rgb_pixel_formats[0]); i++) { @@ -277,19 +278,25 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_format, D3DFORMAT d3dformat) { + int i; + memset(pixel_format, 0, sizeof(*pixel_format)); pixel_format->size = sizeof(*pixel_format); - if (d3dformat == D3DFMT_R8G8B8) + for (i = 0; i < sizeof(rgb_pixel_formats) / sizeof(rgb_pixel_formats[0]); i++) { - pixel_format->flags = DDS_PF_RGB; - pixel_format->bpp = 24; - pixel_format->rmask = 0xff0000; - pixel_format->gmask = 0x00ff00; - pixel_format->bmask = 0x0000ff; - pixel_format->amask = 0x000000; - return D3D_OK; + if (rgb_pixel_formats[i].format == d3dformat) + { + pixel_format->flags |= DDS_PF_RGB; + pixel_format->bpp = rgb_pixel_formats[i].bpp; + pixel_format->rmask = rgb_pixel_formats[i].rmask; + pixel_format->gmask = rgb_pixel_formats[i].gmask; + pixel_format->bmask = rgb_pixel_formats[i].bmask; + pixel_format->amask = rgb_pixel_formats[i].amask; + if (pixel_format->amask) pixel_format->flags |= DDS_PF_ALPHA; + return D3D_OK; + } } WARN("Unknown pixel format %#x\n", d3dformat);
1
0
0
0
Józef Kucia : d3dx9/tests: Add a more detailed test for saving a surface to a DDS file.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 94ab09a226883c96e5658c9f0b95710af356f890 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=94ab09a226883c96e5658c9f0…
Author: Józef Kucia <joseph.kucia(a)gmail.com> Date: Mon Sep 24 13:46:39 2012 +0200 d3dx9/tests: Add a more detailed test for saving a surface to a DDS file. --- dlls/d3dx9_36/tests/surface.c | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 50ed2b2..84a70cf 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1160,6 +1160,24 @@ next_tests: hr = D3DXSaveSurfaceToFileA("saved_surface.dds", D3DXIFF_DDS, surface, NULL, NULL); ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3D_OK); + if (SUCCEEDED(hr)) { + hr = D3DXLoadSurfaceFromFileA(surface, NULL, NULL, "saved_surface.dds", NULL, D3DX_FILTER_NONE, 0, &image_info); + ok(hr == D3D_OK, "Couldn't load saved surface %#x\n", hr); + + if (SUCCEEDED(hr)) { + ok(image_info.Width == 2, "Wrong width %u\n", image_info.Width); + ok(image_info.Format == D3DFMT_R8G8B8, "Wrong format %#x\n", image_info.Format); + ok(image_info.ImageFileFormat == D3DXIFF_DDS, "Wrong file format %u\n", image_info.ImageFileFormat); + + hr = IDirect3DSurface9_LockRect(surface, &lock_rect, NULL, D3DLOCK_READONLY); + ok(hr == D3D_OK, "Couldn't lock surface %#x\n", hr); + if (SUCCEEDED(hr)) { + ok(!memcmp(lock_rect.pBits, pixels, pitch), "Pixel data mismatch in first row\n"); + ok(!memcmp((BYTE *)lock_rect.pBits + lock_rect.Pitch, pixels + pitch, pitch), "Pixel data mismatch in second row\n"); + IDirect3DSurface9_UnlockRect(surface); + } + } + } else skip("Couldn't save surface\n"); hr = D3DXSaveSurfaceToFileA("saved_surface", D3DXIFF_PFM + 1, surface, NULL, NULL); ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1
0
0
0
Józef Kucia : d3dx9: Implement the support for saving a surface to a DDS file.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: bf4201ea58efb099f0d9f4fe8669d68d74f2a633 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bf4201ea58efb099f0d9f4fe8…
Author: Józef Kucia <joseph.kucia(a)gmail.com> Date: Mon Sep 24 13:46:38 2012 +0200 d3dx9: Implement the support for saving a surface to a DDS file. --- dlls/d3dx9_36/surface.c | 93 +++++++++++++++++++++++++++++++++++++++++ dlls/d3dx9_36/tests/surface.c | 3 +- 2 files changed, 95 insertions(+), 1 deletions(-) diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 3bf8cb1..770a2e5 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -275,6 +275,27 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi return D3DFMT_UNKNOWN; } +static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_format, D3DFORMAT d3dformat) +{ + memset(pixel_format, 0, sizeof(*pixel_format)); + + pixel_format->size = sizeof(*pixel_format); + + if (d3dformat == D3DFMT_R8G8B8) + { + pixel_format->flags = DDS_PF_RGB; + pixel_format->bpp = 24; + pixel_format->rmask = 0xff0000; + pixel_format->gmask = 0x00ff00; + pixel_format->bmask = 0x0000ff; + pixel_format->amask = 0x000000; + return D3D_OK; + } + + WARN("Unknown pixel format %#x\n", d3dformat); + return E_NOTIMPL; +} + static HRESULT calculate_dds_surface_size(D3DFORMAT format, UINT width, UINT height, UINT *pitch, UINT *size) { @@ -410,6 +431,77 @@ static HRESULT load_surface_from_dds(IDirect3DSurface9 *dst_surface, const PALET src_pitch, NULL, src_rect, filter, color_key); } +static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSurface9 *src_surface, const RECT *src_rect) +{ + HRESULT hr; + UINT dst_pitch, surface_size, file_size; + D3DSURFACE_DESC src_desc; + D3DLOCKED_RECT locked_rect; + ID3DXBuffer *buffer; + struct dds_header *header; + BYTE *pixels; + struct volume volume; + const struct pixel_format_desc *pixel_format; + + if (src_rect) + { + FIXME("Saving a part of a surface to a DDS file is not implemented yet\n"); + return E_NOTIMPL; + } + + hr = IDirect3DSurface9_GetDesc(src_surface, &src_desc); + if (FAILED(hr)) return hr; + + pixel_format = get_format_info(src_desc.Format); + if (pixel_format->type == FORMAT_UNKNOWN) return E_NOTIMPL; + + file_size = calculate_dds_file_size(src_desc.Format, src_desc.Width, src_desc.Height, 1, 1, 1); + + hr = calculate_dds_surface_size(src_desc.Format, src_desc.Width, src_desc.Height, &dst_pitch, &surface_size); + if (FAILED(hr)) return hr; + + hr = D3DXCreateBuffer(file_size, &buffer); + if (FAILED(hr)) return hr; + + header = ID3DXBuffer_GetBufferPointer(buffer); + pixels = (BYTE *)(header + 1); + + memset(header, 0, sizeof(header)); + header->signature = MAKEFOURCC('D','D','S',' '); + header->size = sizeof(*header); + header->flags = DDS_CAPS | DDS_HEIGHT | DDS_WIDTH | DDS_PITCH | DDS_PIXELFORMAT | DDS_MIPMAPCOUNT; + header->height = src_desc.Height; + header->width = src_desc.Width; + header->pitch_or_linear_size = dst_pitch; + header->depth = 1; + header->miplevels = 1; + header->caps = DDS_CAPS_TEXTURE; + hr = d3dformat_to_dds_pixel_format(&header->pixel_format, src_desc.Format); + if (FAILED(hr)) + { + ID3DXBuffer_Release(buffer); + return hr; + } + + hr = IDirect3DSurface9_LockRect(src_surface, &locked_rect, NULL, D3DLOCK_READONLY); + if (FAILED(hr)) + { + ID3DXBuffer_Release(buffer); + return hr; + } + + volume.width = src_desc.Width; + volume.height = src_desc.Height; + volume.depth = 1; + copy_simple_data(locked_rect.pBits, locked_rect.Pitch, 0, &volume, pixel_format, + pixels, dst_pitch, 0, &volume, pixel_format, 0); + + IDirect3DSurface9_UnlockRect(src_surface); + + *dst_buffer = buffer; + return D3D_OK; +} + HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) @@ -1761,6 +1853,7 @@ HRESULT WINAPI D3DXSaveSurfaceToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE encoder_clsid = &CLSID_WICJpegEncoder; break; case D3DXIFF_DDS: + return save_dds_surface_to_memory(dst_buffer, src_surface, src_rect); case D3DXIFF_DIB: case D3DXIFF_HDR: case D3DXIFF_PFM: diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index 5a01200..50ed2b2 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -1156,9 +1156,10 @@ next_tests: ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3D_OK); hr = D3DXSaveSurfaceToFileA("saved_surface.tga", D3DXIFF_TGA, surface, NULL, NULL); ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3D_OK); + } + hr = D3DXSaveSurfaceToFileA("saved_surface.dds", D3DXIFF_DDS, surface, NULL, NULL); ok(hr == D3D_OK, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3D_OK); - } hr = D3DXSaveSurfaceToFileA("saved_surface", D3DXIFF_PFM + 1, surface, NULL, NULL); ok(hr == D3DERR_INVALIDCALL, "D3DXSaveSurfaceToFileA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
1
0
0
0
Józef Kucia : d3dx9: Use 4 spaces per indent level in get_image_info_from_dds().
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 8f00a63161f17ea6205b491205c6dcc26d4d3e20 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8f00a63161f17ea6205b49120…
Author: Józef Kucia <joseph.kucia(a)gmail.com> Date: Mon Sep 24 13:46:37 2012 +0200 d3dx9: Use 4 spaces per indent level in get_image_info_from_dds(). --- dlls/d3dx9_36/surface.c | 102 +++++++++++++++++++++++----------------------- 1 files changed, 51 insertions(+), 51 deletions(-) diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 4b9b056..3bf8cb1 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -337,58 +337,58 @@ static UINT calculate_dds_file_size(D3DFORMAT format, UINT width, UINT height, U */ static HRESULT get_image_info_from_dds(const void *buffer, UINT length, D3DXIMAGE_INFO *info) { - UINT faces = 1; - UINT expected_length; - const struct dds_header *header = buffer; - - if (length < sizeof(*header) || !info) - return D3DXERR_INVALIDDATA; - - if (header->pixel_format.size != sizeof(header->pixel_format)) - return D3DXERR_INVALIDDATA; - - info->Width = header->width; - info->Height = header->height; - info->Depth = 1; - info->MipLevels = (header->flags & DDS_MIPMAPCOUNT) ? header->miplevels : 1; - - info->Format = dds_pixel_format_to_d3dformat(&header->pixel_format); - if (info->Format == D3DFMT_UNKNOWN) - return D3DXERR_INVALIDDATA; - - TRACE("Pixel format is %#x\n", info->Format); - - if (header->caps2 & DDS_CAPS2_VOLUME) - { - info->Depth = header->depth; - info->ResourceType = D3DRTYPE_VOLUMETEXTURE; - } - else if (header->caps2 & DDS_CAPS2_CUBEMAP) - { - DWORD face; - faces = 0; - for (face = DDS_CAPS2_CUBEMAP_POSITIVEX; face <= DDS_CAPS2_CUBEMAP_NEGATIVEZ; face <<= 1) - { - if (header->caps2 & face) - faces++; - } - info->ResourceType = D3DRTYPE_CUBETEXTURE; - } - else - { - info->ResourceType = D3DRTYPE_TEXTURE; - } - - expected_length = calculate_dds_file_size(info->Format, info->Width, info->Height, info->Depth, + UINT faces = 1; + UINT expected_length; + const struct dds_header *header = buffer; + + if (length < sizeof(*header) || !info) + return D3DXERR_INVALIDDATA; + + if (header->pixel_format.size != sizeof(header->pixel_format)) + return D3DXERR_INVALIDDATA; + + info->Width = header->width; + info->Height = header->height; + info->Depth = 1; + info->MipLevels = (header->flags & DDS_MIPMAPCOUNT) ? header->miplevels : 1; + + info->Format = dds_pixel_format_to_d3dformat(&header->pixel_format); + if (info->Format == D3DFMT_UNKNOWN) + return D3DXERR_INVALIDDATA; + + TRACE("Pixel format is %#x\n", info->Format); + + if (header->caps2 & DDS_CAPS2_VOLUME) + { + info->Depth = header->depth; + info->ResourceType = D3DRTYPE_VOLUMETEXTURE; + } + else if (header->caps2 & DDS_CAPS2_CUBEMAP) + { + DWORD face; + faces = 0; + for (face = DDS_CAPS2_CUBEMAP_POSITIVEX; face <= DDS_CAPS2_CUBEMAP_NEGATIVEZ; face <<= 1) + { + if (header->caps2 & face) + faces++; + } + info->ResourceType = D3DRTYPE_CUBETEXTURE; + } + else + { + info->ResourceType = D3DRTYPE_TEXTURE; + } + + expected_length = calculate_dds_file_size(info->Format, info->Width, info->Height, info->Depth, info->MipLevels, faces); - if (length < expected_length) - { - WARN("File is too short %u, expected at least %u bytes\n", length, expected_length); - return D3DXERR_INVALIDDATA; - } - - info->ImageFileFormat = D3DXIFF_DDS; - return D3D_OK; + if (length < expected_length) + { + WARN("File is too short %u, expected at least %u bytes\n", length, expected_length); + return D3DXERR_INVALIDDATA; + } + + info->ImageFileFormat = D3DXIFF_DDS; + return D3D_OK; } static HRESULT load_surface_from_dds(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette,
1
0
0
0
Józef Kucia : d3dx9: Introduce a function for calculating the expected size of a DDS file.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 00ea54f64f0bc90d38fc49ea803c8d8459db2bc1 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=00ea54f64f0bc90d38fc49ea8…
Author: Józef Kucia <joseph.kucia(a)gmail.com> Date: Mon Sep 24 13:46:36 2012 +0200 d3dx9: Introduce a function for calculating the expected size of a DDS file. --- dlls/d3dx9_36/surface.c | 61 ++++++++++++++++++++++++---------------------- 1 files changed, 32 insertions(+), 29 deletions(-) diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index f0b1c72..4b9b056 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -275,10 +275,10 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi return D3DFMT_UNKNOWN; } -static HRESULT calculate_dds_surface_size(const D3DXIMAGE_INFO *img_info, - UINT width, UINT height, UINT *pitch, UINT *size) +static HRESULT calculate_dds_surface_size(D3DFORMAT format, UINT width, UINT height, + UINT *pitch, UINT *size) { - const struct pixel_format_desc *format_desc = get_format_info(img_info->Format); + const struct pixel_format_desc *format_desc = get_format_info(format); if (format_desc->format == D3DFMT_UNKNOWN) return E_NOTIMPL; @@ -298,6 +298,27 @@ static HRESULT calculate_dds_surface_size(const D3DXIMAGE_INFO *img_info, return D3D_OK; } +static UINT calculate_dds_file_size(D3DFORMAT format, UINT width, UINT height, UINT depth, + UINT miplevels, UINT faces) +{ + UINT i, file_size = 0; + + for (i = 0; i < miplevels; i++) + { + UINT pitch, size = 0; + calculate_dds_surface_size(format, width, height, &pitch, &size); + size *= depth; + file_size += size; + width = max(1, width / 2); + height = max(1, height / 2); + depth = max(1, depth / 2); + } + + file_size *= faces; + file_size += sizeof(struct dds_header); + return file_size; +} + /************************************************************ * get_image_info_from_dds * @@ -316,11 +337,9 @@ static HRESULT calculate_dds_surface_size(const D3DXIMAGE_INFO *img_info, */ static HRESULT get_image_info_from_dds(const void *buffer, UINT length, D3DXIMAGE_INFO *info) { - UINT i; UINT faces = 1; - UINT width, height, depth; + UINT expected_length; const struct dds_header *header = buffer; - UINT expected_length = 0; if (length < sizeof(*header) || !info) return D3DXERR_INVALIDDATA; @@ -360,23 +379,8 @@ static HRESULT get_image_info_from_dds(const void *buffer, UINT length, D3DXIMAG info->ResourceType = D3DRTYPE_TEXTURE; } - /* calculate the expected length */ - width = info->Width; - height = info->Height; - depth = info->Depth; - for (i = 0; i < info->MipLevels; i++) - { - UINT pitch, size = 0; - calculate_dds_surface_size(info, width, height, &pitch, &size); - size *= depth; - expected_length += size; - width = max(1, width / 2); - height = max(1, height / 2); - depth = max(1, depth / 2); - } - - expected_length *= faces; - expected_length += sizeof(*header); + expected_length = calculate_dds_file_size(info->Format, info->Width, info->Height, info->Depth, + info->MipLevels, faces); if (length < expected_length) { WARN("File is too short %u, expected at least %u bytes\n", length, expected_length); @@ -384,7 +388,6 @@ static HRESULT get_image_info_from_dds(const void *buffer, UINT length, D3DXIMAG } info->ImageFileFormat = D3DXIFF_DDS; - return D3D_OK; } @@ -400,7 +403,7 @@ static HRESULT load_surface_from_dds(IDirect3DSurface9 *dst_surface, const PALET if (src_info->ResourceType != D3DRTYPE_TEXTURE) return D3DXERR_INVALIDDATA; - if (FAILED(calculate_dds_surface_size(src_info, src_info->Width, src_info->Height, &src_pitch, &size))) + if (FAILED(calculate_dds_surface_size(src_info->Format, src_info->Width, src_info->Height, &src_pitch, &size))) return E_NOTIMPL; return D3DXLoadSurfaceFromMemory(dst_surface, dst_palette, dst_rect, pixels, src_info->Format, @@ -418,7 +421,7 @@ HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *d if (src_info->ResourceType != D3DRTYPE_VOLUMETEXTURE) return D3DXERR_INVALIDDATA; - if (FAILED(calculate_dds_surface_size(src_info, src_info->Width, src_info->Height, &row_pitch, &slice_pitch))) + if (FAILED(calculate_dds_surface_size(src_info->Format, src_info->Width, src_info->Height, &row_pitch, &slice_pitch))) return E_NOTIMPL; return D3DXLoadVolumeFromMemory(dst_volume, dst_palette, dst_box, pixels, src_info->Format, @@ -448,7 +451,7 @@ HRESULT load_texture_from_dds(IDirect3DTexture9 *texture, const void *src_data, mip_levels = min(src_info->MipLevels, IDirect3DTexture9_GetLevelCount(texture)); for (mip_level = 0; mip_level < mip_levels; mip_level++) { - hr = calculate_dds_surface_size(src_info, width, height, &src_pitch, &mip_level_size); + hr = calculate_dds_surface_size(src_info->Format, width, height, &src_pitch, &mip_level_size); if (FAILED(hr)) return hr; SetRect(&src_rect, 0, 0, width, height); @@ -497,7 +500,7 @@ HRESULT load_cube_texture_from_dds(IDirect3DCubeTexture9 *cube_texture, const vo size = src_info->Width; for (mip_level = 0; mip_level < src_info->MipLevels; mip_level++) { - hr = calculate_dds_surface_size(src_info, size, size, &src_pitch, &mip_level_size); + hr = calculate_dds_surface_size(src_info->Format, size, size, &src_pitch, &mip_level_size); if (FAILED(hr)) return hr; /* if texture has fewer mip levels than DDS file, skip excessive mip levels */ @@ -544,7 +547,7 @@ HRESULT load_volume_texture_from_dds(IDirect3DVolumeTexture9 *volume_texture, co for (mip_level = 0; mip_level < mip_levels; mip_level++) { - hr = calculate_dds_surface_size(src_info, width, height, &src_row_pitch, &src_slice_pitch); + hr = calculate_dds_surface_size(src_info->Format, width, height, &src_row_pitch, &src_slice_pitch); if (FAILED(hr)) return hr; hr = IDirect3DVolumeTexture9_GetVolumeLevel(volume_texture, mip_level, &volume);
1
0
0
0
Jacek Caban : jscript: Properly invoke regexp matching in String.split.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: fa0dfd0bb648c590a7cb24958ef837245b6955d0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fa0dfd0bb648c590a7cb24958…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 24 15:41:53 2012 +0200 jscript: Properly invoke regexp matching in String.split. --- dlls/jscript/string.c | 42 ++++++++++++++++++------------------------ dlls/jscript/tests/regexp.js | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index e7216df..6387896 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -1081,12 +1081,11 @@ static HRESULT String_small(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - match_result_t *match_result = NULL; - DWORD length, match_cnt, i, match_len = 0; - const WCHAR *str, *ptr, *ptr2; + match_result_t match_result; + DWORD length, i, match_len = 0; + const WCHAR *str, *ptr, *ptr2, *cp; unsigned limit = UINT32_MAX; - BOOL use_regexp = FALSE; - jsdisp_t *array; + jsdisp_t *array, *regexp = NULL; BSTR val_str, match_str = NULL, tmp_str; HRESULT hres; @@ -1110,23 +1109,16 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } if(is_object_instance(argv[0])) { - jsdisp_t *regexp; - regexp = iface_to_jsdisp((IUnknown*)get_object(argv[0])); if(regexp) { - if(is_class(regexp, JSCLASS_REGEXP)) { - use_regexp = TRUE; - hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt); - } - jsdisp_release(regexp); - if(FAILED(hres)) { - SysFreeString(val_str); - return hres; + if(!is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; } } } - if(!use_regexp) { + if(!regexp) { hres = to_string(ctx, argv[0], &match_str); if(FAILED(hres)) { SysFreeString(val_str); @@ -1143,12 +1135,13 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi hres = create_array(ctx, 0, &array); if(SUCCEEDED(hres)) { - ptr = str; + ptr = cp = str; for(i=0; i<limit; i++) { - if(use_regexp) { - if(i == match_cnt) + if(regexp) { + hres = regexp_match_next(ctx, regexp, 0, str, length, &cp, NULL, NULL, NULL, &match_result); + if(hres != S_OK) break; - ptr2 = match_result[i].str; + ptr2 = match_result.str; }else if(match_str) { ptr2 = strstrW(ptr, match_str); if(!ptr2) @@ -1170,8 +1163,8 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi if(FAILED(hres)) break; - if(use_regexp) - ptr = match_result[i].str + match_result[i].len; + if(regexp) + ptr = cp; else if(match_str) ptr = ptr2 + match_len; else @@ -1179,7 +1172,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } } - if(SUCCEEDED(hres) && (match_str || use_regexp) && i<limit) { + if(SUCCEEDED(hres) && (match_str || regexp) && i<limit) { DWORD len = (str+length) - ptr; if(len || match_str) { @@ -1194,9 +1187,10 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } } + if(regexp) + jsdisp_release(regexp); SysFreeString(match_str); SysFreeString(val_str); - heap_free(match_result); if(SUCCEEDED(hres) && r) *r = jsval_obj(array); diff --git a/dlls/jscript/tests/regexp.js b/dlls/jscript/tests/regexp.js index 38d5377..6274f93 100644 --- a/dlls/jscript/tests/regexp.js +++ b/dlls/jscript/tests/regexp.js @@ -378,6 +378,19 @@ ok(r[2] === "3", "r[2] = " + r[2]); ok(RegExp.leftContext === "1,,2", "RegExp.leftContext = " + RegExp.leftContext); ok(RegExp.rightContext === "3", "RegExp.rightContext = " + RegExp.rightContext); +r = "1,,2,3".split(/,+/g, 2); +ok(r.length === 2, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); +ok(RegExp.leftContext === "1,,2", "RegExp.leftContext = " + RegExp.leftContext); +ok(RegExp.rightContext === "3", "RegExp.rightContext = " + RegExp.rightContext); + +r = "1,,2,3".split(/,+/g, 1); +ok(r.length === 1, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(RegExp.leftContext === "1", "RegExp.leftContext = " + RegExp.leftContext); +ok(RegExp.rightContext === "2,3", "RegExp.rightContext = " + RegExp.rightContext); + r = "1,,2,3".split(/,+/); ok(r.length === 3, "r.length = " + r.length); ok(r[0] === "1", "r[0] = " + r[0]); @@ -411,6 +424,15 @@ r = "123".split(re = /\s+/).join(";"); ok(r === "123", "r = " + r); ok(re.lastIndex === 0, "re.lastIndex = " + re.lastIndex); +r = "1ab2aab3".split(/(a+)b/); +ok(r.length === 3, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); +ok(r[2] === "3", "r[2] = " + r[2]); + +r = "A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/) ; +ok(r.length === 4, "r.length = " + r.length); + /* another standard violation */ r = "1 12 \t3".split(re = /(\s)+/g).join(";"); ok(r === "1;12;3", "r = " + r);
1
0
0
0
Jacek Caban : jscript: Added support for limit argument in String.split.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 77c3dc544b1b946caf4949375c0e508f5334a2b5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=77c3dc544b1b946caf4949375…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Mon Sep 24 15:41:34 2012 +0200 jscript: Added support for limit argument in String.split. --- dlls/jscript/string.c | 19 +++++++++++++++---- dlls/jscript/tests/api.js | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c index 5d50b85..e7216df 100644 --- a/dlls/jscript/string.c +++ b/dlls/jscript/string.c @@ -25,6 +25,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); +#define UINT32_MAX 0xffffffff + typedef struct { jsdisp_t dispex; @@ -1082,6 +1084,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi match_result_t *match_result = NULL; DWORD length, match_cnt, i, match_len = 0; const WCHAR *str, *ptr, *ptr2; + unsigned limit = UINT32_MAX; BOOL use_regexp = FALSE; jsdisp_t *array; BSTR val_str, match_str = NULL, tmp_str; @@ -1089,8 +1092,8 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi TRACE("\n"); - if(argc != 1) { - FIXME("unsupported args\n"); + if(argc != 1 && argc != 2) { + FIXME("unsupported argc %u\n", argc); return E_NOTIMPL; } @@ -1098,6 +1101,14 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi if(FAILED(hres)) return hres; + if(argc > 1 && !is_undefined(argv[1])) { + hres = to_uint32(ctx, argv[1], &limit); + if(FAILED(hres)) { + SysFreeString(val_str); + return hres; + } + } + if(is_object_instance(argv[0])) { jsdisp_t *regexp; @@ -1133,7 +1144,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi if(SUCCEEDED(hres)) { ptr = str; - for(i=0;; i++) { + for(i=0; i<limit; i++) { if(use_regexp) { if(i == match_cnt) break; @@ -1168,7 +1179,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi } } - if(SUCCEEDED(hres) && (match_str || use_regexp)) { + if(SUCCEEDED(hres) && (match_str || use_regexp) && i<limit) { DWORD len = (str+length) - ptr; if(len || match_str) { diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index c998fa6..03d1a71 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -512,6 +512,23 @@ ok(r[0] === "1", "r[0] = " + r[0]); ok(r[1] === "2", "r[1] = " + r[1]); ok(r[2] === "", "r[2] = " + r[2]); +r = "1,2,3".split(",", 2); +ok(typeof(r) === "object", "typeof(r) = " + typeof(r)); +ok(r.length === 2, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); + +r = "1,2,3".split(",", 0); +ok(typeof(r) === "object", "typeof(r) = " + typeof(r)); +ok(r.length === 0, "r.length = " + r.length); + +r = "1,2,3".split(",", -1); +ok(typeof(r) === "object", "typeof(r) = " + typeof(r)); +ok(r.length === 3, "r.length = " + r.length); +ok(r[0] === "1", "r[0] = " + r[0]); +ok(r[1] === "2", "r[1] = " + r[1]); +ok(r[2] === "3", "r[1] = " + r[1]); + tmp = "abcd".indexOf("bc",0); ok(tmp === 1, "indexOf = " + tmp); tmp = "abcd".indexOf("bc",1);
1
0
0
0
Francois Gouget : shell32: Add some more function prototypes and fix the IsNetDrive() one.
by Alexandre Julliard
24 Sep '12
24 Sep '12
Module: wine Branch: master Commit: 79ea850eab4b47bee5c60b7bd44cb16b9e91c218 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=79ea850eab4b47bee5c60b7bd…
Author: Francois Gouget <fgouget(a)free.fr> Date: Mon Sep 24 16:33:41 2012 +0200 shell32: Add some more function prototypes and fix the IsNetDrive() one. --- dlls/shell32/shlfileop.c | 4 ++-- include/shlobj.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c index 5fa79a9..d07c588 100644 --- a/dlls/shell32/shlfileop.c +++ b/dlls/shell32/shlfileop.c @@ -1708,7 +1708,7 @@ DWORD WINAPI SheChangeDirW(LPWSTR path) /************************************************************************* * IsNetDrive [SHELL32.66] */ -BOOL WINAPI IsNetDrive(DWORD drive) +int WINAPI IsNetDrive(int drive) { char root[4]; strcpy(root, "A:\\"); @@ -1720,7 +1720,7 @@ BOOL WINAPI IsNetDrive(DWORD drive) /************************************************************************* * RealDriveType [SHELL32.524] */ -INT WINAPI RealDriveType(INT drive, BOOL bQueryNet) +int WINAPI RealDriveType(int drive, BOOL bQueryNet) { char root[] = "A:\\"; root[0] += (char)drive; diff --git a/include/shlobj.h b/include/shlobj.h index 103a1cf..4502187 100644 --- a/include/shlobj.h +++ b/include/shlobj.h @@ -83,6 +83,8 @@ VOID WINAPI SHUpdateImageW(LPCWSTR,INT,UINT,INT); int WINAPI RestartDialog(HWND,LPCWSTR,DWORD); int WINAPI RestartDialogEx(HWND,LPCWSTR,DWORD,DWORD); int WINAPI DriveType(int); +int WINAPI RealDriveType(int, BOOL); +int WINAPI IsNetDrive(int); BOOL WINAPI IsUserAnAdmin(void); UINT WINAPI Shell_MergeMenus(HMENU,HMENU,UINT,UINT,UINT,ULONG); BOOL WINAPI Shell_GetImageLists(HIMAGELIST*,HIMAGELIST*); @@ -1636,10 +1638,13 @@ BOOL WINAPI WriteCabinetState(CABINETSTATE *); #define PRF_TRYPROGRAMEXTENSIONS 0x03 #define PRF_FIRSTDIRDEF 0x04 #define PRF_DONTFINDLINK 0x08 +#define PRF_REQUIREABSOLUTE 0x10 VOID WINAPI PathGetShortPath(LPWSTR pszPath); LONG WINAPI PathProcessCommand(LPCWSTR, LPWSTR, int, DWORD); +int WINAPI PathResolve(LPWSTR, PZPCWSTR, UINT); BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR, LPCWSTR, LPCWSTR, LPCWSTR); +BOOL WINAPI Win32DeleteFile(LPCWSTR); /**************************************************************************** * Drag And Drop Routines
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
83
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Results per page:
10
25
50
100
200