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
August 2020
----- 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
692 discussions
Start a n
N
ew thread
Piotr Caban : msvcrt: Import acos from musl.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: 8034d4179c88ae9176ecaae210c30e40084ae29c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8034d4179c88ae9176ecaae2…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 5 17:11:36 2020 +0200 msvcrt: Import acos from musl. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/math.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 46af74f09f..06480911af 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -542,18 +542,75 @@ float CDECL MSVCRT_modff( float x, float *iptr ) /********************************************************************* * MSVCRT_acos (MSVCRT.@) + * + * Copied from musl: src/math/acos.c */ +static double acos_R(double z) +{ + static const double pS0 = 1.66666666666666657415e-01, + pS1 = -3.25565818622400915405e-01, + pS2 = 2.01212532134862925881e-01, + pS3 = -4.00555345006794114027e-02, + pS4 = 7.91534994289814532176e-04, + pS5 = 3.47933107596021167570e-05, + qS1 = -2.40339491173441421878e+00, + qS2 = 2.02094576023350569471e+00, + qS3 = -6.88283971605453293030e-01, + qS4 = 7.70381505559019352791e-02; + + double p, q; + p = z * (pS0 + z * (pS1 + z * (pS2 + z * (pS3 + z * (pS4 + z * pS5))))); + q = 1.0 + z * (qS1 + z * (qS2 + z * (qS3 + z * qS4))); + return p/q; +} + double CDECL MSVCRT_acos( double x ) { - /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x). - * asin() uses a similar construction. This is bad because as x gets nearer to - * 1 the error in the expression "1 - x^2" can get relatively large due to - * cancellation. The sqrt() makes things worse. A safer way to calculate - * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */ - double ret = atan2(sqrt((1 - x) * (1 + x)), x); - if (x < -1.0 || x > 1.0 || !isfinite(x)) - return math_error(_DOMAIN, "acos", x, 0, ret); - return ret; + static const double pio2_hi = 1.57079632679489655800e+00, + pio2_lo = 6.12323399573676603587e-17; + + double z, w, s, c, df; + unsigned int hx, ix; + ULONGLONG llx; + + hx = *(ULONGLONG*)&x >> 32; + ix = hx & 0x7fffffff; + /* |x| >= 1 or nan */ + if (ix >= 0x3ff00000) { + unsigned int lx; + + lx = *(ULONGLONG*)&x; + if (((ix - 0x3ff00000) | lx) == 0) { + /* acos(1)=0, acos(-1)=pi */ + if (hx >> 31) + return 2 * pio2_hi + 7.5231638452626401e-37; + return 0; + } + if (isnan(x)) return x; + return math_error(_DOMAIN, "acos", x, 0, 0 / (x - x)); + } + /* |x| < 0.5 */ + if (ix < 0x3fe00000) { + if (ix <= 0x3c600000) /* |x| < 2**-57 */ + return pio2_hi + 7.5231638452626401e-37; + return pio2_hi - (x - (pio2_lo - x * acos_R(x * x))); + } + /* x < -0.5 */ + if (hx >> 31) { + z = (1.0 + x) * 0.5; + s = sqrt(z); + w = acos_R(z) * s - pio2_lo; + return 2 * (pio2_hi - (s + w)); + } + /* x > 0.5 */ + z = (1.0 - x) * 0.5; + s = sqrt(z); + df = s; + llx = (*(ULONGLONG*)&df >> 32) << 32; + df = *(double*)&llx; + c = (z - df * df) / (s + df); + w = acos_R(z) * s + c; + return 2 * (df + w); } /*********************************************************************
1
0
0
0
Piotr Caban : msvcrt: Import acosf from musl.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: d53d42f1ae6f2bb2e98a36a9173ad0ffd3b205fd URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d53d42f1ae6f2bb2e98a36a9…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 5 17:11:20 2020 +0200 msvcrt: Import acosf from musl. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/math.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 59b6a98487..46af74f09f 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -219,18 +219,63 @@ INT CDECL MSVCRT__isnanf( float num ) /********************************************************************* * MSVCRT_acosf (MSVCRT.@) + * + * Copied from musl: src/math/acosf.c */ +static float acosf_R(float z) +{ + static const float pS0 = 1.6666586697e-01, + pS1 = -4.2743422091e-02, + pS2 = -8.6563630030e-03, + qS1 = -7.0662963390e-01; + + float p, q; + p = z * (pS0 + z * (pS1 + z * pS2)); + q = 1.0f + z * qS1; + return p / q; +} + float CDECL MSVCRT_acosf( float x ) { - /* glibc implements acos() as the FPU equivalent of atan2(sqrt(1 - x ^ 2), x). - * asin() uses a similar construction. This is bad because as x gets nearer to - * 1 the error in the expression "1 - x^2" can get relatively large due to - * cancellation. The sqrt() makes things worse. A safer way to calculate - * acos() is to use atan2(sqrt((1 - x) * (1 + x)), x). */ - float ret = atan2f(sqrtf((1 - x) * (1 + x)), x); - if (x < -1.0 || x > 1.0 || !finitef(x)) - return math_error(_DOMAIN, "acosf", x, 0, ret); - return ret; + static const float pio2_hi = 1.5707962513e+00, + pio2_lo = 7.5497894159e-08; + + float z, w, s, c, df; + unsigned int hx, ix; + + hx = *(unsigned int*)&x; + ix = hx & 0x7fffffff; + /* |x| >= 1 or nan */ + if (ix >= 0x3f800000) { + if (ix == 0x3f800000) { + if (hx >> 31) + return 2 * pio2_hi + 7.5231638453e-37; + return 0; + } + if (MSVCRT__isnanf(x)) return x; + return math_error(_DOMAIN, "acosf", x, 0, 0 / (x - x)); + } + /* |x| < 0.5 */ + if (ix < 0x3f000000) { + if (ix <= 0x32800000) /* |x| < 2**-26 */ + return pio2_hi + 7.5231638453e-37; + return pio2_hi - (x - (pio2_lo - x * acosf_R(x * x))); + } + /* x < -0.5 */ + if (hx >> 31) { + z = (1 + x) * 0.5f; + s = sqrtf(z); + w = acosf_R(z) * s - pio2_lo; + return 2 * (pio2_hi - (s + w)); + } + /* x > 0.5 */ + z = (1 - x) * 0.5f; + s = sqrtf(z); + hx = *(unsigned int*)&s & 0xfffff000; + df = *(float*)&hx; + c = (z - df * df) / (s + df); + w = acosf_R(z) * s + c; + return 2 * (df + w); } /*********************************************************************
1
0
0
0
Gijs Vermeulen : amstream: Increase parent IAMMediaStream refcount in IDirectDrawMediaStream::CreateSample().
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: a51897566340904afdbd42b4d1f81ee278cb8cae URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a51897566340904afdbd42b4…
Author: Gijs Vermeulen <gijsvrm(a)gmail.com> Date: Wed Aug 5 16:31:27 2020 +0200 amstream: Increase parent IAMMediaStream refcount in IDirectDrawMediaStream::CreateSample(). Signed-off-by: Gijs Vermeulen <gijsvrm(a)gmail.com> Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/ddrawstream.c | 3 +++ dlls/amstream/tests/amstream.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 917fcad9c9..0d3f2d0d4b 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1048,6 +1048,8 @@ static ULONG WINAPI ddraw_sample_Release(IDirectDrawStreamSample *iface) --sample->parent->sample_refs; LeaveCriticalSection(&sample->parent->cs); + IAMMediaStream_Release(&sample->parent->IAMMediaStream_iface); + if (sample->surface) IDirectDrawSurface_Release(sample->surface); HeapFree(GetProcessHeap(), 0, sample); @@ -1163,6 +1165,7 @@ static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDraw object->IDirectDrawStreamSample_iface.lpVtbl = &DirectDrawStreamSample_Vtbl; object->ref = 1; object->parent = parent; + IAMMediaStream_AddRef(&parent->IAMMediaStream_iface); ++parent->sample_refs; if (surface) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 383ea7e936..910ab11f52 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5670,7 +5670,7 @@ static void test_ddrawstream_create_sample(void) EXPECT_REF(stream, 3); hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine EXPECT_REF(stream, 4); + EXPECT_REF(stream, 4); hr = IDirectDrawStreamSample_GetSurface(sample, NULL, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -5773,13 +5773,13 @@ static void test_ddrawstreamsample_get_media_stream(void) ok(hr == E_POINTER, "Got hr %#x.\n", hr); } - todo_wine EXPECT_REF(stream, 4); + EXPECT_REF(stream, 4); hr = IDirectDrawStreamSample_GetMediaStream(sample, &stream2); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(stream2 == stream, "Expected stream %p, got %p.\n", stream, stream2); - todo_wine EXPECT_REF(stream, 5); + EXPECT_REF(stream, 5); IMediaStream_Release(stream2); - todo_wine EXPECT_REF(stream, 4); + EXPECT_REF(stream, 4); IDirectDrawMediaStream_Release(ddraw_stream); ref = IDirectDrawStreamSample_Release(sample);
1
0
0
0
Gijs Vermeulen : amstream: Return E_INVALIDARG when a rect but no surface is passed in IDirectDrawMediaStream::CreateSample().
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: a4ddb5a1e6c0c94b344f5cf6d52b103538c378f0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a4ddb5a1e6c0c94b344f5cf6…
Author: Gijs Vermeulen <gijsvrm(a)gmail.com> Date: Wed Aug 5 16:31:26 2020 +0200 amstream: Return E_INVALIDARG when a rect but no surface is passed in IDirectDrawMediaStream::CreateSample(). Signed-off-by: Gijs Vermeulen <gijsvrm(a)gmail.com> Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/ddrawstream.c | 3 +++ dlls/amstream/tests/amstream.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 4c94bacf52..917fcad9c9 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -442,6 +442,9 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_CreateSample(IDirectDrawMedia TRACE("stream %p, surface %p, rect %s, flags %#x, sample %p.\n", stream, surface, wine_dbgstr_rect(rect), flags, sample); + if (!surface && rect) + return E_INVALIDARG; + EnterCriticalSection(&stream->cs); hr = ddrawstreamsample_create(stream, surface, rect, sample); LeaveCriticalSection(&stream->cs); diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 1310e42cf2..383ea7e936 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5665,7 +5665,7 @@ static void test_ddrawstream_create_sample(void) SetRectEmpty(&rect); hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, &rect, 0, &sample); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr); EXPECT_REF(stream, 3); hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &sample);
1
0
0
0
Gijs Vermeulen : amstream/tests: Split test_IDirectDrawStreamSample().
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: 7bdb713bc47e741d59051bd3599dc0da12f441c2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=7bdb713bc47e741d59051bd3…
Author: Gijs Vermeulen <gijsvrm(a)gmail.com> Date: Wed Aug 5 16:31:25 2020 +0200 amstream/tests: Split test_IDirectDrawStreamSample(). Signed-off-by: Gijs Vermeulen <gijsvrm(a)gmail.com> Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/tests/amstream.c | 268 +++++++++++++++++++++++++---------------- 1 file changed, 167 insertions(+), 101 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=7bdb713bc47e741d5905…
1
0
0
0
Alexandre Julliard : ntdll: Avoid importing RtlEnterCriticalSection/RtlLeaveCriticalSection from the Unix side.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: 1d3e3a1c8d08c75e88734ec00b5a2b412e8d6ca3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1d3e3a1c8d08c75e88734ec0…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed Aug 5 15:28:23 2020 +0200 ntdll: Avoid importing RtlEnterCriticalSection/RtlLeaveCriticalSection from the Unix side. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/sync.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index e7e13a6c7e..23dca9c61b 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -2522,9 +2522,20 @@ NTSTATUS CDECL fast_RtlSleepConditionVariableCS( RTL_CONDITION_VARIABLE *variabl val = *futex; - RtlLeaveCriticalSection( cs ); - status = wait_cv( futex, val, timeout ); - RtlEnterCriticalSection( cs ); + if (cs->RecursionCount == 1) + { + /* FIXME: simplified version of RtlLeaveCriticalSection/RtlEnterCriticalSection to avoid imports */ + cs->RecursionCount = 0; + cs->OwningThread = 0; + if (InterlockedDecrement( &cs->LockCount ) >= 0) fast_RtlpUnWaitCriticalSection( cs ); + + status = wait_cv( futex, val, timeout ); + + if (InterlockedIncrement( &cs->LockCount )) fast_RtlpWaitForCriticalSection( cs, INT_MAX ); + cs->OwningThread = ULongToHandle( GetCurrentThreadId() ); + cs->RecursionCount = 1; + } + else status = wait_cv( futex, val, timeout ); return status; }
1
0
0
0
Piotr Caban : msvcrt: Use correct code page in _write when outputing to console.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: 081d25d4b989c732d301b786311c034132c8d7a3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=081d25d4b989c732d301b786…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 5 15:08:06 2020 +0200 msvcrt: Use correct code page in _write when outputing to console. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/file.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index b6655e6886..a37aa87b5d 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -40,6 +40,7 @@ #include "windef.h" #include "winbase.h" +#include "wincon.h" #include "winternl.h" #include "winnls.h" #include "msvcrt.h" @@ -3446,6 +3447,7 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) ioinfo *info = get_ioinfo(fd); HANDLE hand = info->handle; DWORD num_written, i; + BOOL console; if (hand == INVALID_HANDLE_VALUE || fd == MSVCRT_NO_CONSOLE_FD) { @@ -3480,13 +3482,65 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) return num_written; } + console = MSVCRT__isatty(fd); for (i = 0; i < count;) { const char *s = buf; char lfbuf[2048]; - DWORD j; + DWORD j = 0; - if (!(info->exflag & (EF_UTF8|EF_UTF16))) + if (!(info->exflag & (EF_UTF8|EF_UTF16)) && console) + { + char conv[sizeof(lfbuf)]; + MSVCRT_size_t len = 0; + +#if _MSVCR_VER >= 90 + if (info->dbcsBufferUsed) + { + conv[j++] = info->dbcsBuffer; + info->dbcsBufferUsed = FALSE; + conv[j++] = s[i++]; + len++; + } +#endif + + for (; i < count && j < sizeof(conv)-1; i++, j++, len++) + { + if (MSVCRT_isleadbyte((unsigned char)s[i])) + { + conv[j++] = s[i++]; + + if (i == count) + { +#if _MSVCR_VER >= 90 + info->dbcsBuffer = conv[j-1]; + info->dbcsBufferUsed = TRUE; + break; +#else + *MSVCRT__errno() = MSVCRT_EINVAL; + release_ioinfo(info); + return -1; +#endif + } + } + else if (s[i] == '\n') + { + conv[j++] = '\r'; + len++; + } + conv[j] = s[i]; + } + + len = MSVCRT_mbstowcs((WCHAR*)lfbuf, conv, len); + if (len == -1) + { + msvcrt_set_errno(GetLastError()); + release_ioinfo(info); + return -1; + } + j = len * 2; + } + else if (!(info->exflag & (EF_UTF8|EF_UTF16))) { for (j = 0; i < count && j < sizeof(lfbuf)-1; i++, j++) { @@ -3495,7 +3549,7 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) lfbuf[j] = s[i]; } } - else if (info->exflag & EF_UTF16) + else if (info->exflag & EF_UTF16 || console) { for (j = 0; i < count && j < sizeof(lfbuf)-3; i++, j++) { @@ -3532,9 +3586,20 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) } } - if (!WriteFile(hand, lfbuf, j, &num_written, NULL) || num_written != j) + if (console) { - TRACE("WriteFile (fd %d, hand %p) failed-last error (%d)\n", fd, + j = j/2; + if (!WriteConsoleW(hand, lfbuf, j, &num_written, NULL)) + num_written = -1; + } + else if (!WriteFile(hand, lfbuf, j, &num_written, NULL)) + { + num_written = -1; + } + + if (num_written != j) + { + TRACE("WriteFile/WriteConsoleW (fd %d, hand %p) failed-last error (%d)\n", fd, hand, GetLastError()); msvcrt_set_errno(GetLastError()); release_ioinfo(info);
1
0
0
0
Piotr Caban : msvcrt: Avoid allocations in _write implementation.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: e0555a742f4e9527b31bd67a8dcf572046f7c4a8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e0555a742f4e9527b31bd67a…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 5 15:07:27 2020 +0200 msvcrt: Avoid allocations in _write implementation. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/file.c | 154 +++++++++++++++-------------------------------------- 1 file changed, 42 insertions(+), 112 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index e63cedede5..b6655e6886 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -3443,15 +3443,10 @@ int CDECL _wutime(const MSVCRT_wchar_t* path, struct MSVCRT___utimbuf32 *t) */ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) { - DWORD num_written; ioinfo *info = get_ioinfo(fd); HANDLE hand = info->handle; + DWORD num_written, i; - /* Don't trace small writes, it gets *very* annoying */ -#if 0 - if (count > 32) - TRACE(":fd (%d) handle (%d) buf (%p) len (%d)\n",fd,hand,buf,count); -#endif if (hand == INVALID_HANDLE_VALUE || fd == MSVCRT_NO_CONSOLE_FD) { *MSVCRT__errno() = MSVCRT_EBADF; @@ -3472,148 +3467,83 @@ int CDECL MSVCRT__write(int fd, const void* buf, unsigned int count) if (!(info->wxflag & WX_TEXT)) { - if (WriteFile(hand, buf, count, &num_written, NULL) - && (num_written == count)) + if (!WriteFile(hand, buf, count, &num_written, NULL) + || num_written != count) { - release_ioinfo(info); - return num_written; + TRACE("WriteFile (fd %d, hand %p) failed-last error (%d)\n", fd, + hand, GetLastError()); + msvcrt_set_errno(GetLastError()); + num_written = -1; } - TRACE("WriteFile (fd %d, hand %p) failed-last error (%d)\n", fd, - hand, GetLastError()); - msvcrt_set_errno(GetLastError()); + + release_ioinfo(info); + return num_written; } - else + + for (i = 0; i < count;) { - unsigned int i, j, nr_lf, size; - char *p = NULL; - const char *q; const char *s = buf; + char lfbuf[2048]; + DWORD j; if (!(info->exflag & (EF_UTF8|EF_UTF16))) { - /* find number of \n */ - for (nr_lf=0, i=0; i<count; i++) - if (s[i] == '\n') - nr_lf++; - if (nr_lf) - { - size = count+nr_lf; - if ((q = p = MSVCRT_malloc(size))) - { - for (s = buf, i = 0, j = 0; i < count; i++) - { - if (s[i] == '\n') - p[j++] = '\r'; - p[j++] = s[i]; - } - } - else - { - FIXME("Malloc failed\n"); - nr_lf = 0; - size = count; - q = buf; - } - } - else + for (j = 0; i < count && j < sizeof(lfbuf)-1; i++, j++) { - size = count; - q = buf; + if (s[i] == '\n') + lfbuf[j++] = '\r'; + lfbuf[j] = s[i]; } } else if (info->exflag & EF_UTF16) { - for (nr_lf=0, i=0; i<count; i+=2) - if (s[i]=='\n' && s[i+1]==0) - nr_lf += 2; - if (nr_lf) + for (j = 0; i < count && j < sizeof(lfbuf)-3; i++, j++) { - size = count+nr_lf; - if ((q = p = MSVCRT_malloc(size))) - { - for (s=buf, i=0, j=0; i<count; i++) - { - if (s[i]=='\n' && s[i+1]==0) - { - p[j++] = '\r'; - p[j++] = 0; - } - p[j++] = s[i++]; - p[j++] = s[i]; - } - } - else + if (s[i] == '\n' && !s[i+1]) { - FIXME("Malloc failed\n"); - nr_lf = 0; - size = count; - q = buf; + lfbuf[j++] = '\r'; + lfbuf[j++] = 0; } - } - else - { - size = count; - q = buf; + lfbuf[j++] = s[i++]; + lfbuf[j] = s[i]; } } else { - DWORD conv_len; - - for(nr_lf=0, i=0; i<count; i+=2) - if (s[i]=='\n' && s[i+1]==0) - nr_lf++; - - conv_len = WideCharToMultiByte(CP_UTF8, 0, (WCHAR*)buf, count/2, NULL, 0, NULL, NULL); - if(!conv_len) { - msvcrt_set_errno(GetLastError()); - MSVCRT_free(p); - release_ioinfo(info); - return -1; - } + char conv[sizeof(lfbuf)/4]; - size = conv_len+nr_lf; - if((p = MSVCRT_malloc(count+nr_lf*2+size))) + for (j = 0; i < count && j < sizeof(conv)-3; i++, j++) { - for (s=buf, i=0, j=0; i<count; i++) + if (s[i] == '\n' && !s[i+1]) { - if (s[i]=='\n' && s[i+1]==0) - { - p[j++] = '\r'; - p[j++] = 0; - } - p[j++] = s[i++]; - p[j++] = s[i]; + conv[j++] = '\r'; + conv[j++] = 0; } - q = p+count+nr_lf*2; - WideCharToMultiByte(CP_UTF8, 0, (WCHAR*)p, count/2+nr_lf, - p+count+nr_lf*2, conv_len+nr_lf, NULL, NULL); + conv[j++] = s[i++]; + conv[j] = s[i]; } - else + + j = WideCharToMultiByte(CP_UTF8, 0, (WCHAR*)conv, j/2, lfbuf, sizeof(lfbuf), NULL, NULL); + if (!j) { - FIXME("Malloc failed\n"); - nr_lf = 0; - size = count; - q = buf; + msvcrt_set_errno(GetLastError()); + release_ioinfo(info); + return -1; } } - if (!WriteFile(hand, q, size, &num_written, NULL)) - num_written = -1; - release_ioinfo(info); - MSVCRT_free(p); - if (num_written != size) + if (!WriteFile(hand, lfbuf, j, &num_written, NULL) || num_written != j) { - TRACE("WriteFile (fd %d, hand %p) failed-last error (%d), num_written %d\n", - fd, hand, GetLastError(), num_written); + TRACE("WriteFile (fd %d, hand %p) failed-last error (%d)\n", fd, + hand, GetLastError()); msvcrt_set_errno(GetLastError()); + release_ioinfo(info); return -1; } - return count; } release_ioinfo(info); - return -1; + return count; } /*********************************************************************
1
0
0
0
Piotr Caban : msvcrt: Return error on invalid character in mbstowcs.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: 5983fcfec932d44f601ad3a520e1996f0fdf5d0f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5983fcfec932d44f601ad3a5…
Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 5 15:07:18 2020 +0200 msvcrt: Return error on invalid character in mbstowcs. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcrt/mbcs.c | 15 +++++++++++---- dlls/msvcrt/tests/string.c | 5 +++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index a065b8b003..dc52cf1b8c 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -2472,8 +2472,15 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr, } /* Ignore count parameter */ - if(!wcstr) - return MultiByteToWideChar(locinfo->lc_codepage, 0, mbstr, -1, NULL, 0)-1; + if(!wcstr) { + size = MultiByteToWideChar(locinfo->lc_codepage, + MB_ERR_INVALID_CHARS, mbstr, -1, NULL, 0); + if(!size) { + *MSVCRT__errno() = MSVCRT_EILSEQ; + return -1; + } + return size - 1; + } for(i=0, size=0; i<count; i++) { if(mbstr[size] == '\0') @@ -2483,8 +2490,8 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr, } if(size) { - size = MultiByteToWideChar(locinfo->lc_codepage, 0, - mbstr, size, wcstr, count); + size = MultiByteToWideChar(locinfo->lc_codepage, + MB_ERR_INVALID_CHARS, mbstr, size, wcstr, count); if(!size) { if(count) wcstr[0] = '\0'; *MSVCRT__errno() = MSVCRT_EILSEQ; diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 3970f703f6..a4b1fb9d11 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -2107,6 +2107,11 @@ static void test_mbstowcs(void) ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret); ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut)); + errno = 0xdeadbeef; + ret = mbstowcs(wOut, mHiragana+1, 5); + ok(ret == -1, "mbstowcs did not return -1\n"); + ok(errno == EILSEQ, "errno = %d\n", errno); + ret = wcstombs(mOut, wHiragana, 6); ok(ret == 4, "wcstombs did not return 4\n"); ok(!memcmp(mOut, mHiragana, sizeof(mHiragana)), "mOut = %s\n", mOut);
1
0
0
0
Alistair Leslie-Hughes : xactengine3_7: Use CLSID defined from global header.
by Alexandre Julliard
05 Aug '20
05 Aug '20
Module: wine Branch: master Commit: 93bf951e1c1e2df700ce60f24db95a1436821357 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=93bf951e1c1e2df700ce60f2…
Author: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> Date: Wed Aug 5 14:38:38 2020 +1000 xactengine3_7: Use CLSID defined from global header. Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/xactengine3_7/Makefile.in | 1 + dlls/xactengine3_7/xact_dll.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/xactengine3_7/Makefile.in b/dlls/xactengine3_7/Makefile.in index 6fce27d162..6d48617162 100644 --- a/dlls/xactengine3_7/Makefile.in +++ b/dlls/xactengine3_7/Makefile.in @@ -1,5 +1,6 @@ MODULE = xactengine3_7.dll IMPORTS = ole32 uuid +EXTRADEFS = -DXACT3_VER=0x0307 EXTRALIBS = $(FAUDIO_LIBS) EXTRAINCL = $(FAUDIO_CFLAGS) diff --git a/dlls/xactengine3_7/xact_dll.c b/dlls/xactengine3_7/xact_dll.c index 7e1add41fe..52bf9e5210 100644 --- a/dlls/xactengine3_7/xact_dll.c +++ b/dlls/xactengine3_7/xact_dll.c @@ -27,7 +27,6 @@ #include "initguid.h" #include "xact3.h" #include "rpcproxy.h" -#include "xact_classes.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(xact3); @@ -823,7 +822,7 @@ HRESULT WINAPI DllCanUnloadNow(void) HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv) { - if (IsEqualGUID(rclsid, &CLSID_XACTEngine37)) + if (IsEqualGUID(rclsid, &CLSID_XACTEngine)) { TRACE("(%s, %s, %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); return IClassFactory_QueryInterface(&XACTFactory, riid, ppv);
1
0
0
0
← Newer
1
...
57
58
59
60
61
62
63
...
70
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
Results per page:
10
25
50
100
200