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
October 2009
----- 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
3 participants
1207 discussions
Start a n
N
ew thread
Alexandre Julliard : configure: Add -Werror flag in maintainer mode.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: 12753c572071e2acccf6886442bcb7b978d9943e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=12753c572071e2acccf688644…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Fri Oct 2 14:39:49 2009 +0200 configure: Add -Werror flag in maintainer mode. --- configure | 36 ++++++++++++++++++++++++++++++++++++ configure.ac | 6 ++++++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/configure b/configure index c16637c..5a7516d 100755 --- a/configure +++ b/configure @@ -11753,6 +11753,42 @@ $as_echo "$ac_cv_c_string_h_warnings" >&6; } then EXTRACFLAGS="$EXTRACFLAGS -Wpointer-arith" fi + + if test "${enable_maintainer_mode+set}" = set + then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Werror" >&5 +$as_echo_n "checking whether the compiler supports -Werror... " >&6; } +if test "${ac_cv_cflags__Werror+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + ac_wine_try_cflags_saved=$CFLAGS +CFLAGS="$CFLAGS -Werror" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_cflags__Werror=yes +else + ac_cv_cflags__Werror=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +CFLAGS=$ac_wine_try_cflags_saved +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags__Werror" >&5 +$as_echo "$ac_cv_cflags__Werror" >&6; } +if test $ac_cv_cflags__Werror = yes; then : + EXTRACFLAGS="$EXTRACFLAGS -Werror" +fi + fi fi diff --git a/configure.ac b/configure.ac index 6210c2f..0cc339b 100644 --- a/configure.ac +++ b/configure.ac @@ -1498,6 +1498,12 @@ then then EXTRACFLAGS="$EXTRACFLAGS -Wpointer-arith" fi + + dnl Enable -Werror for maintainer mode + if test "${enable_maintainer_mode+set}" = set + then + WINE_TRY_CFLAGS([-Werror]) + fi fi dnl **** Check for underscore on external symbols ****
1
0
0
0
Michael Stefaniuc : oleaut32/tests: Use LONG instead of long.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: 8b2723d48d922cb4fc0a2ae5192505978d606ab4 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8b2723d48d922cb4fc0a2ae51…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Fri Oct 2 12:18:50 2009 +0200 oleaut32/tests: Use LONG instead of long. --- dlls/oleaut32/tests/olefont.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c index 8e26a0f..b457f36 100644 --- a/dlls/oleaut32/tests/olefont.c +++ b/dlls/oleaut32/tests/olefont.c @@ -57,9 +57,9 @@ static HRESULT (WINAPI *pOleCreateFontIndirect)(LPFONTDESC,REFIID,LPVOID*); /* check that resulting hfont has height hfont_height. */ /* Various checks along the way. */ -static void test_ifont_sizes(long lo_size, long hi_size, - long ratio_logical, long ratio_himetric, - long hfont_height, const char * test_name) +static void test_ifont_sizes(LONG lo_size, LONG hi_size, + LONG ratio_logical, LONG ratio_himetric, + LONG hfont_height, const char * test_name) { FONTDESC fd; LPVOID pvObj = NULL; @@ -91,8 +91,8 @@ static void test_ifont_sizes(long lo_size, long hi_size, ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n", test_name, hres); ok(S(psize).Lo == lo_size && S(psize).Hi == 0, - "%s: get_Size: Lo=%d, Hi=%d; expected Lo=%ld, Hi=%ld.\n", - test_name, S(psize).Lo, S(psize).Hi, lo_size, 0L); + "%s: get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=0.\n", + test_name, S(psize).Lo, S(psize).Hi, lo_size); /* Change ratio, check size unchanged. Standard is 72, 2540. */ hres = IFont_SetRatio(ifnt, ratio_logical, ratio_himetric); @@ -102,8 +102,8 @@ static void test_ifont_sizes(long lo_size, long hi_size, ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n", test_name, hres); ok(S(psize).Lo == lo_size && S(psize).Hi == 0, - "%s: gS after SR: Lo=%d, Hi=%d; expected Lo=%ld, Hi=%ld.\n", - test_name, S(psize).Lo, S(psize).Hi, lo_size, 0L); + "%s: gS after SR: Lo=%d, Hi=%d; expected Lo=%d, Hi=0.\n", + test_name, S(psize).Lo, S(psize).Hi, lo_size); /* Check hFont size with this ratio. This tests an important */ /* conversion for which MSDN is very wrong. */ @@ -112,7 +112,7 @@ static void test_ifont_sizes(long lo_size, long hi_size, test_name, hres); hres = GetObject (hfont, sizeof(LOGFONT), &lf); ok(lf.lfHeight == hfont_height, - "%s: hFont has lf.lfHeight=%d, expected %ld.\n", + "%s: hFont has lf.lfHeight=%d, expected %d.\n", test_name, lf.lfHeight, hfont_height); /* Free IFont. */
1
0
0
0
Michael Stefaniuc : user32/tests: Use LONG instead of long.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: bd93d0b5d8a6a9299e8367ca49351a3e94132aac URL:
http://source.winehq.org/git/wine.git/?a=commit;h=bd93d0b5d8a6a9299e8367ca4…
Author: Michael Stefaniuc <mstefani(a)redhat.de> Date: Fri Oct 2 12:18:42 2009 +0200 user32/tests: Use LONG instead of long. --- dlls/user32/tests/msg.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 57931cf..761f3aa 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -5257,7 +5257,7 @@ static WNDPROC old_button_proc; static LRESULT CALLBACK button_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - static long defwndproc_counter = 0; + static LONG defwndproc_counter = 0; LRESULT ret; struct recvd_message msg; @@ -5458,7 +5458,7 @@ static WNDPROC old_static_proc; static LRESULT CALLBACK static_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - static long defwndproc_counter = 0; + static LONG defwndproc_counter = 0; LRESULT ret; struct recvd_message msg; @@ -5553,7 +5553,7 @@ static WNDPROC old_combobox_proc; static LRESULT CALLBACK combobox_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - static long defwndproc_counter = 0; + static LONG defwndproc_counter = 0; LRESULT ret; struct recvd_message msg; @@ -9011,7 +9011,7 @@ static WNDPROC old_edit_proc; static LRESULT CALLBACK edit_hook_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - static long defwndproc_counter = 0; + static LONG defwndproc_counter = 0; LRESULT ret; struct recvd_message msg;
1
0
0
0
Stefan Dösinger : wined3d: SetRenderTarget resets the scissor rect.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: cb5ce03de4e821257a21ac70bc82c0dcf91900d8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=cb5ce03de4e821257a21ac70b…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Wed Sep 30 18:59:41 2009 +0200 wined3d: SetRenderTarget resets the scissor rect. --- dlls/wined3d/device.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index e4b5cd1..90da2a0 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -6164,8 +6164,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, /* Render target 0 is special */ if(RenderTargetIndex == 0 && dxVersion > 7) { - /* Finally, reset the viewport as the MSDN states. Tests show that stateblock recording is ignored. - * the change goes directly into the primary stateblock. + /* Finally, reset the viewport and scissor rect as the MSDN states. + * Tests show that stateblock recording is ignored, the change goes + * directly into the primary stateblock. */ This->stateBlock->viewport.Height = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height; This->stateBlock->viewport.Width = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Width; @@ -6174,6 +6175,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, This->stateBlock->viewport.MaxZ = 1.0f; This->stateBlock->viewport.MinZ = 0.0f; IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT); + + This->stateBlock->scissorRect.top = 0; + This->stateBlock->scissorRect.left = 0; + This->stateBlock->scissorRect.right = This->stateBlock->viewport.Width; + This->stateBlock->scissorRect.bottom = This->stateBlock->viewport.Height; + IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SCISSORRECT); } return WINED3D_OK; }
1
0
0
0
Stefan Dösinger : wined3d: SetRenderTarget bypasses stateblock recording.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: 4a3f04cb5633d073b8ecdbc298e09ff71ba70c35 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=4a3f04cb5633d073b8ecdbc29…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Wed Sep 30 18:58:04 2009 +0200 wined3d: SetRenderTarget bypasses stateblock recording. --- dlls/wined3d/device.c | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 6cbf115..e4b5cd1 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -6130,7 +6130,6 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - WINED3DVIEWPORT viewport; int dxVersion = ( (IWineD3DImpl *) This->wineD3D)->dxVersion; TRACE("(%p) : Setting rendertarget %d to %p\n", This, RenderTargetIndex, pRenderTarget); @@ -6165,14 +6164,16 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, /* Render target 0 is special */ if(RenderTargetIndex == 0 && dxVersion > 7) { - /* Finally, reset the viewport as the MSDN states. */ - viewport.Height = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height; - viewport.Width = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Width; - viewport.X = 0; - viewport.Y = 0; - viewport.MaxZ = 1.0f; - viewport.MinZ = 0.0f; - IWineD3DDeviceImpl_SetViewport(iface, &viewport); + /* Finally, reset the viewport as the MSDN states. Tests show that stateblock recording is ignored. + * the change goes directly into the primary stateblock. + */ + This->stateBlock->viewport.Height = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height; + This->stateBlock->viewport.Width = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Width; + This->stateBlock->viewport.X = 0; + This->stateBlock->viewport.Y = 0; + This->stateBlock->viewport.MaxZ = 1.0f; + This->stateBlock->viewport.MinZ = 0.0f; + IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT); } return WINED3D_OK; }
1
0
0
0
Stefan Dösinger : wined3d: SetRenderTarget doesn' t change the viewport in d3d7.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: 9e068a33b3366ea072ec141a564bce2a0034e1fe URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9e068a33b3366ea072ec141a5…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Wed Sep 30 18:56:42 2009 +0200 wined3d: SetRenderTarget doesn't change the viewport in d3d7. --- dlls/ddraw/tests/d3d.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/device.c | 3 +- 2 files changed, 106 insertions(+), 1 deletions(-) diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 2d7d8d0..11b6a66 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -2973,6 +2973,109 @@ static void ComputeSphereVisibility(void) ok(result[0] == 0x2002f, "Expected 0x2002f, got %x\n", result[0]); } +static void SetRenderTargetTest(void) +{ + HRESULT hr; + IDirectDrawSurface7 *newrt, *oldrt; + D3DVIEWPORT7 vp; + DDSURFACEDESC2 ddsd; + DWORD stateblock; + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE; + ddsd.dwWidth = 64; + ddsd.dwHeight = 64; + hr = IDirectDraw7_CreateSurface(lpDD, &ddsd, &newrt, NULL); + ok(hr == DD_OK, "IDirectDraw7_CreateSurface failed, hr=0x%08x\n", hr); + if(FAILED(hr)) + { + skip("Skipping SetRenderTarget test\n"); + return; + } + + memset(&vp, 0, sizeof(vp)); + vp.dwX = 10; + vp.dwY = 10; + vp.dwWidth = 246; + vp.dwHeight = 246; + vp.dvMinZ = 0.25; + vp.dvMaxZ = 0.75; + hr = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp); + ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08x\n", hr); + + hr = IDirect3DDevice7_GetRenderTarget(lpD3DDevice, &oldrt); + ok(hr == DD_OK, "IDirect3DDevice7_GetRenderTarget failed, hr=0x%08x\n", hr); + + hr = IDirect3DDevice7_SetRenderTarget(lpD3DDevice, newrt, 0); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr=0x%08x\n", hr); + memset(&vp, 0xff, sizeof(vp)); + hr = IDirect3DDevice7_GetViewport(lpD3DDevice, &vp); + ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08x\n", hr); + ok(vp.dwX == 10, "vp.dwX is %u, expected 10\n", vp.dwX); + ok(vp.dwY == 10, "vp.dwY is %u, expected 10\n", vp.dwY); + ok(vp.dwWidth == 246, "vp.dwWidth is %u, expected 246\n", vp.dwWidth); + ok(vp.dwHeight == 246, "vp.dwHeight is %u, expected 246\n", vp.dwHeight); + ok(vp.dvMinZ == 0.25, "vp.dvMinZ is %f, expected 0.1\n", vp.dvMinZ); + ok(vp.dvMaxZ == 0.75, "vp.dvMaxZ is %f, expected 0.9\n", vp.dvMaxZ); + + memset(&vp, 0, sizeof(vp)); + vp.dwX = 0; + vp.dwY = 0; + vp.dwWidth = 64; + vp.dwHeight = 64; + vp.dvMinZ = 0.0; + vp.dvMaxZ = 1.0; + hr = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp); + ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08x\n", hr); + + hr = IDirect3DDevice7_BeginStateBlock(lpD3DDevice); + ok(hr == D3D_OK, "IDirect3DDevice7_BeginStateblock failed, hr=0x%08x\n", hr); + hr = IDirect3DDevice7_SetRenderTarget(lpD3DDevice, oldrt, 0); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderTarget failed, hr=0x%08x\n", hr); + + /* Check this twice, before and after ending the stateblock */ + memset(&vp, 0xff, sizeof(vp)); + hr = IDirect3DDevice7_GetViewport(lpD3DDevice, &vp); + ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08x\n", hr); + ok(vp.dwX == 0, "vp.dwX is %u, expected 0\n", vp.dwX); + ok(vp.dwY == 0, "vp.dwY is %u, expected 0\n", vp.dwY); + ok(vp.dwWidth == 64, "vp.dwWidth is %u, expected 64\n", vp.dwWidth); + ok(vp.dwHeight == 64, "vp.dwHeight is %u, expected 64\n", vp.dwHeight); + ok(vp.dvMinZ == 0.0, "vp.dvMinZ is %f, expected 0.0\n", vp.dvMinZ); + ok(vp.dvMaxZ == 1.0, "vp.dvMaxZ is %f, expected 1.0\n", vp.dvMaxZ); + + hr = IDirect3DDevice7_EndStateBlock(lpD3DDevice, &stateblock); + ok(hr == D3D_OK, "IDirect3DDevice7_EndStateblock failed, hr=0x%08x\n", hr); + + memset(&vp, 0xff, sizeof(vp)); + hr = IDirect3DDevice7_GetViewport(lpD3DDevice, &vp); + ok(hr == D3D_OK, "IDirect3DDevice7_GetViewport failed, hr=0x%08x\n", hr); + ok(vp.dwX == 0, "vp.dwX is %u, expected 0\n", vp.dwX); + ok(vp.dwY == 0, "vp.dwY is %u, expected 0\n", vp.dwY); + ok(vp.dwWidth == 64, "vp.dwWidth is %u, expected 64\n", vp.dwWidth); + ok(vp.dwHeight == 64, "vp.dwHeight is %u, expected 64\n", vp.dwHeight); + ok(vp.dvMinZ == 0.0, "vp.dvMinZ is %f, expected 0.0\n", vp.dvMinZ); + ok(vp.dvMaxZ == 1.0, "vp.dvMaxZ is %f, expected 1.0\n", vp.dvMaxZ); + + hr = IDirect3DDevice7_DeleteStateBlock(lpD3DDevice, stateblock); + ok(hr == D3D_OK, "IDirect3DDevice7_DeleteStateblock failed, hr=0x%08x\n", hr); + + memset(&vp, 0, sizeof(vp)); + vp.dwX = 0; + vp.dwY = 0; + vp.dwWidth = 256; + vp.dwHeight = 256; + vp.dvMinZ = 0.0; + vp.dvMaxZ = 0.0; + hr = IDirect3DDevice7_SetViewport(lpD3DDevice, &vp); + ok(hr == D3D_OK, "IDirect3DDevice7_SetViewport failed, hr=0x%08x\n", hr); + + IDirectDrawSurface7_Release(oldrt); + IDirectDrawSurface7_Release(newrt); +} + START_TEST(d3d) { init_function_pointers(); @@ -2996,6 +3099,7 @@ START_TEST(d3d) VertexBufferDescTest(); D3D7_OldRenderStateTest(); DeviceLoadTest(); + SetRenderTargetTest(); ReleaseDirect3D(); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 06be54b..6cbf115 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -6131,6 +6131,7 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, DWORD RenderTargetIndex, IWineD3DSurface *pRenderTarget) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; WINED3DVIEWPORT viewport; + int dxVersion = ( (IWineD3DImpl *) This->wineD3D)->dxVersion; TRACE("(%p) : Setting rendertarget %d to %p\n", This, RenderTargetIndex, pRenderTarget); @@ -6163,7 +6164,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, This->render_targets[RenderTargetIndex] = pRenderTarget; /* Render target 0 is special */ - if(RenderTargetIndex == 0) { + if(RenderTargetIndex == 0 && dxVersion > 7) { /* Finally, reset the viewport as the MSDN states. */ viewport.Height = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height; viewport.Width = ((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Width;
1
0
0
0
Stefan Dösinger : d3d9: Test viewports that are bigger than the surface.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: eda00d97adf9abe51f96be0ab28c1edf106bfaec URL:
http://source.winehq.org/git/wine.git/?a=commit;h=eda00d97adf9abe51f96be0ab…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Thu Oct 1 15:48:52 2009 +0200 d3d9: Test viewports that are bigger than the surface. --- dlls/d3d9/tests/visual.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/state.c | 19 ++++++------ 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 7240ab1..092cbe9 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -10395,6 +10395,76 @@ static void sgn_test(IDirect3DDevice9 *device) { IDirect3DVertexShader9_Release(shader); } +static void viewport_test(IDirect3DDevice9 *device) { + HRESULT hr; + DWORD color; + D3DVIEWPORT9 vp, old_vp; + const float quad[] = + { + -0.5, -0.5, 0.1, + 0.5, -0.5, 0.1, + -0.5, 0.5, 0.1, + 0.5, 0.5, 0.1 + }; + + memset(&old_vp, 0, sizeof(old_vp)); + hr = IDirect3DDevice9_GetViewport(device, &old_vp); + ok(hr == D3D_OK, "IDirect3DDevice9_GetViewport failed with %08x\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0x00ff0000, 0.0, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear returned %08x\n", hr); + + /* Test a viewport with Width and Height bigger than the surface dimensions + * + * TODO: Test Width < surface.width, but X + Width > surface.width + * TODO: Test Width < surface.width, what happens with the height? + */ + memset(&vp, 0, sizeof(vp)); + vp.X = 0; + vp.Y = 0; + vp.Width = 10000; + vp.Height = 10000; + vp.MinZ = 0.0; + vp.MaxZ = 0.0; + hr = IDirect3DDevice9_SetViewport(device, &vp); + ok(hr == D3D_OK, "IDirect3DDevice9_SetViewport failed with %08x\n", hr); + + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ); + ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF returned %08x\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene returned %08x\n", hr); + if(SUCCEEDED(hr)) + { + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 3 * sizeof(float)); + ok(hr == D3D_OK, "DrawPrimitiveUP failed (%08x)\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene returned %08x\n", hr); + } + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %08x\n", hr); + color = getPixelColor(device, 158, 118); + ok(color == 0x00ff0000, "viewport test: (158,118) has color %08x\n", color); + color = getPixelColor(device, 162, 118); + ok(color == 0x00ff0000, "viewport test: (162,118) has color %08x\n", color); + color = getPixelColor(device, 158, 122); + ok(color == 0x00ff0000, "viewport test: (158,122) has color %08x\n", color); + color = getPixelColor(device, 162, 122); + ok(color == 0x00ffffff, "viewport test: (162,122) has color %08x\n", color); + + color = getPixelColor(device, 478, 358); + ok(color == 0x00ffffff, "viewport test: (478,358 has color %08x\n", color); + color = getPixelColor(device, 482, 358); + ok(color == 0x00ff0000, "viewport test: (482,358) has color %08x\n", color); + color = getPixelColor(device, 478, 362); + ok(color == 0x00ff0000, "viewport test: (478,362) has color %08x\n", color); + color = getPixelColor(device, 482, 362); + ok(color == 0x00ff0000, "viewport test: (482,362) has color %08x\n", color); + + hr = IDirect3DDevice9_SetViewport(device, &old_vp); + ok(hr == D3D_OK, "IDirect3DDevice9_SetViewport failed with %08x\n", hr); +} + START_TEST(visual) { IDirect3DDevice9 *device_ptr; @@ -10493,6 +10563,7 @@ START_TEST(visual) yuv_color_test(device_ptr); zwriteenable_test(device_ptr); alphatest_test(device_ptr); + viewport_test(device_ptr); if (caps.VertexShaderVersion >= D3DVS_VERSION(1, 1)) { diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 944d8f7..637bec6 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -4642,24 +4642,25 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, s static void viewport_miscpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { UINT width, height; - IWineD3DSurfaceImpl *target; + IWineD3DSurfaceImpl *target = (IWineD3DSurfaceImpl *) stateblock->wineD3DDevice->render_targets[0]; + WINED3DVIEWPORT vp = stateblock->viewport; + + if(vp.Width > target->currentDesc.Width) vp.Width = target->currentDesc.Width; + if(vp.Height > target->currentDesc.Height) vp.Height = target->currentDesc.Height; - glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ); + glDepthRange(vp.MinZ, vp.MaxZ); checkGLcall("glDepthRange"); /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering */ if (context->render_offscreen) { - glViewport(stateblock->viewport.X, - stateblock->viewport.Y, - stateblock->viewport.Width, stateblock->viewport.Height); + glViewport(vp.X, vp.Y, vp.Width, vp.Height); } else { - target = (IWineD3DSurfaceImpl *) stateblock->wineD3DDevice->render_targets[0]; target->get_drawable_size(context, &width, &height); - glViewport(stateblock->viewport.X, - (height - (stateblock->viewport.Y + stateblock->viewport.Height)), - stateblock->viewport.Width, stateblock->viewport.Height); + glViewport(vp.X, + (height - (vp.Y + vp.Height)), + vp.Width, vp.Height); } checkGLcall("glViewport");
1
0
0
0
Stefan Dösinger : wined3d: Fix vs_2_0 sgn.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: dc45657f2c2547f6f737cc9e26a1b25e8ab8eba2 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=dc45657f2c2547f6f737cc9e2…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Thu Oct 1 15:31:39 2009 +0200 wined3d: Fix vs_2_0 sgn. vs_2_0's sgn has two extra parameters - temporary registers for the instruction. This patch fixes the crash of the d3d9:visual test on windows and properly handles the vs_2_0 version of sgn. --- dlls/d3d9/tests/visual.c | 2 +- dlls/wined3d/arb_program_shader.c | 10 +++++----- dlls/wined3d/glsl_shader.c | 18 ++++++++++++++++-- dlls/wined3d/shader_sm1.c | 3 ++- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index b4f1dda..7240ab1 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -10351,7 +10351,7 @@ static void sgn_test(IDirect3DDevice9 *device) { 0x05000051, 0xa00f0000, 0xbf000000, 0x00000000, 0x3f000000, 0x41400000, /* def c0, -0.5, 0.0, 0.5, 12.0 */ 0x05000051, 0xa00f0001, 0x3fc00000, 0x00000000, 0x00000000, 0x00000000, /* def c1, 1.5, 0.0, 0.0, 0.0 */ 0x02000001, 0xc00f0000, 0x90e40000, /* mov oPos, v0 */ - 0x02000022, 0x800f0000, 0xa0e40000, /* sgn r0, c0 */ + 0x04000022, 0x800f0000, 0xa0e40000, 0x80e40001, 0x80e40002, /* sgn r0, c0, r1, r2 */ 0x03000002, 0xd00f0000, 0x80e40000, 0xa0e40001, /* add oD0, r0, c1 */ 0x0000ffff /* end */ }; diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 3fefec9..f1218ad 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -1578,7 +1578,6 @@ static void shader_hw_map2gl(const struct wined3d_shader_instruction *ins) case WINED3DSIH_SLT: instruction = "SLT"; break; case WINED3DSIH_SUB: instruction = "SUB"; break; case WINED3DSIH_MOVA:instruction = "ARR"; break; - case WINED3DSIH_SGN: instruction = "SSG"; break; case WINED3DSIH_DSX: instruction = "DDX"; break; default: instruction = ""; FIXME("Unhandled opcode %#x\n", ins->handler_idx); @@ -2455,13 +2454,14 @@ static void shader_hw_sgn(const struct wined3d_shader_instruction *ins) char src_name[50]; struct shader_arb_ctx_priv *ctx = ins->ctx->backend_data; + shader_arb_get_dst_param(ins, &ins->dst[0], dst_name); + shader_arb_get_src_param(ins, &ins->src[0], 0, src_name); + /* SGN is only valid in vertex shaders */ - if(ctx->target_version == NV2) { - shader_hw_map2gl(ins); + if(ctx->target_version >= NV2) { + shader_addline(buffer, "SSG%s %s, %s;\n", shader_arb_get_modifier(ins), dst_name, src_name); return; } - shader_arb_get_dst_param(ins, &ins->dst[0], dst_name); - shader_arb_get_src_param(ins, &ins->src[0], 0, src_name); /* If SRC > 0.0, -SRC < SRC = TRUE, otherwise false. * if SRC < 0.0, SRC < -SRC = TRUE. If neither is true, src = 0.0 diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index cf61117..a8922d8 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1956,7 +1956,6 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) case WINED3DSIH_FRC: instruction = "fract"; break; case WINED3DSIH_NRM: instruction = "normalize"; break; case WINED3DSIH_EXP: instruction = "exp2"; break; - case WINED3DSIH_SGN: instruction = "sign"; break; case WINED3DSIH_DSX: instruction = "dFdx"; break; case WINED3DSIH_DSY: instruction = "ycorrection.y * dFdy"; break; default: instruction = ""; @@ -2449,6 +2448,21 @@ static void shader_glsl_sincos(const struct wined3d_shader_instruction *ins) } } +/* sgn in vs_2_0 has 2 extra parameters(registers for temporary storage) which we don't use + * here. But those extra parameters require a dedicated function for sgn, since map2gl would + * generate invalid code + */ +static void shader_glsl_sgn(const struct wined3d_shader_instruction *ins) +{ + glsl_src_param_t src0_param; + DWORD write_mask; + + write_mask = shader_glsl_append_dst(ins->ctx->buffer, ins); + shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src0_param); + + shader_addline(ins->ctx->buffer, "sign(%s));\n", src0_param.param_str); +} + /** Process the WINED3DSIO_LOOP instruction in GLSL: * Start a for() loop where src1.y is the initial value of aL, * increment aL by src1.z for a total of src1.x iterations. @@ -4719,7 +4733,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_RSQ */ shader_glsl_rsq, /* WINED3DSIH_SETP */ NULL, /* WINED3DSIH_SGE */ shader_glsl_compare, - /* WINED3DSIH_SGN */ shader_glsl_map2gl, + /* WINED3DSIH_SGN */ shader_glsl_sgn, /* WINED3DSIH_SINCOS */ shader_glsl_sincos, /* WINED3DSIH_SLT */ shader_glsl_compare, /* WINED3DSIH_SUB */ shader_glsl_arith, diff --git a/dlls/wined3d/shader_sm1.c b/dlls/wined3d/shader_sm1.c index ead2769..e84132e 100644 --- a/dlls/wined3d/shader_sm1.c +++ b/dlls/wined3d/shader_sm1.c @@ -145,7 +145,8 @@ static const struct wined3d_sm1_opcode_info vs_opcode_table[] = {WINED3DSIO_FRC, 1, 2, WINED3DSIH_FRC, 0, 0 }, {WINED3DSIO_POW, 1, 3, WINED3DSIH_POW, 0, 0 }, {WINED3DSIO_CRS, 1, 3, WINED3DSIH_CRS, 0, 0 }, - {WINED3DSIO_SGN, 1, 2, WINED3DSIH_SGN, 0, 0 }, + {WINED3DSIO_SGN, 1, 4, WINED3DSIH_SGN, WINED3D_SHADER_VERSION(2,0), WINED3D_SHADER_VERSION(2,1)}, + {WINED3DSIO_SGN, 1, 2, WINED3DSIH_SGN, WINED3D_SHADER_VERSION(3,0), -1 }, {WINED3DSIO_NRM, 1, 2, WINED3DSIH_NRM, 0, 0 }, {WINED3DSIO_SINCOS, 1, 4, WINED3DSIH_SINCOS, WINED3D_SHADER_VERSION(2,0), WINED3D_SHADER_VERSION(2,1)}, {WINED3DSIO_SINCOS, 1, 2, WINED3DSIH_SINCOS, WINED3D_SHADER_VERSION(3,0), -1 },
1
0
0
0
Matteo Bruni : wpp: Handle remaining memory allocation failures in ppl. l and ppy.y.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: c571d3c1fadf1a22594af126af768b78599e39c6 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c571d3c1fadf1a22594af126a…
Author: Matteo Bruni <matteo.mystral(a)gmail.com> Date: Mon Sep 28 21:30:45 2009 +0200 wpp: Handle remaining memory allocation failures in ppl.l and ppy.y. --- libs/wpp/ppl.l | 85 ++++++++++++++++++++++++++++++++++++++++++++------------ libs/wpp/ppy.y | 8 ++++- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l index 5281e1c..062ac22 100644 --- a/libs/wpp/ppl.l +++ b/libs/wpp/ppl.l @@ -908,19 +908,26 @@ static void expand_special(pp_entry_t *ppp) { const char *dbgtext = "?"; static char *buf = NULL; + char *new_buf; assert(ppp->type == def_special); if(!strcmp(ppp->ident, "__LINE__")) { dbgtext = "def_special(__LINE__)"; - buf = pp_xrealloc(buf, 32); + new_buf = pp_xrealloc(buf, 32); + if(!new_buf) + return; + buf = new_buf; sprintf(buf, "%d", pp_status.line_number); } else if(!strcmp(ppp->ident, "__FILE__")) { dbgtext = "def_special(__FILE__)"; - buf = pp_xrealloc(buf, strlen(pp_status.input) + 3); + new_buf = pp_xrealloc(buf, strlen(pp_status.input) + 3); + if(!new_buf) + return; + buf = new_buf; sprintf(buf, "\"%s\"", pp_status.input); } else @@ -965,12 +972,19 @@ static char *curdef_text = NULL; static void add_text(const char *str, int len) { + int new_alloc; + char *new_text; + if(len == 0) return; if(curdef_idx >= curdef_alloc || curdef_alloc - curdef_idx < len) { - curdef_alloc += (len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1); - curdef_text = pp_xrealloc(curdef_text, curdef_alloc * sizeof(curdef_text[0])); + new_alloc = curdef_alloc + ((len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1)); + new_text = pp_xrealloc(curdef_text, new_alloc * sizeof(curdef_text[0])); + if(!new_text) + return; + curdef_text = new_text; + curdef_alloc = new_alloc; if(curdef_alloc > 65536) ppy_warning("Reallocating macro-expansion buffer larger than 64kB"); } @@ -1168,12 +1182,19 @@ static void new_string(void) static void add_string(const char *str, int len) { + int new_alloc; + char *new_buffer; + if(len == 0) return; if(strbuf_idx >= strbuf_alloc || strbuf_alloc - strbuf_idx < len) { - strbuf_alloc += (len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1); - strbuffer = pp_xrealloc(strbuffer, strbuf_alloc * sizeof(strbuffer[0])); + new_alloc = strbuf_alloc + ((len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1)); + new_buffer = pp_xrealloc(strbuffer, new_alloc * sizeof(strbuffer[0])); + if(!new_buffer) + return; + strbuffer = new_buffer; + strbuf_alloc = new_alloc; if(strbuf_alloc > 65536) ppy_warning("Reallocating string buffer larger than 64kB"); } @@ -1184,6 +1205,8 @@ static void add_string(const char *str, int len) static char *get_string(void) { char *str = pp_xmalloc(strbuf_idx + 1); + if(!str) + return NULL; memcpy(str, strbuffer, strbuf_idx); str[strbuf_idx] = '\0'; #ifdef DEBUG @@ -1259,14 +1282,10 @@ static bufferstackentry_t *pop_buffer(void) bufferstack[bufferstackidx].define->expanding = 0; else { - pp_status.line_number = bufferstack[bufferstackidx].line_number; - pp_status.char_number = bufferstack[bufferstackidx].char_number; - pp_status.input = bufferstack[bufferstackidx].filename; - ncontinuations = bufferstack[bufferstackidx].ncontinuations; if(!bufferstack[bufferstackidx].should_pop) { fclose(ppy_in); - fprintf(ppy_out, "# %d \"%s\" 2\n", pp_status.line_number, pp_status.input); + fprintf(ppy_out, "# %d \"%s\" 2\n", bufferstack[bufferstackidx].line_number, bufferstack[bufferstackidx].filename); /* We have EOF, check the include logic */ if(pp_incl_state.state == 2 && !pp_incl_state.seen_junk && pp_incl_state.ppp) @@ -1275,6 +1294,9 @@ static bufferstackentry_t *pop_buffer(void) if(ppp) { includelogicentry_t *iep = pp_xmalloc(sizeof(includelogicentry_t)); + if(!iep) + return NULL; + iep->ppp = ppp; ppp->iep = iep; iep->filename = bufferstack[bufferstackidx].include_filename; @@ -1284,7 +1306,7 @@ static bufferstackentry_t *pop_buffer(void) iep->next->prev = iep; pp_includelogiclist = iep; if(pp_status.debug) - fprintf(stderr, "pop_buffer: %s:%d: includelogic added, include_ppp='%s', file='%s'\n", pp_status.input, pp_status.line_number, pp_incl_state.ppp, iep->filename); + fprintf(stderr, "pop_buffer: %s:%d: includelogic added, include_ppp='%s', file='%s'\n", bufferstack[bufferstackidx].filename, bufferstack[bufferstackidx].line_number, pp_incl_state.ppp, iep->filename); } else free(bufferstack[bufferstackidx].include_filename); @@ -1293,6 +1315,10 @@ static bufferstackentry_t *pop_buffer(void) pp_incl_state = bufferstack[bufferstackidx].incl; } + pp_status.line_number = bufferstack[bufferstackidx].line_number; + pp_status.char_number = bufferstack[bufferstackidx].char_number; + pp_status.input = bufferstack[bufferstackidx].filename; + ncontinuations = bufferstack[bufferstackidx].ncontinuations; } if(ppy_debug) @@ -1335,6 +1361,8 @@ static void push_macro(pp_entry_t *ppp) } macexpstack[macexpstackidx] = pp_xmalloc(sizeof(macexpstack[0][0])); + if(!macexpstack[macexpstackidx]) + return; memset( macexpstack[macexpstackidx], 0, sizeof(macexpstack[0][0])); macexpstack[macexpstackidx]->ppp = ppp; macexpstackidx++; @@ -1372,8 +1400,13 @@ static void add_text_to_macro(const char *text, int len) if(mep->curargalloc - mep->curargsize <= len+1) /* +1 for '\0' */ { - mep->curargalloc += (ALLOCBLOCKSIZE > len+1) ? ALLOCBLOCKSIZE : len+1; - mep->curarg = pp_xrealloc(mep->curarg, mep->curargalloc * sizeof(mep->curarg[0])); + char *new_curarg; + int new_alloc = mep->curargalloc + (ALLOCBLOCKSIZE > len+1) ? ALLOCBLOCKSIZE : len+1; + new_curarg = pp_xrealloc(mep->curarg, new_alloc * sizeof(mep->curarg[0])); + if(!new_curarg) + return; + mep->curarg = new_curarg; + mep->curargalloc = new_alloc; } memcpy(mep->curarg + mep->curargsize, text, len); mep->curargsize += len; @@ -1384,14 +1417,30 @@ static void macro_add_arg(int last) { int nnl = 0; char *cptr; + char **new_args, **new_ppargs; + int *new_nnls; macexpstackentry_t *mep = top_macro(); assert(mep->ppp->expanding == 0); - mep->args = pp_xrealloc(mep->args, (mep->nargs+1) * sizeof(mep->args[0])); - mep->ppargs = pp_xrealloc(mep->ppargs, (mep->nargs+1) * sizeof(mep->ppargs[0])); - mep->nnls = pp_xrealloc(mep->nnls, (mep->nargs+1) * sizeof(mep->nnls[0])); + new_args = pp_xrealloc(mep->args, (mep->nargs+1) * sizeof(mep->args[0])); + if(!new_args) + return; + mep->args = new_args; + + new_ppargs = pp_xrealloc(mep->ppargs, (mep->nargs+1) * sizeof(mep->ppargs[0])); + if(!new_ppargs) + return; + mep->ppargs = new_ppargs; + + new_nnls = pp_xrealloc(mep->nnls, (mep->nargs+1) * sizeof(mep->nnls[0])); + if(!new_nnls) + return; + mep->nnls = new_nnls; + mep->args[mep->nargs] = pp_xstrdup(mep->curarg ? mep->curarg : ""); + if(!mep->args[mep->nargs]) + return; cptr = mep->args[mep->nargs]-1; while((cptr = strchr(cptr+1, '\n'))) { @@ -1436,7 +1485,7 @@ static void macro_add_expansion(void) pp_status.input, pp_status.line_number, mep->nargs-1, - mep->ppargs[mep->nargs-1]); + mep->ppargs[mep->nargs-1] ? mep->ppargs[mep->nargs-1] : ""); } diff --git a/libs/wpp/ppy.y b/libs/wpp/ppy.y index 505d685..ba88320 100644 --- a/libs/wpp/ppy.y +++ b/libs/wpp/ppy.y @@ -594,6 +594,8 @@ static int marg_index(char *id) static mtext_t *new_mtext(char *str, int idx, def_exp_t type) { mtext_t *mt = pp_xmalloc(sizeof(mtext_t)); + if(!mt) + return NULL; if(str == NULL) mt->subst.argidx = idx; else @@ -613,7 +615,11 @@ static mtext_t *combine_mtext(mtext_t *tail, mtext_t *mtp) if(tail->type == exp_text && mtp->type == exp_text) { - tail->subst.text = pp_xrealloc(tail->subst.text, strlen(tail->subst.text)+strlen(mtp->subst.text)+1); + char *new_text; + new_text = pp_xrealloc(tail->subst.text, strlen(tail->subst.text)+strlen(mtp->subst.text)+1); + if(!new_text) + return mtp; + tail->subst.text = new_text; strcat(tail->subst.text, mtp->subst.text); free(mtp->subst.text); free(mtp);
1
0
0
0
Matteo Bruni : wpp: Handle memory allocation failures in tokens management code.
by Alexandre Julliard
02 Oct '09
02 Oct '09
Module: wine Branch: master Commit: b7a2d2da3a0e001a4ce3dab6ca61813506cc99a8 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b7a2d2da3a0e001a4ce3dab6c…
Author: Matteo Bruni <matteo.mystral(a)gmail.com> Date: Mon Sep 28 20:48:36 2009 +0200 wpp: Handle memory allocation failures in tokens management code. --- libs/wpp/ppl.l | 2 +- libs/wpp/ppy.y | 56 ++++++++++++++++++++++++++++++++++++++++----------- libs/wpp/preproc.c | 29 ++++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 16 deletions(-) diff --git a/libs/wpp/ppl.l b/libs/wpp/ppl.l index 1c83547..5281e1c 100644 --- a/libs/wpp/ppl.l +++ b/libs/wpp/ppl.l @@ -437,7 +437,7 @@ includelogicentry_t *pp_includelogiclist = NULL; /* * Handle left side of #define */ -<pp_def>{cident}\( ppy_lval.cptr = pp_xstrdup(ppy_text); ppy_lval.cptr[ppy_leng-1] = '\0'; yy_pp_state(pp_macro); return tMACRO; +<pp_def>{cident}\( ppy_lval.cptr = pp_xstrdup(ppy_text); if(ppy_lval.cptr) ppy_lval.cptr[ppy_leng-1] = '\0'; yy_pp_state(pp_macro); return tMACRO; <pp_def>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); yy_pp_state(pp_define); return tDEFINE; <pp_def>{ws}+ ; <pp_def>\\\r?\n newline(0); diff --git a/libs/wpp/ppy.y b/libs/wpp/ppy.y index 2098ca3..505d685 100644 --- a/libs/wpp/ppy.y +++ b/libs/wpp/ppy.y @@ -295,11 +295,17 @@ preprocessor | tPRAGMA opt_text tNL { fprintf(ppy_out, "#pragma %s\n", $2 ? $2 : ""); free($2); } | tPPIDENT opt_text tNL { if(pp_status.pedantic) ppy_warning("#ident ignored (arg: '%s')", $2); free($2); } | tRCINCLUDE tRCINCLUDEPATH { - int nl=strlen($2) +3; - char *fn=pp_xmalloc(nl); - sprintf(fn,"\"%s\"",$2); - free($2); - pp_do_include(fn,1); + if($2) + { + int nl=strlen($2) +3; + char *fn=pp_xmalloc(nl); + if(fn) + { + sprintf(fn,"\"%s\"",$2); + pp_do_include(fn,1); + } + free($2); + } } | tRCINCLUDE tDQSTRING { pp_do_include($2,1); @@ -361,7 +367,7 @@ mtext : tLITERAL { $$ = new_mtext($1, 0, exp_text); } int mat = marg_index($1); if(mat >= 0) $$ = new_mtext(NULL, mat, exp_subst); - else + else if($1) $$ = new_mtext($1, 0, exp_text); } ; @@ -546,6 +552,8 @@ static int boolean(cval_t *v) static marg_t *new_marg(char *str, def_arg_t type) { marg_t *ma = pp_xmalloc(sizeof(marg_t)); + if(!ma) + return NULL; ma->arg = str; ma->type = type; ma->nnl = 0; @@ -554,16 +562,27 @@ static marg_t *new_marg(char *str, def_arg_t type) static marg_t *add_new_marg(char *str, def_arg_t type) { - marg_t *ma = new_marg(str, type); + marg_t **new_macro_args; + marg_t *ma; + if(!str) + return NULL; + new_macro_args = pp_xrealloc(macro_args, (nmacro_args+1) * sizeof(macro_args[0])); + if(!new_macro_args) + return NULL; + macro_args = new_macro_args; + ma = new_marg(str, type); + if(!ma) + return NULL; + macro_args[nmacro_args] = ma; nmacro_args++; - macro_args = pp_xrealloc(macro_args, nmacro_args * sizeof(macro_args[0])); - macro_args[nmacro_args-1] = ma; return ma; } static int marg_index(char *id) { int t; + if(!id) + return -1; for(t = 0; t < nmacro_args; t++) { if(!strcmp(id, macro_args[t]->arg)) @@ -658,9 +677,22 @@ static mtext_t *combine_mtext(mtext_t *tail, mtext_t *mtp) static char *merge_text(char *s1, char *s2) { - int l1 = strlen(s1); - int l2 = strlen(s2); - s1 = pp_xrealloc(s1, l1+l2+1); + int l1; + int l2; + char *snew; + if(!s1) + return s2; + if(!s2) + return s1; + l1 = strlen(s1); + l2 = strlen(s2); + snew = pp_xrealloc(s1, l1+l2+1); + if(!snew) + { + free(s2); + return s1; + } + s1 = snew; memcpy(s1+l1, s2, l2+1); free(s2); return s1; diff --git a/libs/wpp/preproc.c b/libs/wpp/preproc.c index c071c56..1d9aed6 100644 --- a/libs/wpp/preproc.c +++ b/libs/wpp/preproc.c @@ -126,9 +126,12 @@ static int pphash(const char *str) pp_entry_t *pplookup(const char *ident) { - int idx = pphash(ident); + int idx; pp_entry_t *ppp; + if(!ident) + return NULL; + idx = pphash(ident); for(ppp = pp_def_state->defines[idx]; ppp; ppp = ppp->next) { if(!strcmp(ident, ppp->ident)) @@ -220,9 +223,12 @@ pp_entry_t *pp_add_define(char *def, char *text) { int len; char *cptr; - int idx = pphash(def); + int idx; pp_entry_t *ppp; + if(!def) + return NULL; + idx = pphash(def); if((ppp = pplookup(def)) != NULL) { if(pp_status.pedantic) @@ -230,11 +236,18 @@ pp_entry_t *pp_add_define(char *def, char *text) pp_del_define(def); } ppp = pp_xmalloc(sizeof(pp_entry_t)); + if(!ppp) + return NULL; memset( ppp, 0, sizeof(*ppp) ); ppp->ident = def; ppp->type = def_define; ppp->subst.text = text; ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>"); + if(!ppp->filename) + { + free(ppp); + return NULL; + } ppp->linenumber = pp_status.input ? pp_status.line_number : 0; ppp->next = pp_def_state->defines[idx]; pp_def_state->defines[idx] = ppp; @@ -262,9 +275,12 @@ pp_entry_t *pp_add_define(char *def, char *text) pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp) { - int idx = pphash(id); + int idx; pp_entry_t *ppp; + if(!id) + return NULL; + idx = pphash(id); if((ppp = pplookup(id)) != NULL) { if(pp_status.pedantic) @@ -272,6 +288,8 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp) pp_del_define(id); } ppp = pp_xmalloc(sizeof(pp_entry_t)); + if(!ppp) + return NULL; memset( ppp, 0, sizeof(*ppp) ); ppp->ident = id; ppp->type = def_macro; @@ -279,6 +297,11 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp) ppp->nargs = nargs; ppp->subst.mtext= exp; ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>"); + if(!ppp->filename) + { + free(ppp); + return NULL; + } ppp->linenumber = pp_status.input ? pp_status.line_number : 0; ppp->next = pp_def_state->defines[idx]; pp_def_state->defines[idx] = ppp;
1
0
0
0
← Newer
1
...
109
110
111
112
113
114
115
...
121
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Results per page:
10
25
50
100
200