ReactOS.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
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
List overview
Download
Ros-diffs
February 2023
----- 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
ros-diffs@reactos.org
16 participants
97 discussions
Start a n
N
ew thread
[reactos] 08/12: [WINESYNC] msvcrt: Add helper for exception throwing.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8fdc1b0d38dbda447e5cc…
commit 8fdc1b0d38dbda447e5ccabe0dfbfa5e73937e80 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Mon Mar 27 11:26:54 2017 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] msvcrt: Add helper for exception throwing. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 90307e067f985f5963b62829993b320537578333 by Piotr Caban <piotr(a)codeweavers.com> --- sdk/lib/crt/wine/heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index b773e00ddea..a1c86c5f2db 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -175,7 +175,7 @@ void* CDECL MSVCRT_operator_new(MSVCRT_size_t size) TRACE("(%ld) out of memory\n", size); #if _MSVCR_VER >= 80 - throw_bad_alloc("bad allocation"); + throw_exception(EXCEPTION_BAD_ALLOC, 0, "bad allocation"); #endif return NULL; }
1 year, 10 months
1
0
0
0
[reactos] 07/12: [WINESYNC] ucrtbase: Implement _realloc_base.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6360937cd4248bef7a3b2…
commit 6360937cd4248bef7a3b2eb8df0ca67b9a772079 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Jun 17 03:02:26 2016 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] ucrtbase: Implement _realloc_base. Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 8a69c5d81f8deb472df18a8e16e57efef2eb9a9a by Alex Henrie <alexhenrie24(a)gmail.com> --- sdk/lib/crt/wine/heap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index ae5e8fa31ee..b773e00ddea 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -483,6 +483,14 @@ void* CDECL MSVCRT_realloc(void* ptr, MSVCRT_size_t size) return NULL; } +/********************************************************************* + * _realloc_base (UCRTBASE.@) + */ +void* CDECL _realloc_base(void* ptr, MSVCRT_size_t size) +{ + return MSVCRT_realloc(ptr, size); +} + /********************************************************************* * _recalloc (MSVCR100.@) */
1 year, 10 months
1
0
0
0
[reactos] 06/12: [WINESYNC] ucrtbase: Implement _free_base.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aa77776eb0f88c08f772f…
commit aa77776eb0f88c08f772f585868ad4da241a524c Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Jun 17 03:02:25 2016 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] ucrtbase: Implement _free_base. Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id e4b8bc0edc640b36f2a2a26c53e18edea04fa74c by Alex Henrie <alexhenrie24(a)gmail.com> --- sdk/lib/crt/wine/heap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 88db61657c4..ae5e8fa31ee 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -445,6 +445,14 @@ void CDECL MSVCRT_free(void* ptr) msvcrt_heap_free(ptr); } +/********************************************************************* + * _free_base (UCRTBASE.@) + */ +void CDECL _free_base(void* ptr) +{ + msvcrt_heap_free(ptr); +} + /********************************************************************* * malloc (MSVCRT.@) */
1 year, 10 months
1
0
0
0
[reactos] 05/12: [WINESYNC] ucrtbase: Implement _malloc_base.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7757ebfbad26c9bd5200f…
commit 7757ebfbad26c9bd5200fa734b2b65de4df4b5ec Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Jun 17 03:02:24 2016 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] ucrtbase: Implement _malloc_base. Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 5325b8c95112be75f4fa0e2e2e45bcc88434fb5d by Alex Henrie <alexhenrie24(a)gmail.com> --- sdk/lib/crt/wine/heap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 66fcf5b4b82..88db61657c4 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -456,6 +456,14 @@ void* CDECL MSVCRT_malloc(MSVCRT_size_t size) return ret; } +/********************************************************************* + * _malloc_base (UCRTBASE.@) + */ +void* CDECL _malloc_base(MSVCRT_size_t size) +{ + return MSVCRT_malloc(size); +} + /********************************************************************* * realloc (MSVCRT.@) */
1 year, 10 months
1
0
0
0
[reactos] 04/12: [WINESYNC] ucrtbase: Implement _calloc_base.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0dfd5665c0f3dda38d417…
commit 0dfd5665c0f3dda38d417920609bf276e77d26d2 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Fri Jun 17 03:02:23 2016 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] ucrtbase: Implement _calloc_base. Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id fdc57d497bb305e90680c3b450fa172042fd79cd by Alex Henrie <alexhenrie24(a)gmail.com> --- sdk/lib/crt/wine/heap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 1b7eb529f31..66fcf5b4b82 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -429,6 +429,14 @@ void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size) return msvcrt_heap_alloc(HEAP_ZERO_MEMORY, bytes); } +/********************************************************************* + * _calloc_base (UCRTBASE.@) + */ +void* CDECL _calloc_base(MSVCRT_size_t count, MSVCRT_size_t size) +{ + return MSVCRT_calloc(count, size); +} + /********************************************************************* * free (MSVCRT.@) */
1 year, 10 months
1
0
0
0
[reactos] 03/12: [WINESYNC] msvcrt: Handle overflow in calloc().
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1d6ec8555d98976f6492a…
commit 1d6ec8555d98976f6492ad07a4ca304f1b404372 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Wed Apr 27 11:11:49 2016 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] msvcrt: Handle overflow in calloc(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 50dd4b892825c75db35cd1f378291b51fa782f3e by Nikolay Sivov <nsivov(a)codeweavers.com> --- sdk/lib/crt/wine/heap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 5cf7d6bd4ee..1b7eb529f31 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -418,7 +418,15 @@ size_t CDECL _aligned_msize(void *p, MSVCRT_size_t alignment, MSVCRT_size_t offs */ void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size) { - return msvcrt_heap_alloc(HEAP_ZERO_MEMORY, count*size); + MSVCRT_size_t bytes = count*size; + + if (size && bytes / size != count) + { + *MSVCRT__errno() = MSVCRT_ENOMEM; + return NULL; + } + + return msvcrt_heap_alloc(HEAP_ZERO_MEMORY, bytes); } /*********************************************************************
1 year, 10 months
1
0
0
0
[reactos] 02/12: [WINESYNC] msvcrt: memmove_s shouldn't zero its output buffer on error.
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=977e236102b4be50d473c…
commit 977e236102b4be50d473c397fa6aeca12fc2a166 Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Sat Jul 28 19:43:43 2012 +0300 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [WINESYNC] msvcrt: memmove_s shouldn't zero its output buffer on error. wine commit id 49560458426cf25b6a36bbf9bad35aa75c9f7aa7 by Dan Kegel <dank(a)kegel.com> --- sdk/lib/crt/wine/heap.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c index 8fc3f6c37f1..5cf7d6bd4ee 100644 --- a/sdk/lib/crt/wine/heap.c +++ b/sdk/lib/crt/wine/heap.c @@ -715,20 +715,9 @@ int CDECL MSVCRT_memmove_s(void *dest, MSVCRT_size_t numberOfElements, const voi if(!count) return 0; - if(!dest || !src) { - if(dest) - memset(dest, 0, numberOfElements); - - *_errno() = EINVAL; - return EINVAL; - } - - if(count > numberOfElements) { - memset(dest, 0, numberOfElements); - - *_errno() = ERANGE; - return ERANGE; - } + if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL; + if (!MSVCRT_CHECK_PMT_ERR( count <= numberOfElements, MSVCRT_ERANGE )) return MSVCRT_ERANGE; memmove(dest, src, count); return 0;
1 year, 10 months
1
0
0
0
[reactos] 01/12: [CRT] Reduce diff to wine by adjusting white space
by Timo Kreuzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8fa0886fb9e2851a30467…
commit 8fa0886fb9e2851a30467ee5efc5b2538ae7625e Author: Timo Kreuzer <timo.kreuzer(a)reactos.org> AuthorDate: Thu Jan 26 21:24:53 2023 +0200 Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org> CommitDate: Thu Feb 2 14:58:08 2023 +0100 [CRT] Reduce diff to wine by adjusting white space --- sdk/lib/crt/wine/except_i386.c | 42 ++++++++++++++++++------------------ sdk/lib/crt/wine/msvcrt.h | 2 +- sdk/lib/crt/wine/undname.c | 48 +++++++++++++++++++++--------------------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/sdk/lib/crt/wine/except_i386.c b/sdk/lib/crt/wine/except_i386.c index acb8223075c..746ddad77da 100644 --- a/sdk/lib/crt/wine/except_i386.c +++ b/sdk/lib/crt/wine/except_i386.c @@ -651,8 +651,8 @@ DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame /********************************************************************* * __CxxFrameHandler (MSVCRT.@) */ -extern DWORD CDECL __CxxFrameHandler(PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, - PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch); +extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, + PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch ); #ifdef _MSC_VER DWORD _declspec(naked) __CxxFrameHandler(PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch) @@ -672,25 +672,25 @@ DWORD _declspec(naked) __CxxFrameHandler(PEXCEPTION_RECORD rec, EXCEPTION_REGIST } } #else -__ASM_GLOBAL_FUNC(__CxxFrameHandler, - "pushl $0\n\t" /* nested_trylevel */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl $0\n\t" /* nested_frame */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl %eax\n\t" /* descr */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl 28(%esp)\n\t" /* dispatch */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl 28(%esp)\n\t" /* context */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl 28(%esp)\n\t" /* frame */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "pushl 28(%esp)\n\t" /* rec */ - __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") - "call " __ASM_NAME("cxx_frame_handler") "\n\t" - "add $28,%esp\n\t" - __ASM_CFI(".cfi_adjust_cfa_offset -28\n\t") - "ret") +__ASM_GLOBAL_FUNC( __CxxFrameHandler, + "pushl $0\n\t" /* nested_trylevel */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl $0\n\t" /* nested_frame */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl %eax\n\t" /* descr */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl 28(%esp)\n\t" /* dispatch */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl 28(%esp)\n\t" /* context */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl 28(%esp)\n\t" /* frame */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "pushl 28(%esp)\n\t" /* rec */ + __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") + "call " __ASM_NAME("cxx_frame_handler") "\n\t" + "add $28,%esp\n\t" + __ASM_CFI(".cfi_adjust_cfa_offset -28\n\t") + "ret" ) #endif diff --git a/sdk/lib/crt/wine/msvcrt.h b/sdk/lib/crt/wine/msvcrt.h index 7c71550acdf..d5dc4cd5366 100644 --- a/sdk/lib/crt/wine/msvcrt.h +++ b/sdk/lib/crt/wine/msvcrt.h @@ -26,7 +26,7 @@ * Other conventions * - To avoid conflicts with the standard C library, * no msvcrt headers are included in the implementation. - * - Instead, symbols are duplicated here, prefixed with + * - Instead, symbols are duplicated here, prefixed with * MSVCRT_, as explained above. * - To avoid inconsistencies, a test for each symbol is * added into tests/headers.c. Please always add a diff --git a/sdk/lib/crt/wine/undname.c b/sdk/lib/crt/wine/undname.c index 899a419d1af..c81dfcc273a 100644 --- a/sdk/lib/crt/wine/undname.c +++ b/sdk/lib/crt/wine/undname.c @@ -34,7 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); */ /* How data types modifiers are stored: - * M (in the following definitions) is defined for + * M (in the following definitions) is defined for * 'A', 'B', 'C' and 'D' as follows * {<A>}: "" * {<B>}: "const " @@ -48,7 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); * in data fields: * same as for arguments and also the following * ?<M>x {<M>}x - * + * */ struct array @@ -110,7 +110,7 @@ static void* und_alloc(struct parsed_symbol* sym, unsigned int len) sym->avail_in_first = 0; ptr = (char*)sym->alloc_list + sizeof(void*); } - else + else { if (len > sym->avail_in_first) { @@ -188,7 +188,7 @@ static BOOL str_array_push(struct parsed_symbol* sym, const char* ptr, int len, a->elts[a->num] = und_alloc(sym, len + 1); assert(a->elts[a->num]); memcpy(a->elts[a->num], ptr, len); - a->elts[a->num][len] = '\0'; + a->elts[a->num][len] = '\0'; if (++a->num >= a->max) a->max = a->num; { int i; @@ -217,18 +217,18 @@ static char* str_array_get_ref(struct array* cref, unsigned idx) assert(cref); if (cref->start + idx >= cref->max) { - WARN("Out of bounds: %p %d + %d >= %d\n", + WARN("Out of bounds: %p %d + %d >= %d\n", cref, cref->start, idx, cref->max); return NULL; } - TRACE("Returning %p[%d] => %s\n", + TRACE("Returning %p[%d] => %s\n", cref, idx, debugstr_a(cref->elts[cref->start + idx])); return cref->elts[cref->start + idx]; } /****************************************************************** * str_printf - * Helper for printf type of command (only %s and %c are implemented) + * Helper for printf type of command (only %s and %c are implemented) * while dynamically allocating the buffer */ static char* str_printf(struct parsed_symbol* sym, const char* format, ...) @@ -341,7 +341,7 @@ static const char* get_number(struct parsed_symbol* sym) * Parses a list of function/method arguments, creates a string corresponding * to the arguments' list. */ -static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_term, +static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_term, char open_char, char close_char) { @@ -376,8 +376,8 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t */ if (z_term && *sym->current++ != 'Z') return NULL; - if (arg_collect.num == 0 || - (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void"))) + if (arg_collect.num == 0 || + (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void"))) return str_printf(sym, "%cvoid%c", open_char, close_char); for (i = 1; i < arg_collect.num; i++) { @@ -386,12 +386,12 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t last = args_str ? args_str : arg_collect.elts[0]; if (close_char == '>' && last[strlen(last) - 1] == '>') - args_str = str_printf(sym, "%c%s%s %c", + args_str = str_printf(sym, "%c%s%s %c", open_char, arg_collect.elts[0], args_str, close_char); else - args_str = str_printf(sym, "%c%s%s%c", + args_str = str_printf(sym, "%c%s%s%c", open_char, arg_collect.elts[0], args_str, close_char); - + return args_str; } @@ -730,7 +730,7 @@ static BOOL get_calling_convention(char ch, const char** call_conv, static const char* get_simple_type(char c) { const char* type_string; - + switch (c) { case 'C': type_string = "signed char"; break; @@ -759,7 +759,7 @@ static const char* get_simple_type(char c) static const char* get_extended_type(char c) { const char* type_string; - + switch (c) { case 'D': type_string = "__int8"; break; @@ -794,7 +794,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, assert(ct); ct->left = ct->right = NULL; - + switch (dt = *sym->current++) { case '_': @@ -819,7 +819,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, if (!(struct_name = get_class_name(sym))) goto done; - if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE)) + if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE)) { switch (dt) { @@ -908,7 +908,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, sym->current++; if (!get_calling_convention(*sym->current++, - &call_conv, &exported, + &call_conv, &exported, sym->flags & ~UNDNAME_NO_ALLOCATION_LANGUAGE) || !demangle_datatype(sym, &sub_ct, pmt_ref, FALSE)) goto done; @@ -917,7 +917,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, if (!args) goto done; sym->stack.num = mark; - ct->left = str_printf(sym, "%s%s (%s*", + ct->left = str_printf(sym, "%s%s (%s*", sub_ct.left, sub_ct.right, call_conv); ct->right = str_printf(sym, ")%s", args); } @@ -1044,7 +1044,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct, return FALSE; } done: - + return ct->left != NULL; } @@ -1081,7 +1081,7 @@ static BOOL handle_data(struct parsed_symbol* sym) case '0': access = "private: "; break; case '1': access = "protected: "; break; case '2': access = "public: "; break; - } + } } if (!(sym->flags & UNDNAME_NO_MEMBER_TYPE)) @@ -1131,8 +1131,8 @@ static BOOL handle_data(struct parsed_symbol* sym) if (sym->flags & UNDNAME_NAME_ONLY) ct.left = ct.right = modifier = NULL; sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s", access, - member_type, ct.left, - modifier && ct.left ? " " : NULL, modifier, + member_type, ct.left, + modifier && ct.left ? " " : NULL, modifier, modifier || ct.left ? " " : NULL, name, ct.right); ret = TRUE; done: @@ -1604,7 +1604,7 @@ char* CDECL __unDNameEx(char* buffer, const char* mangled, int buflen, TRACE("(%p,%s,%d,%p,%p,%p,%x)\n", buffer, debugstr_a(mangled), buflen, memget, memfree, unknown, flags); - + /* The flags details is not documented by MS. However, it looks exactly * like the UNDNAME_ manifest constants from imagehlp.h and dbghelp.h * So, we copied those (on top of the file)
1 year, 10 months
1
0
0
0
[reactos] 01/01: [ACPI_APITEST] Mark test failures as todos.
by Thomas Faber
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5999c6b66c4779bc71db…
commit d5999c6b66c4779bc71db51df4189e2a465b0ee5 Author: Thomas Faber <thomas.faber(a)reactos.org> AuthorDate: Wed Feb 1 20:17:28 2023 -0500 Commit: Thomas Faber <thomas.faber(a)reactos.org> CommitDate: Wed Feb 1 20:20:17 2023 -0500 [ACPI_APITEST] Mark test failures as todos. This is a true unit test and runs the same code on Windows as it does on ROS, so this uses unconditional todos rather than todo_ros. This avoids test failures on Windows and hopefully makes things less confusing. --- modules/rostests/apitests/acpi/Bus_PDO_QueryResourceRequirements.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/rostests/apitests/acpi/Bus_PDO_QueryResourceRequirements.c b/modules/rostests/apitests/acpi/Bus_PDO_QueryResourceRequirements.c index 08a7a13dd4c..695e6f0d42a 100644 --- a/modules/rostests/apitests/acpi/Bus_PDO_QueryResourceRequirements.c +++ b/modules/rostests/apitests/acpi/Bus_PDO_QueryResourceRequirements.c @@ -2,7 +2,7 @@ * PROJECT: ReactOS API Tests * LICENSE: LGPL-2.1-or-later (
https://spdx.org/licenses/LGPL-2.1-or-later
) * PURPOSE: Unit Tests for acpi!Bus_PDO_QueryResourceRequirements - * COPYRIGHT: Copyright 2017-2020 Thomas Faber (thomas.faber(a)reactos.org) + * COPYRIGHT: Copyright 2017-2023 Thomas Faber (thomas.faber(a)reactos.org) */ #include <apitest.h> @@ -501,6 +501,7 @@ START_TEST(Bus_PDO_QueryResourceRequirements) ok(ReqList->InterfaceType == Internal, "InterfaceType = %u\n", ReqList->InterfaceType); ok(ReqList->BusNumber == 0, "BusNumber = %lu\n", ReqList->BusNumber); ok(ReqList->SlotNumber == 0, "SlotNumber = %lu\n", ReqList->SlotNumber); + todo_if(1) ok(ReqList->AlternativeLists == 2, "AlternativeLists = %lu\n", ReqList->AlternativeLists); ok(ReqList->List[0].Version == 1, "List[0].Version = %u\n", ReqList->List[0].Version); ok(ReqList->List[0].Revision == 1, "List[0].Revision = %u\n", ReqList->List[0].Revision); @@ -525,6 +526,7 @@ START_TEST(Bus_PDO_QueryResourceRequirements) expect_irq(&ReqList2->Descriptors[5], IO_RESOURCE_ALTERNATIVE, CmResourceShareDeviceExclusive, 7, 7); } ok_int(ReqList->ListSize, GetPoolAllocSize(ReqList)); + todo_if(1) ok_int(ReqList->ListSize, (ULONG_PTR)&ReqList2->Descriptors[6] - (ULONG_PTR)ReqList); ExFreePoolWithTag(ReqList, 'RpcA'); }
1 year, 10 months
1
0
0
0
[reactos] 01/01: [NOTEPAD] Speed up notepad loading (#5012)
by Katayama Hirofumi MZ
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0a851eadcb790e4a52bac…
commit 0a851eadcb790e4a52bac1e05153d0913e63e896 Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> AuthorDate: Thu Feb 2 10:10:30 2023 +0900 Commit: GitHub <noreply(a)github.com> CommitDate: Thu Feb 2 10:10:30 2023 +0900 [NOTEPAD] Speed up notepad loading (#5012) - Use EM_GETHANDLE/EM_SETHANDLE message to get/set the internal buffer handle. - Use LocalReAlloc to re-allocate the buffer. - Use file mapping to speed up loading. - Use also IS_TEXT_UNICODE_REVERSE_STATISTICS for IsTextUnicode. CORE-14641 --- base/applications/notepad/dialog.c | 21 +-- base/applications/notepad/main.h | 15 +- base/applications/notepad/text.c | 326 ++++++++++++++++++++----------------- 3 files changed, 192 insertions(+), 170 deletions(-) diff --git a/base/applications/notepad/dialog.c b/base/applications/notepad/dialog.c index 6e45d05798e..06618147121 100644 --- a/base/applications/notepad/dialog.c +++ b/base/applications/notepad/dialog.c @@ -419,11 +419,9 @@ BOOL DoCloseFile(VOID) VOID DoOpenFile(LPCTSTR szFileName) { - static const TCHAR dotlog[] = _T(".LOG"); HANDLE hFile; - LPTSTR pszText = NULL; - DWORD dwTextLen; TCHAR log[5]; + HLOCAL hLocal; /* Close any files and prompt to save changes */ if (!DoCloseFile()) @@ -437,21 +435,22 @@ VOID DoOpenFile(LPCTSTR szFileName) goto done; } - if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, &Globals.encFile, &Globals.iEoln)) + /* To make loading file quicker, we use the internal handle of EDIT control */ + hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0); + if (!ReadText(hFile, &hLocal, &Globals.encFile, &Globals.iEoln)) { ShowLastError(); goto done; } - SetWindowText(Globals.hEdit, pszText); + SendMessageW(Globals.hEdit, EM_SETHANDLE, (WPARAM)hLocal, 0); + /* No need of EM_SETMODIFY and EM_EMPTYUNDOBUFFER here. EM_SETHANDLE does instead. */ - SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0); - SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0); SetFocus(Globals.hEdit); /* If the file starts with .LOG, add a time/date at the end and set cursor after - * See
http://support.microsoft.com/?kbid=260563
+ * See
http://web.archive.org/web/20090627165105/http://support.microsoft.com/kb/2…
*/ - if (GetWindowText(Globals.hEdit, log, ARRAY_SIZE(log)) && !_tcscmp(log, dotlog)) + if (GetWindowText(Globals.hEdit, log, ARRAY_SIZE(log)) && !_tcscmp(log, _T(".LOG"))) { static const TCHAR lf[] = _T("\r\n"); SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1); @@ -471,8 +470,6 @@ VOID DoOpenFile(LPCTSTR szFileName) done: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); - if (pszText) - HeapFree(GetProcessHeap(), 0, pszText); } VOID DIALOG_FileNew(VOID) @@ -590,7 +587,7 @@ DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) hCombo = GetDlgItem(hDlg, ID_EOLN); if (hCombo) - Globals.iEoln = (int) SendMessage(hCombo, CB_GETCURSEL, 0, 0); + Globals.iEoln = (EOLN)SendMessage(hCombo, CB_GETCURSEL, 0, 0); } break; } diff --git a/base/applications/notepad/main.h b/base/applications/notepad/main.h index ce7fc850877..e2140c2b52b 100644 --- a/base/applications/notepad/main.h +++ b/base/applications/notepad/main.h @@ -47,9 +47,12 @@ typedef enum // #define MIN_ENCODING 0 // #define MAX_ENCODING 3 -#define EOLN_CRLF 0 -#define EOLN_LF 1 -#define EOLN_CR 2 +typedef enum +{ + EOLN_CRLF = 0, /* "\r\n" */ + EOLN_LF = 1, /* "\n" */ + EOLN_CR = 2 /* "\r" */ +} EOLN; /* End of line (NewLine) type */ typedef struct { @@ -76,7 +79,7 @@ typedef struct TCHAR szStatusBarLineCol[MAX_PATH]; ENCODING encFile; - int iEoln; + EOLN iEoln; FINDREPLACE find; WNDPROC EditProc; @@ -89,8 +92,8 @@ extern NOTEPAD_GLOBALS Globals; VOID SetFileName(LPCTSTR szFileName); /* from text.c */ -BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int *piEoln); -BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int iEoln); +BOOL ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln); +BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln); /* from settings.c */ void NOTEPAD_LoadSettingsFromRegistry(void); diff --git a/base/applications/notepad/text.c b/base/applications/notepad/text.c index 6a83a89d64f..3ce3a889bfe 100644 --- a/base/applications/notepad/text.c +++ b/base/applications/notepad/text.c @@ -4,7 +4,7 @@ * Copyright 1998,99 Marcel Baur <mbaur(a)g26.ethz.ch> * Copyright 2002 Sylvain Petreolle <spetreolle(a)yahoo.fr> * Copyright 2002 Andriy Palamarchuk - * Copyright 2019 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> + * Copyright 2019-2023 Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,31 +22,7 @@ */ #include "notepad.h" - -static BOOL Append(LPWSTR *ppszText, DWORD *pdwTextLen, LPCWSTR pszAppendText, DWORD dwAppendLen) -{ - LPWSTR pszNewText; - - if (dwAppendLen > 0) - { - if (*ppszText) - { - pszNewText = (LPWSTR) HeapReAlloc(GetProcessHeap(), 0, *ppszText, (*pdwTextLen + dwAppendLen) * sizeof(WCHAR)); - } - else - { - pszNewText = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, dwAppendLen * sizeof(WCHAR)); - } - - if (!pszNewText) - return FALSE; - - memcpy(pszNewText + *pdwTextLen, pszAppendText, dwAppendLen * sizeof(WCHAR)); - *ppszText = pszNewText; - *pdwTextLen += dwAppendLen; - } - return TRUE; -} +#include <assert.h> BOOL IsTextNonZeroASCII(const void *pText, DWORD dwSize) { @@ -63,71 +39,156 @@ BOOL IsTextNonZeroASCII(const void *pText, DWORD dwSize) ENCODING AnalyzeEncoding(const char *pBytes, DWORD dwSize) { - INT flags = IS_TEXT_UNICODE_STATISTICS; + INT flags = IS_TEXT_UNICODE_STATISTICS | IS_TEXT_UNICODE_REVERSE_STATISTICS; - if (dwSize <= 1) + if (dwSize <= 1 || IsTextNonZeroASCII(pBytes, dwSize)) return ENCODING_ANSI; - if (IsTextNonZeroASCII(pBytes, dwSize)) - { - return ENCODING_ANSI; - } - if (IsTextUnicode(pBytes, dwSize, &flags)) - { return ENCODING_UTF16LE; - } if ((flags & IS_TEXT_UNICODE_REVERSE_MASK) && !(flags & IS_TEXT_UNICODE_ILLEGAL_CHARS)) - { return ENCODING_UTF16BE; - } /* is it UTF-8? */ if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, pBytes, dwSize, NULL, 0)) - { return ENCODING_UTF8; - } return ENCODING_ANSI; } +static VOID +ReplaceNewLines(LPWSTR pszNew, SIZE_T cchNew, LPCWSTR pszOld, SIZE_T cchOld) +{ + BOOL bPrevCR = FALSE; + SIZE_T ichNew, ichOld; + + for (ichOld = ichNew = 0; ichOld < cchOld; ++ichOld) + { + WCHAR ch = pszOld[ichOld]; + + if (ch == L'\n') + { + if (!bPrevCR) + { + pszNew[ichNew++] = L'\r'; + pszNew[ichNew++] = L'\n'; + } + } + else if (ch == '\r') + { + pszNew[ichNew++] = L'\r'; + pszNew[ichNew++] = L'\n'; + } + else + { + pszNew[ichNew++] = ch; + } + + bPrevCR = (ch == L'\r'); + } + + pszNew[ichNew] = UNICODE_NULL; + assert(ichNew == cchNew); +} + +static BOOL +ProcessNewLinesAndNulls(HLOCAL *phLocal, LPWSTR *ppszText, SIZE_T *pcchText, EOLN *piEoln) +{ + SIZE_T ich, cchText = *pcchText, adwEolnCount[3] = { 0, 0, 0 }, cNonCRLFs; + LPWSTR pszText = *ppszText; + EOLN iEoln; + BOOL bPrevCR = FALSE; + + /* Replace '\0' with SPACE. Count newlines. */ + for (ich = 0; ich < cchText; ++ich) + { + WCHAR ch = pszText[ich]; + if (ch == UNICODE_NULL) + pszText[ich] = L' '; + + if (ch == L'\n') + { + if (bPrevCR) + { + adwEolnCount[EOLN_CR]--; + adwEolnCount[EOLN_CRLF]++; + } + else + { + adwEolnCount[EOLN_LF]++; + } + } + else if (ch == '\r') + { + adwEolnCount[EOLN_CR]++; + } + + bPrevCR = (ch == L'\r'); + } + + /* Choose the newline code */ + if (adwEolnCount[EOLN_CR] > adwEolnCount[EOLN_CRLF]) + iEoln = EOLN_CR; + else if (adwEolnCount[EOLN_LF] > adwEolnCount[EOLN_CRLF]) + iEoln = EOLN_LF; + else + iEoln = EOLN_CRLF; + + cNonCRLFs = adwEolnCount[EOLN_CR] + adwEolnCount[EOLN_LF]; + if (cNonCRLFs != 0) + { + /* Allocate a buffer for EM_SETHANDLE */ + SIZE_T cchNew = cchText + cNonCRLFs; + HLOCAL hLocal = LocalAlloc(LMEM_MOVEABLE, (cchNew + 1) * sizeof(WCHAR)); + LPWSTR pszNew = LocalLock(hLocal); + if (!pszNew) + { + LocalFree(hLocal); + return FALSE; /* Failure */ + } + + ReplaceNewLines(pszNew, cchNew, pszText, cchText); + + /* Replace with new data */ + LocalUnlock(*phLocal); + LocalFree(*phLocal); + *phLocal = hLocal; + *ppszText = pszNew; + *pcchText = cchNew; + } + + *piEoln = iEoln; + return TRUE; +} + BOOL -ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int *piEoln) +ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln) { - DWORD dwSize; - LPBYTE pBytes = NULL; - LPWSTR pszText; - LPWSTR pszAllocText = NULL; - DWORD dwPos, i; - DWORD dwCharCount; + PCHAR pBytes = NULL; + LPWSTR pszText, pszNewText = NULL; + DWORD dwSize, dwPos; + SIZE_T i, cchText, cbContent; BOOL bSuccess = FALSE; - BYTE b = 0; ENCODING encFile = ENCODING_ANSI; - int iCodePage = 0; - WCHAR szCrlf[2] = {'\r', '\n'}; - DWORD adwEolnCount[3] = {0, 0, 0}; - - *ppszText = NULL; - *pdwTextLen = 0; + UINT iCodePage; + HANDLE hMapping = INVALID_HANDLE_VALUE; + HLOCAL hNewLocal; dwSize = GetFileSize(hFile, NULL); if (dwSize == INVALID_FILE_SIZE) goto done; - pBytes = HeapAlloc(GetProcessHeap(), 0, dwSize + 2); - if (!pBytes) + hMapping = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapping == NULL) goto done; - if (!ReadFile(hFile, pBytes, dwSize, &dwSize, NULL)) + pBytes = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, dwSize); + if (!pBytes) goto done; - dwPos = 0; - - /* Make sure that there is a NUL character at the end, in any encoding */ - pBytes[dwSize + 0] = '\0'; - pBytes[dwSize + 1] = '\0'; /* Look for Byte Order Marks */ + dwPos = 0; if ((dwSize >= 2) && (pBytes[0] == 0xFF) && (pBytes[1] == 0xFE)) { encFile = ENCODING_UTF16LE; @@ -151,124 +212,85 @@ ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, switch(encFile) { case ENCODING_UTF16BE: - for (i = dwPos; i < dwSize-1; i += 2) - { - b = pBytes[i+0]; - pBytes[i+0] = pBytes[i+1]; - pBytes[i+1] = b; - } - /* fall through */ - case ENCODING_UTF16LE: + { + /* Re-allocate the buffer for EM_SETHANDLE */ pszText = (LPWSTR) &pBytes[dwPos]; - dwCharCount = (dwSize - dwPos) / sizeof(WCHAR); + cchText = (dwSize - dwPos) / sizeof(WCHAR); + hNewLocal = LocalReAlloc(*phLocal, (cchText + 1) * sizeof(WCHAR), LMEM_MOVEABLE); + pszNewText = LocalLock(hNewLocal); + if (pszNewText == NULL) + goto done; + + *phLocal = hNewLocal; + CopyMemory(pszNewText, pszText, cchText * sizeof(WCHAR)); + + if (encFile == ENCODING_UTF16BE) /* big endian; Swap bytes */ + { + BYTE tmp, *pb = (LPBYTE)pszNewText; + for (i = 0; i < cchText * 2; i += 2) + { + tmp = pb[i]; + pb[i] = pb[i + 1]; + pb[i + 1] = tmp; + } + } break; + } case ENCODING_ANSI: case ENCODING_UTF8: case ENCODING_UTF8BOM: - if (encFile == ENCODING_UTF8 || encFile == ENCODING_UTF8BOM) - iCodePage = CP_UTF8; - else - iCodePage = CP_ACP; + { + iCodePage = ((encFile == ENCODING_UTF8 || encFile == ENCODING_UTF8BOM) ? CP_UTF8 : CP_ACP); - if ((dwSize - dwPos) > 0) + /* Get ready for ANSI-to-Wide conversion */ + cbContent = dwSize - dwPos; + cchText = 0; + if (cbContent > 0) { - dwCharCount = MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, NULL, 0); - if (dwCharCount == 0) + cchText = MultiByteToWideChar(iCodePage, 0, &pBytes[dwPos], (INT)cbContent, NULL, 0); + if (cchText == 0) goto done; } - else - { - /* special case for files with no characters (other than BOMs) */ - dwCharCount = 0; - } - pszAllocText = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, (dwCharCount + 1) * sizeof(WCHAR)); - if (!pszAllocText) + /* Re-allocate the buffer for EM_SETHANDLE */ + hNewLocal = LocalReAlloc(*phLocal, (cchText + 1) * sizeof(WCHAR), LMEM_MOVEABLE); + pszNewText = LocalLock(hNewLocal); + if (!pszNewText) goto done; + *phLocal = hNewLocal; - if ((dwSize - dwPos) > 0) + /* Do ANSI-to-Wide conversion */ + if (cbContent > 0) { - if (!MultiByteToWideChar(iCodePage, 0, (LPCSTR)&pBytes[dwPos], dwSize - dwPos, pszAllocText, dwCharCount)) + if (!MultiByteToWideChar(iCodePage, 0, + &pBytes[dwPos], (INT)cbContent, pszNewText, (INT)cchText)) + { goto done; + } } - - pszAllocText[dwCharCount] = '\0'; - pszText = pszAllocText; break; - DEFAULT_UNREACHABLE; } - dwPos = 0; - for (i = 0; i < dwCharCount; i++) - { - switch(pszText[i]) - { - case '\r': - if ((i < dwCharCount-1) && (pszText[i+1] == '\n')) - { - i++; - adwEolnCount[EOLN_CRLF]++; - break; - } - /* fall through */ - - case '\n': - if (!Append(ppszText, pdwTextLen, &pszText[dwPos], i - dwPos)) - return FALSE; - if (!Append(ppszText, pdwTextLen, szCrlf, ARRAY_SIZE(szCrlf))) - return FALSE; - dwPos = i + 1; - - if (pszText[i] == '\r') - adwEolnCount[EOLN_CR]++; - else - adwEolnCount[EOLN_LF]++; - break; - - case '\0': - pszText[i] = ' '; - break; - } + DEFAULT_UNREACHABLE; } - if (!*ppszText && (pszText == pszAllocText)) - { - /* special case; don't need to reallocate */ - *ppszText = pszAllocText; - *pdwTextLen = dwCharCount; - pszAllocText = NULL; - } - else - { - /* append last remaining text */ - if (!Append(ppszText, pdwTextLen, &pszText[dwPos], i - dwPos + 1)) - return FALSE; - } + pszNewText[cchText] = UNICODE_NULL; - /* chose which eoln to use */ - *piEoln = EOLN_CRLF; - if (adwEolnCount[EOLN_LF] > adwEolnCount[*piEoln]) - *piEoln = EOLN_LF; - if (adwEolnCount[EOLN_CR] > adwEolnCount[*piEoln]) - *piEoln = EOLN_CR; - *pencFile = encFile; + if (!ProcessNewLinesAndNulls(phLocal, &pszNewText, &cchText, piEoln)) + goto done; + *pencFile = encFile; bSuccess = TRUE; done: if (pBytes) - HeapFree(GetProcessHeap(), 0, pBytes); - if (pszAllocText) - HeapFree(GetProcessHeap(), 0, pszAllocText); - - if (!bSuccess && *ppszText) - { - HeapFree(GetProcessHeap(), 0, *ppszText); - *ppszText = NULL; - *pdwTextLen = 0; - } + UnmapViewOfFile(pBytes); + if (hMapping != INVALID_HANDLE_VALUE) + CloseHandle(hMapping); + if (pszNewText) + LocalUnlock(*phLocal); return bSuccess; } @@ -367,7 +389,7 @@ done: return bSuccess; } -BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int iEoln) +BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln) { WCHAR wcBom; LPCWSTR pszLF = L"\n";
1 year, 10 months
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
10
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
Results per page:
10
25
50
100
200