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
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
March 2019
----- 2025 -----
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1097 discussions
Start a n
N
ew thread
Michael Stefaniuc : dsound: Remove useless casts to self.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: 841541a6a6541e464241062e0d49db41056d394f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=841541a6a6541e464241062e…
Author: Michael Stefaniuc <mstefani(a)winehq.org> Date: Thu Feb 28 00:50:29 2019 +0100 dsound: Remove useless casts to self. Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org> Signed-off-by: Andrew Eikum <aeikum(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dsound/primary.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c index 9f41a2b4..852ec51 100644 --- a/dlls/dsound/primary.c +++ b/dlls/dsound/primary.c @@ -576,7 +576,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetVolume(IDirectSoundBuffer8 *iface, LO for (i = 0; i < DS_MAX_CHANNELS; i++) { if (device->pwfx->nChannels > i){ - fvol = (float)((DWORD)(device->volpan.dwTotalAmpFactor[i] & 0xFFFF) / (float)0xFFFF); + fvol = (float)((device->volpan.dwTotalAmpFactor[i] & 0xFFFF) / (float)0xFFFF); hr = IAudioStreamVolume_SetChannelVolume(device->volume, i, fvol); if (FAILED(hr)){ LeaveCriticalSection(&device->mixlock); @@ -932,7 +932,7 @@ static HRESULT WINAPI PrimaryBufferImpl_SetPan(IDirectSoundBuffer8 *iface, LONG for (i = 0; i < DS_MAX_CHANNELS; i++) { if (device->pwfx->nChannels > i) { - fvol = (float)((DWORD)(device->volpan.dwTotalAmpFactor[i] & 0xFFFF) / (float)0xFFFF); + fvol = (float)((device->volpan.dwTotalAmpFactor[i] & 0xFFFF) / (float)0xFFFF); hr = IAudioStreamVolume_SetChannelVolume(device->volume, i, fvol); if (FAILED(hr)){ LeaveCriticalSection(&device->mixlock);
1
0
0
0
Paul Gofman : ntdll: Avoid resetting x87 FPU state when saving context.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: c6cd92bedda4296ce3e666e28c470a5c4b618fee URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c6cd92bedda4296ce3e666e2…
Author: Paul Gofman <gofmanp(a)gmail.com> Date: Mon Mar 4 16:05:16 2019 +0300 ntdll: Avoid resetting x87 FPU state when saving context. 'FNSAVE' x87 instruction resets the FPU state to default values (like FINIT). This results in FPU state reset to default in any ntdll call which is getting x87 FPU state, e. g. obtaining context or raising an exception. Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/signal_i386.c | 18 ++++++++++++++++++ dlls/ntdll/tests/exception.c | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 0274a7d..f1deb1c 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -860,8 +860,26 @@ static inline void *init_handler( const ucontext_t *sigcontext, WORD *fs, WORD * static inline void save_fpu( CONTEXT *context ) { #ifdef __GNUC__ + struct + { + DWORD ControlWord; + DWORD StatusWord; + DWORD TagWord; + DWORD ErrorOffset; + DWORD ErrorSelector; + DWORD DataOffset; + DWORD DataSelector; + } + float_status; + context->ContextFlags |= CONTEXT_FLOATING_POINT; __asm__ __volatile__( "fnsave %0; fwait" : "=m" (context->FloatSave) ); + + /* Reset unmasked exceptions status to avoid firing an exception. */ + memcpy(&float_status, &context->FloatSave, sizeof(float_status)); + float_status.StatusWord &= float_status.ControlWord | 0xffffff80; + + __asm__ __volatile__( "fldenv %0" : "=m" (float_status) ); #endif } diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index f1a59f1..57ad30f 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -1642,7 +1642,7 @@ static void test_thread_context(void) ok( LOWORD(context.FloatSave.ControlWord) == LOWORD(expect.x87_control), "wrong x87 control word %#x/%#x.\n", context.FloatSave.ControlWord, expect.x87_control ); - todo_wine ok( LOWORD(expect.x87_control) == LOWORD(new_x87_control), + ok( LOWORD(expect.x87_control) == LOWORD(new_x87_control), "x87 control word changed in NtGetContextThread() %#x/%#x.\n", LOWORD(expect.x87_control), LOWORD(new_x87_control) );
1
0
0
0
Paul Gofman : ntdll/tests: Add test for preserving x87 fpu state when capturing context.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: fddea78ac1ce2c7d8b34cd5bd17001e6aea304ef URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fddea78ac1ce2c7d8b34cd5b…
Author: Paul Gofman <gofmanp(a)gmail.com> Date: Mon Mar 4 16:05:15 2019 +0300 ntdll/tests: Add test for preserving x87 fpu state when capturing context. Signed-off-by: Paul Gofman <gofmanp(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/tests/exception.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index b8bd186..f1a59f1 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -1509,9 +1509,12 @@ static void test_thread_context(void) struct expected { DWORD Eax, Ebx, Ecx, Edx, Esi, Edi, Ebp, Esp, Eip, - SegCs, SegDs, SegEs, SegFs, SegGs, SegSs, EFlags, prev_frame; + SegCs, SegDs, SegEs, SegFs, SegGs, SegSs, EFlags, prev_frame, + x87_control; } expect; - NTSTATUS (*func_ptr)( struct expected *res, void *func, void *arg1, void *arg2 ) = (void *)code_mem; + NTSTATUS (*func_ptr)( struct expected *res, void *func, void *arg1, void *arg2, + DWORD *new_x87_control ) = (void *)code_mem; + DWORD new_x87_control; static const BYTE call_func[] = { @@ -1542,10 +1545,20 @@ static void test_thread_context(void) 0x8f, 0x40, 0x3c, /* popl 0x3c(%eax) */ 0xff, 0x75, 0x00, /* pushl 0x0(%ebp) ; previous stack frame */ 0x8f, 0x40, 0x40, /* popl 0x40(%eax) */ + /* pushl $0x47f */ + 0x68, 0x7f, 0x04, 0x00, 0x00, + 0x8f, 0x40, 0x44, /* popl 0x44(%eax) */ + 0xd9, 0x68, 0x44, /* fldcw 0x44(%eax) */ + 0x8b, 0x00, /* mov (%eax),%eax */ 0xff, 0x75, 0x14, /* pushl 0x14(%ebp) */ 0xff, 0x75, 0x10, /* pushl 0x10(%ebp) */ 0xff, 0x55, 0x0c, /* call *0xc(%ebp) */ + + 0x8b, 0x55, 0x18, /* mov 0x18(%ebp),%edx */ + 0x9b, 0xd9, 0x3a, /* fstcw (%edx) */ + 0xdb, 0xe3, /* fninit */ + 0xc9, /* leave */ 0xc3, /* ret */ }; @@ -1557,7 +1570,7 @@ static void test_thread_context(void) memset( &context, 0xcc, sizeof(context) ); memset( &expect, 0xcc, sizeof(expect) ); - func_ptr( &expect, pRtlCaptureContext, &context, 0 ); + func_ptr( &expect, pRtlCaptureContext, &context, 0, &new_x87_control ); trace( "expect: eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x ebp=%08x esp=%08x " "eip=%08x cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x flags=%08x prev=%08x\n", expect.Eax, expect.Ebx, expect.Ecx, expect.Edx, expect.Esi, expect.Edi, @@ -1593,8 +1606,9 @@ static void test_thread_context(void) memset( &context, 0xcc, sizeof(context) ); memset( &expect, 0xcc, sizeof(expect) ); - context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS; - status = func_ptr( &expect, pNtGetContextThread, (void *)GetCurrentThread(), &context ); + context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT; + + status = func_ptr( &expect, pNtGetContextThread, (void *)GetCurrentThread(), &context, &new_x87_control ); ok( status == STATUS_SUCCESS, "NtGetContextThread failed %08x\n", status ); trace( "expect: eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x ebp=%08x esp=%08x " "eip=%08x cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x flags=%08x prev=%08x\n", @@ -1625,6 +1639,13 @@ static void test_thread_context(void) ok( context.SegFs == LOWORD(expect.SegFs), "wrong SegFs %08x/%08x\n", context.SegFs, expect.SegFs ); ok( context.SegGs == LOWORD(expect.SegGs), "wrong SegGs %08x/%08x\n", context.SegGs, expect.SegGs ); ok( context.SegSs == LOWORD(expect.SegSs), "wrong SegSs %08x/%08x\n", context.SegSs, expect.SegGs ); + + ok( LOWORD(context.FloatSave.ControlWord) == LOWORD(expect.x87_control), + "wrong x87 control word %#x/%#x.\n", context.FloatSave.ControlWord, expect.x87_control ); + todo_wine ok( LOWORD(expect.x87_control) == LOWORD(new_x87_control), + "x87 control word changed in NtGetContextThread() %#x/%#x.\n", + LOWORD(expect.x87_control), LOWORD(new_x87_control) ); + #undef COMPARE }
1
0
0
0
Alexandre Julliard : winebuild: Add a helper function to open a temporary file as output.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: 67f6c6c0c92ac82db7da067fc06fe00fa05b9340 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=67f6c6c0c92ac82db7da067f…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 4 14:46:02 2019 +0100 winebuild: Add a helper function to open a temporary file as output. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/winebuild/build.h | 1 + tools/winebuild/import.c | 27 +++++++++++---------------- tools/winebuild/utils.c | 20 +++++++++++++------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index d65af7b..d7b46a6 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -260,6 +260,7 @@ extern FILE *open_input_file( const char *srcdir, const char *name ); extern void close_input_file( FILE *file ); extern void open_output_file(void); extern void close_output_file(void); +extern char *open_temp_output_file( const char *suffix ); extern void dump_bytes( const void *buffer, unsigned int size ); extern int remove_stdcall_decoration( char *name ); extern void assemble_file( const char *src_file, const char *obj_file ); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index b3c7121..6ab7765 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -489,22 +489,20 @@ static char *create_undef_symbols_file( DLLSPEC *spec ) char *as_file, *obj_file; int i; unsigned int j; - FILE *f; - as_file = get_temp_file_name( output_file_name, ".s" ); - if (!(f = fopen( as_file, "w" ))) fatal_error( "Cannot create %s\n", as_file ); - fprintf( f, "\t.data\n" ); + as_file = open_temp_output_file( ".s" ); + output( "\t.data\n" ); for (i = 0; i < spec->nb_entry_points; i++) { ORDDEF *odp = &spec->entry_points[i]; if (odp->type == TYPE_STUB || odp->type == TYPE_ABS || odp->type == TYPE_VARIABLE) continue; if (odp->flags & FLAG_FORWARD) continue; - fprintf( f, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp->link_name) ); + output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name(odp->link_name) ); } for (j = 0; j < extra_ld_symbols.count; j++) - fprintf( f, "\t%s %s\n", get_asm_ptr_keyword(), asm_name(extra_ld_symbols.str[j]) ); - fclose( f ); + output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name(extra_ld_symbols.str[j]) ); + fclose( output_file ); obj_file = get_temp_file_name( output_file_name, ".o" ); assemble_file( as_file, obj_file ); @@ -1332,13 +1330,12 @@ void output_imports( DLLSPEC *spec ) } /* create a new asm temp file */ -static void new_output_as_file( const char *prefix ) +static void new_output_as_file(void) { - char *name = get_temp_file_name( prefix, ".s" ); + char *name; if (output_file) fclose( output_file ); - if (!(output_file = fopen( name, "w" ))) - fatal_error( "Unable to create output file '%s'\n", name ); + name = open_temp_output_file( ".s" ); strarray_add( &as_files, name, NULL ); } @@ -1381,9 +1378,7 @@ static void build_windows_import_lib( DLLSPEC *spec ) char *def_file; const char *as_flags, *m_flag; - def_file = get_temp_file_name( output_file_name, ".def" ); - if (!(output_file = fopen( def_file, "w" ))) - fatal_error( "Unable to create output file '%s'\n", def_file ); + def_file = open_temp_output_file( ".def" ); output_def_file( spec, 0 ); fclose( output_file ); @@ -1442,7 +1437,7 @@ static void build_unix_import_lib( DLLSPEC *spec ) case TYPE_CDECL: case TYPE_STDCALL: prefix = (!odp->name || (odp->flags & FLAG_ORDINAL)) ? import_ord_prefix : import_func_prefix; - new_output_as_file( spec->file_name ); + new_output_as_file(); output( "\t.text\n" ); output( "\n\t.align %d\n", get_alignment( get_ptr_size() )); output( "\t%s\n", func_declaration( name ) ); @@ -1461,7 +1456,7 @@ static void build_unix_import_lib( DLLSPEC *spec ) if (!as_files.count) /* create a dummy file to avoid empty import libraries */ { - new_output_as_file( spec->file_name ); + new_output_as_file(); output( "\t.text\n" ); } diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 09b01fa..06c3d39 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -734,16 +734,10 @@ void open_output_file(void) if (output_file_name) { if (strendswith( output_file_name, ".o" )) - { - output_file_source_name = get_temp_file_name( output_file_name, ".s" ); - if (!(output_file = fopen( output_file_source_name, "w" ))) - fatal_error( "Unable to create output file '%s'\n", output_file_name ); - } + output_file_source_name = open_temp_output_file( ".s" ); else - { if (!(output_file = fopen( output_file_name, "w" ))) fatal_error( "Unable to create output file '%s'\n", output_file_name ); - } } else output_file = stdout; } @@ -762,6 +756,18 @@ void close_output_file(void) /******************************************************************* + * open_temp_output_file + */ +char *open_temp_output_file( const char *suffix ) +{ + char *tmp_file = get_temp_file_name( output_file_name, suffix ); + if (!(output_file = fopen( tmp_file, "w" ))) + fatal_error( "Unable to create output file '%s'\n", tmp_file ); + return tmp_file; +} + + +/******************************************************************* * remove_stdcall_decoration * * Remove a possible @xx suffix from a function name.
1
0
0
0
Alexandre Julliard : winebuild: Open the output file only when needed.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: aa0572f0a27d5dd5981835aa5bd198061964df97 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=aa0572f0a27d5dd5981835aa…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon Mar 4 14:31:48 2019 +0100 winebuild: Open the output file only when needed. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/winebuild/build.h | 2 ++ tools/winebuild/import.c | 3 --- tools/winebuild/main.c | 34 +++++++--------------------------- tools/winebuild/res32.c | 2 -- tools/winebuild/spec16.c | 2 ++ tools/winebuild/spec32.c | 2 ++ tools/winebuild/utils.c | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 51 insertions(+), 32 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index eee98eb..d65af7b 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -258,6 +258,8 @@ extern char *get_temp_file_name( const char *prefix, const char *suffix ); extern void output_standard_file_header(void); extern FILE *open_input_file( const char *srcdir, const char *name ); extern void close_input_file( FILE *file ); +extern void open_output_file(void); +extern void close_output_file(void); extern void dump_bytes( const void *buffer, unsigned int size ); extern int remove_stdcall_decoration( char *name ); extern void assemble_file( const char *src_file, const char *obj_file ); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 893691e..b3c7121 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -1382,12 +1382,10 @@ static void build_windows_import_lib( DLLSPEC *spec ) const char *as_flags, *m_flag; def_file = get_temp_file_name( output_file_name, ".def" ); - fclose( output_file ); if (!(output_file = fopen( def_file, "w" ))) fatal_error( "Unable to create output file '%s'\n", def_file ); output_def_file( spec, 0 ); fclose( output_file ); - output_file = NULL; args = find_tool( "dlltool", NULL ); switch (target_cpu) @@ -1484,5 +1482,4 @@ void output_import_lib( DLLSPEC *spec, char **argv ) build_unix_import_lib( spec ); build_library( output_file_name, argv, 1 ); } - output_file_name = NULL; } diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index b2f5c95..7769641 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -79,7 +79,6 @@ char *input_file_name = NULL; char *spec_file_name = NULL; FILE *output_file = NULL; const char *output_file_name = NULL; -static const char *output_file_source_name; static int fake_module; struct strarray lib_path = { 0 }; @@ -450,25 +449,9 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) add_import_dll( optarg, NULL ); break; case 'o': - { - char *ext = strrchr( optarg, '.' ); - - if (unlink( optarg ) == -1 && errno != ENOENT) - fatal_error( "Unable to create output file '%s'\n", optarg ); - if (ext && !strcmp( ext, ".o" )) - { - output_file_source_name = get_temp_file_name( optarg, ".s" ); - if (!(output_file = fopen( output_file_source_name, "w" ))) - fatal_error( "Unable to create output file '%s'\n", optarg ); - } - else - { - if (!(output_file = fopen( optarg, "w" ))) - fatal_error( "Unable to create output file '%s'\n", optarg ); - } - output_file_name = xstrdup(optarg); - atexit( cleanup ); /* make sure we remove the output file on exit */ - } + if (unlink( optarg ) == -1 && errno != ENOENT) + fatal_error( "Unable to create output file '%s'\n", optarg ); + output_file_name = xstrdup( optarg ); break; case 'r': strarray_add( &res_files, xstrdup( optarg ), NULL ); @@ -636,8 +619,8 @@ int main(int argc, char **argv) signal( SIGTERM, exit_on_signal ); signal( SIGINT, exit_on_signal ); - output_file = stdout; argv = parse_options( argc, argv, spec ); + atexit( cleanup ); /* make sure we remove the output file on exit */ switch(exec_mode) { @@ -671,7 +654,9 @@ int main(int argc, char **argv) if (argv[0]) fatal_error( "file argument '%s' not allowed in this mode\n", argv[0] ); if (!spec_file_name) fatal_error( "missing .spec file\n" ); if (!parse_input_file( spec )) break; + open_output_file(); output_def_file( spec, 1 ); + close_output_file(); break; case MODE_IMPLIB: if (!spec_file_name) fatal_error( "missing .spec file\n" ); @@ -687,11 +672,6 @@ int main(int argc, char **argv) break; } if (nb_errors) exit(1); - if (output_file_name) - { - if (fclose( output_file ) < 0) fatal_perror( "fclose" ); - if (output_file_source_name) assemble_file( output_file_source_name, output_file_name ); - output_file_name = NULL; - } + output_file_name = NULL; return 0; } diff --git a/tools/winebuild/res32.c b/tools/winebuild/res32.c index d237782..b20dfb4 100644 --- a/tools/winebuild/res32.c +++ b/tools/winebuild/res32.c @@ -698,6 +698,4 @@ void output_res_o_file( DLLSPEC *spec ) if (format) strarray_add( &args, "-F", format, NULL ); spawn( args ); - - output_file_name = NULL; /* so we don't try to assemble it */ } diff --git a/tools/winebuild/spec16.c b/tools/winebuild/spec16.c index 85bcf09..027580b 100644 --- a/tools/winebuild/spec16.c +++ b/tools/winebuild/spec16.c @@ -816,6 +816,7 @@ void output_spec16_file( DLLSPEC *spec16 ) add_16bit_exports( spec32, spec16 ); needs_get_pc_thunk = 0; + open_output_file(); output_standard_file_header(); output_module( spec32 ); output_module16( spec16 ); @@ -831,6 +832,7 @@ void output_spec16_file( DLLSPEC *spec16 ) output( "\t%s \"%s\"\n", get_asm_string_keyword(), spec16->main_module ); } output_gnu_stack_note(); + close_output_file(); free_dll_spec( spec32 ); } diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 132ab88..89f33c8 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -703,6 +703,7 @@ void BuildSpec32File( DLLSPEC *spec ) { needs_get_pc_thunk = 0; resolve_imports( spec ); + open_output_file(); output_standard_file_header(); output_module( spec ); output_stubs( spec ); @@ -711,6 +712,7 @@ void BuildSpec32File( DLLSPEC *spec ) if (needs_get_pc_thunk) output_get_pc_thunk(); output_resources( spec ); output_gnu_stack_note(); + close_output_file(); } diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 78e9645..09b01fa 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -47,6 +47,7 @@ static struct strarray tmp_files; static struct strarray empty_strarray; +static const char *output_file_source_name; static const struct { @@ -564,8 +565,10 @@ void init_output_buffer(void) void flush_output_buffer(void) { + open_output_file(); if (fwrite( output_buffer, 1, output_buffer_pos, output_file ) != output_buffer_pos) fatal_error( "Error writing to %s\n", output_file_name ); + close_output_file(); free( output_buffer ); } @@ -724,6 +727,41 @@ void close_input_file( FILE *file ) /******************************************************************* + * open_output_file + */ +void open_output_file(void) +{ + if (output_file_name) + { + if (strendswith( output_file_name, ".o" )) + { + output_file_source_name = get_temp_file_name( output_file_name, ".s" ); + if (!(output_file = fopen( output_file_source_name, "w" ))) + fatal_error( "Unable to create output file '%s'\n", output_file_name ); + } + else + { + if (!(output_file = fopen( output_file_name, "w" ))) + fatal_error( "Unable to create output file '%s'\n", output_file_name ); + } + } + else output_file = stdout; +} + + +/******************************************************************* + * close_output_file + */ +void close_output_file(void) +{ + if (!output_file || !output_file_name) return; + if (fclose( output_file ) < 0) fatal_perror( "fclose" ); + if (output_file_source_name) assemble_file( output_file_source_name, output_file_name ); + output_file = NULL; +} + + +/******************************************************************* * remove_stdcall_decoration * * Remove a possible @xx suffix from a function name.
1
0
0
0
Brendan McGrath : kernel32: Allow double quote style escape in argv.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: 87917df887e00254a457a859c06892307b4e2daf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=87917df887e00254a457a859…
Author: Brendan McGrath <brendan(a)redmandi.com> Date: Tue Feb 26 19:39:25 2019 +1100 kernel32: Allow double quote style escape in argv. Two quotes together (within outer quotes) represents a single quote (with the first quote acting as an escape character) Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46721
Signed-off-by: Brendan McGrath <brendan(a)redmandi.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/process.c | 17 +++++++++++++---- dlls/kernel32/tests/process.c | 7 ++++--- dlls/ntdll/process.c | 17 +++++++++++++---- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index ad257a0..89b561e 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -1505,9 +1505,13 @@ static char **build_argv( const UNICODE_STRING *cmdlineW, int reserved ) /* '\', count them */ bcount++; } else if ((*s=='"') && ((bcount & 1)==0)) { - /* unescaped '"' */ - in_quotes=!in_quotes; - bcount=0; + if (in_quotes && s[1] == '"') { + s++; + } else { + /* unescaped '"' */ + in_quotes=!in_quotes; + bcount=0; + } } else { /* a regular character */ bcount=0; @@ -1551,7 +1555,12 @@ static char **build_argv( const UNICODE_STRING *cmdlineW, int reserved ) */ d-=bcount/2; s++; - in_quotes=!in_quotes; + if(in_quotes && *s == '"') { + *d++='"'; + s++; + } else { + in_quotes=!in_quotes; + } } else { /* Preceded by an odd number of '\', this is half that * number of '\' followed by a '"' diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index fe68d28..f62f8fb 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -896,7 +896,7 @@ static void test_CommandLine(void) /* the basics */ get_file_name(resfile); - sprintf(buffer, "\"%s\" tests/process.c dump \"%s\" \"C:\\Program Files\\my nice app.exe\"", selfname, resfile); + sprintf(buffer, "\"%s\" tests/process.c dump \"%s\" \"C:\\Program Files\\my nice app.exe\" \"\"\"\"", selfname, resfile); ok(CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); /* wait for child to terminate */ ok(WaitForSingleObject(info.hProcess, 30000) == WAIT_OBJECT_0, "Child process termination\n"); @@ -905,9 +905,10 @@ static void test_CommandLine(void) CloseHandle(info.hThread); CloseHandle(info.hProcess); - okChildInt("Arguments", "argcA", 5); + okChildInt("Arguments", "argcA", 6); okChildString("Arguments", "argvA4", "C:\\Program Files\\my nice app.exe"); - okChildString("Arguments", "argvA5", NULL); + okChildString("Arguments", "argvA5", "\""); + okChildString("Arguments", "argvA6", NULL); okChildString("Arguments", "CommandLineA", buffer); release_memory(); DeleteFileA(resfile); diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c index 2ff8610..6c6c427 100644 --- a/dlls/ntdll/process.c +++ b/dlls/ntdll/process.c @@ -815,9 +815,13 @@ static char **build_argv( const UNICODE_STRING *cmdlineW, int reserved ) else if (*s == '\\') bcount++; /* '\', count them */ else if ((*s == '"') && ((bcount & 1) == 0)) { - /* unescaped '"' */ - in_quotes = !in_quotes; - bcount = 0; + if (in_quotes && s[1] == '"') s++; + else + { + /* unescaped '"' */ + in_quotes = !in_quotes; + bcount = 0; + } } else bcount = 0; /* a regular character */ s++; @@ -864,7 +868,12 @@ static char **build_argv( const UNICODE_STRING *cmdlineW, int reserved ) */ d -= bcount/2; s++; - in_quotes = !in_quotes; + if (in_quotes && *s == '"') + { + *d++ = '"'; + s++; + } + else in_quotes = !in_quotes; } else {
1
0
0
0
Jacek Caban : jscript: Add support for string literals with embedded null bytes.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: 922049a21d69333a8c5b58654103fde914a4737a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=922049a21d69333a8c5b5865…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Mar 1 17:44:18 2019 +0100 jscript: Add support for string literals with embedded null bytes. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/jscript/compile.c | 4 ++-- dlls/jscript/lex.c | 34 +++++++++++++++++++++------------- dlls/jscript/parser.h | 2 +- dlls/jscript/parser.y | 12 ++++++------ dlls/jscript/tests/lang.js | 3 +++ 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 08975e2..9e71872 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -829,7 +829,7 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal) case LT_NULL: return push_instr(ctx, OP_null) ? S_OK : E_OUTOFMEMORY; case LT_STRING: - return push_instr_str(ctx, OP_str, compiler_alloc_string(ctx, literal->u.wstr)); + return push_instr_str(ctx, OP_str, literal->u.str); case LT_REGEXP: return push_instr_str_uint(ctx, OP_regexp, literal->u.regexp.str, literal->u.regexp.flags); DEFAULT_UNREACHABLE; @@ -841,7 +841,7 @@ static HRESULT literal_as_string(compiler_ctx_t *ctx, literal_t *literal, jsstr_ { switch(literal->type) { case LT_STRING: - *str = compiler_alloc_string(ctx, literal->u.wstr); + *str = literal->u.str; break; case LT_DOUBLE: return double_to_string(literal->u.dval, str); diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index b3a7923..a22a02b 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -373,33 +373,41 @@ static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret) return tIdentifier; } -static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret, WCHAR endch) +static int parse_string_literal(parser_ctx_t *ctx, jsstr_t **ret, WCHAR endch) { - const WCHAR *ptr = ++ctx->ptr; - WCHAR *wstr; + const WCHAR *ptr = ++ctx->ptr, *ret_str = ptr; + BOOL needs_unescape = FALSE; + WCHAR *unescape_str; size_t len; while(ctx->ptr < ctx->end && *ctx->ptr != endch) { - if(*ctx->ptr++ == '\\') + if(*ctx->ptr++ == '\\') { ctx->ptr++; + needs_unescape = TRUE; + } } if(ctx->ptr == ctx->end) return lex_error(ctx, JS_E_UNTERMINATED_STRING); - len = ctx->ptr-ptr; - - *ret = wstr = parser_alloc(ctx, (len+1)*sizeof(WCHAR)); - memcpy(wstr, ptr, len*sizeof(WCHAR)); - + len = ctx->ptr - ptr; ctx->ptr++; - if(!unescape(wstr, &len)) { - WARN("unescape failed\n"); - return lex_error(ctx, E_FAIL); + if(needs_unescape) { + ret_str = unescape_str = parser_alloc(ctx, len * sizeof(WCHAR)); + if(!unescape_str) + return lex_error(ctx, E_OUTOFMEMORY); + memcpy(unescape_str, ptr, len * sizeof(WCHAR)); + if(!unescape(unescape_str, &len)) { + WARN("unescape failed\n"); + return lex_error(ctx, E_FAIL); + } } - wstr[len] = 0; + if(!(*ret = compiler_alloc_string_len(ctx->compiler, ret_str, len))) + return lex_error(ctx, E_OUTOFMEMORY); + + /* FIXME: leaking string */ return tStringLiteral; } diff --git a/dlls/jscript/parser.h b/dlls/jscript/parser.h index 0be13d5..bceb556 100644 --- a/dlls/jscript/parser.h +++ b/dlls/jscript/parser.h @@ -79,7 +79,7 @@ typedef struct { literal_type_t type; union { double dval; - const WCHAR *wstr; + jsstr_t *str; BOOL bval; struct { jsstr_t *str; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 57aecf6..8fc0d37 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -37,7 +37,7 @@ typedef struct _statement_list_t { statement_t *tail; } statement_list_t; -static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); +static literal_t *new_string_literal(parser_ctx_t*,jsstr_t*); static literal_t *new_null_literal(parser_ctx_t*); typedef struct _property_list_t { @@ -147,7 +147,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state %union { int ival; const WCHAR *srcptr; - LPCWSTR wstr; + jsstr_t *str; literal_t *literal; struct _argument_list_t *argument_list; case_clausule_t *case_clausule; @@ -177,7 +177,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state %token <identifier> tIdentifier %token <ival> tAssignOper tEqOper tShiftOper tRelOper %token <literal> tNumericLiteral tBooleanLiteral -%token <wstr> tStringLiteral +%token <str> tStringLiteral %token tEOF %type <source_elements> SourceElements @@ -813,7 +813,7 @@ GetterSetterMethod /* Ecma-262 3rd Edition 11.1.5 */ PropertyName - : IdentifierName { $$ = new_string_literal(ctx, $1); } + : IdentifierName { $$ = new_string_literal(ctx, compiler_alloc_string_len(ctx->compiler, $1, strlenW($1))); } | tStringLiteral { $$ = new_string_literal(ctx, $1); } | tNumericLiteral { $$ = $1; } @@ -921,12 +921,12 @@ static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size return stat; } -static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) +static literal_t *new_string_literal(parser_ctx_t *ctx, jsstr_t *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); ret->type = LT_STRING; - ret->u.wstr = str; + ret->u.str = str; return ret; } diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 2a30ea3..0fb63f4 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -180,6 +180,9 @@ ok(tmp === "undefined", "typeof((new Object).doesnotexist = " + tmp); tmp = typeof(testObj.onlyDispID); ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp); +ok("\0\0x\0\0".length === 5, "\"\\0\\0x\\0\\0\".length = " + "\0\0x\0\0".length); +ok("\0\0x\0\0" === String.fromCharCode(0) + "\0x\0" + String.fromCharCode(0), "\"\\0\\0x\\0\\0\" unexpected"); + ok(testFunc1(true, "test") === true, "testFunc1 not returned true"); ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments);
1
0
0
0
Jacek Caban : jscript: Pass string as jsstr_t to push_instr_str.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: 1314140a3783d062ba4ce968c877fd09f75a3be3 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1314140a3783d062ba4ce968…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Mar 1 17:44:40 2019 +0100 jscript: Pass string as jsstr_t to push_instr_str. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/jscript/compile.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index d165dd7..08975e2 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -245,14 +245,9 @@ static HRESULT push_instr_int(compiler_ctx_t *ctx, jsop_t op, LONG arg) return S_OK; } -static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg) +static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, jsstr_t *str) { unsigned instr; - jsstr_t *str; - - str = compiler_alloc_string(ctx, arg); - if(!str) - return E_OUTOFMEMORY; instr = push_instr(ctx, op); if(!instr) @@ -490,13 +485,18 @@ static HRESULT compile_memberid_expression(compiler_ctx_t *ctx, expression_t *ex } case EXPR_MEMBER: { member_expression_t *member_expr = (member_expression_t*)expr; + jsstr_t *jsstr; hres = compile_expression(ctx, member_expr->expression, TRUE); if(FAILED(hres)) return hres; /* FIXME: Potential optimization */ - hres = push_instr_str(ctx, OP_str, member_expr->identifier); + jsstr = compiler_alloc_string(ctx, member_expr->identifier); + if(!jsstr) + return E_OUTOFMEMORY; + + hres = push_instr_str(ctx, OP_str, jsstr); if(FAILED(hres)) return hres; @@ -689,13 +689,18 @@ static HRESULT compile_delete_expression(compiler_ctx_t *ctx, unary_expression_t } case EXPR_MEMBER: { member_expression_t *member_expr = (member_expression_t*)expr->expression; + jsstr_t *jsstr; hres = compile_expression(ctx, member_expr->expression, TRUE); if(FAILED(hres)) return hres; /* FIXME: Potential optimization */ - hres = push_instr_str(ctx, OP_str, member_expr->identifier); + jsstr = compiler_alloc_string(ctx, member_expr->identifier); + if(!jsstr) + return E_OUTOFMEMORY; + + hres = push_instr_str(ctx, OP_str, jsstr); if(FAILED(hres)) return hres; @@ -824,7 +829,7 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal) case LT_NULL: return push_instr(ctx, OP_null) ? S_OK : E_OUTOFMEMORY; case LT_STRING: - return push_instr_str(ctx, OP_str, literal->u.wstr); + return push_instr_str(ctx, OP_str, compiler_alloc_string(ctx, literal->u.wstr)); case LT_REGEXP: return push_instr_str_uint(ctx, OP_regexp, literal->u.regexp.str, literal->u.regexp.flags); DEFAULT_UNREACHABLE;
1
0
0
0
Jacek Caban : jscript: Return regexp string as jsstr_t from lexer.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: edc9df207c12d7560e9f32c0b0cb4b8ee98130ed URL:
https://source.winehq.org/git/wine.git/?a=commit;h=edc9df207c12d7560e9f32c0…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Mar 1 17:44:31 2019 +0100 jscript: Return regexp string as jsstr_t from lexer. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/jscript/compile.c | 24 +++++------------------- dlls/jscript/lex.c | 3 +-- dlls/jscript/parser.h | 8 +++++--- dlls/jscript/parser.y | 5 ++++- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 5c60ab0..d165dd7 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -48,7 +48,7 @@ typedef struct { int ref; } function_local_t; -typedef struct { +typedef struct _compiler_ctx_t { parser_ctx_t *parser; bytecode_t *code; @@ -130,7 +130,7 @@ static inline void *compiler_alloc(bytecode_t *code, size_t size) return heap_pool_alloc(&code->heap, size); } -static jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len) +jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len) { jsstr_t *new_str; @@ -825,22 +825,8 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal) return push_instr(ctx, OP_null) ? S_OK : E_OUTOFMEMORY; case LT_STRING: return push_instr_str(ctx, OP_str, literal->u.wstr); - case LT_REGEXP: { - unsigned instr; - jsstr_t *str; - - str = compiler_alloc_string_len(ctx, literal->u.regexp.str, literal->u.regexp.str_len); - if(!str) - return E_OUTOFMEMORY; - - instr = push_instr(ctx, OP_regexp); - if(!instr) - return E_OUTOFMEMORY; - - instr_ptr(ctx, instr)->u.arg[0].str = str; - instr_ptr(ctx, instr)->u.arg[1].uint = literal->u.regexp.flags; - return S_OK; - } + case LT_REGEXP: + return push_instr_str_uint(ctx, OP_regexp, literal->u.regexp.str, literal->u.regexp.flags); DEFAULT_UNREACHABLE; } return E_FAIL; @@ -2480,7 +2466,7 @@ HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *args, } } - hres = script_parse(ctx, compiler.code->source, delimiter, from_eval, &compiler.parser); + hres = script_parse(ctx, &compiler, compiler.code->source, delimiter, from_eval, &compiler.parser); if(FAILED(hres)) { release_bytecode(compiler.code); return hres; diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index 2f0172c..b3a7923 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -1201,8 +1201,7 @@ literal_t *parse_regexp(parser_ctx_t *ctx) ret = parser_alloc(ctx, sizeof(literal_t)); ret->type = LT_REGEXP; - ret->u.regexp.str = re; - ret->u.regexp.str_len = re_len; + ret->u.regexp.str = compiler_alloc_string_len(ctx->compiler, re, re_len); ret->u.regexp.flags = flags; return ret; } diff --git a/dlls/jscript/parser.h b/dlls/jscript/parser.h index f4f044c..0be13d5 100644 --- a/dlls/jscript/parser.h +++ b/dlls/jscript/parser.h @@ -34,6 +34,7 @@ typedef struct _parser_ctx_t { const WCHAR *ptr; script_ctx_t *script; + struct _compiler_ctx_t *compiler; source_elements_t *source; BOOL nl; BOOL implicit_nl_semicolon; @@ -47,7 +48,7 @@ typedef struct _parser_ctx_t { heap_pool_t heap; } parser_ctx_t; -HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN; +HRESULT script_parse(script_ctx_t*,struct _compiler_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN; void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN; int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN; @@ -81,8 +82,7 @@ typedef struct { const WCHAR *wstr; BOOL bval; struct { - const WCHAR *str; - DWORD str_len; + jsstr_t *str; DWORD flags; } regexp; } u; @@ -399,3 +399,5 @@ static inline double get_ccnum(ccval_t v) { return v.is_num ? v.u.n : v.u.b; } + +jsstr_t *compiler_alloc_string_len(struct _compiler_ctx_t*,const WCHAR *,unsigned) DECLSPEC_HIDDEN; diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y index 157bc18..57aecf6 100644 --- a/dlls/jscript/parser.y +++ b/dlls/jscript/parser.y @@ -1566,7 +1566,7 @@ void parser_release(parser_ctx_t *ctx) heap_free(ctx); } -HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimiter, BOOL from_eval, +HRESULT script_parse(script_ctx_t *ctx, struct _compiler_ctx_t *compiler, const WCHAR *code, const WCHAR *delimiter, BOOL from_eval, parser_ctx_t **ret) { parser_ctx_t *parser_ctx; @@ -1591,7 +1591,10 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite mark = heap_pool_mark(&ctx->tmp_heap); heap_pool_init(&parser_ctx->heap); + parser_ctx->compiler = compiler; parser_parse(parser_ctx); + parser_ctx->compiler = NULL; + heap_pool_clear(mark); hres = parser_ctx->hres; if(FAILED(hres)) {
1
0
0
0
Jacek Caban : jscript: Support embedded null bytes in unescape.
by Alexandre Julliard
04 Mar '19
04 Mar '19
Module: wine Branch: master Commit: 79557db98133a2c6062d7416448a41bd4ed33d71 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=79557db98133a2c6062d7416…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Mar 1 17:44:07 2019 +0100 jscript: Support embedded null bytes in unescape. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/jscript/json.c | 4 ++-- dlls/jscript/lex.c | 25 +++++++++++++++---------- dlls/jscript/parser.h | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dlls/jscript/json.c b/dlls/jscript/json.c index d440543..b5e6e10 100644 --- a/dlls/jscript/json.c +++ b/dlls/jscript/json.c @@ -89,14 +89,14 @@ static HRESULT parse_json_string(json_parse_ctx_t *ctx, WCHAR **r) return E_OUTOFMEMORY; if(len) memcpy(buf, ptr, len*sizeof(WCHAR)); - buf[len] = 0; - if(!unescape(buf)) { + if(!unescape(buf, &len)) { FIXME("unescape failed\n"); heap_free(buf); return E_FAIL; } + buf[len] = 0; ctx->ptr++; *r = buf; return S_OK; diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index be20e99..2f0172c 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -260,19 +260,20 @@ static BOOL skip_spaces(parser_ctx_t *ctx) return ctx->ptr != ctx->end; } -BOOL unescape(WCHAR *str) +BOOL unescape(WCHAR *str, size_t *len) { - WCHAR *pd, *p, c; + WCHAR *pd, *p, c, *end = str + *len; int i; pd = p = str; - while(*p) { + while(p < end) { if(*p != '\\') { *pd++ = *p++; continue; } - p++; + if(++p == end) + return FALSE; switch(*p) { case '\'': @@ -296,6 +297,8 @@ BOOL unescape(WCHAR *str) c = '\r'; break; case 'x': + if(p + 2 >= end) + return FALSE; i = hex_to_int(*++p); if(i == -1) return FALSE; @@ -307,6 +310,8 @@ BOOL unescape(WCHAR *str) c += i; break; case 'u': + if(p + 4 >= end) + return FALSE; i = hex_to_int(*++p); if(i == -1) return FALSE; @@ -330,9 +335,9 @@ BOOL unescape(WCHAR *str) default: if(isdigitW(*p)) { c = *p++ - '0'; - if(isdigitW(*p)) { + if(p < end && isdigitW(*p)) { c = c*8 + (*p++ - '0'); - if(isdigitW(*p)) + if(p < end && isdigitW(*p)) c = c*8 + (*p++ - '0'); } p--; @@ -345,7 +350,7 @@ BOOL unescape(WCHAR *str) p++; } - *pd = 0; + *len = pd - str; return TRUE; } @@ -372,7 +377,7 @@ static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret, WCHAR endc { const WCHAR *ptr = ++ctx->ptr; WCHAR *wstr; - int len; + size_t len; while(ctx->ptr < ctx->end && *ctx->ptr != endch) { if(*ctx->ptr++ == '\\') @@ -386,15 +391,15 @@ static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret, WCHAR endc *ret = wstr = parser_alloc(ctx, (len+1)*sizeof(WCHAR)); memcpy(wstr, ptr, len*sizeof(WCHAR)); - wstr[len] = 0; ctx->ptr++; - if(!unescape(wstr)) { + if(!unescape(wstr, &len)) { WARN("unescape failed\n"); return lex_error(ctx, E_FAIL); } + wstr[len] = 0; return tStringLiteral; } diff --git a/dlls/jscript/parser.h b/dlls/jscript/parser.h index 03f504f..f4f044c 100644 --- a/dlls/jscript/parser.h +++ b/dlls/jscript/parser.h @@ -63,7 +63,7 @@ static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size) } BOOL is_identifier_char(WCHAR) DECLSPEC_HIDDEN; -BOOL unescape(WCHAR*) DECLSPEC_HIDDEN; +BOOL unescape(WCHAR*,size_t*) DECLSPEC_HIDDEN; HRESULT parse_decimal(const WCHAR**,const WCHAR*,double*) DECLSPEC_HIDDEN; typedef enum {
1
0
0
0
← Newer
1
...
87
88
89
90
91
92
93
...
110
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
Results per page:
10
25
50
100
200