From: Piotr Caban piotr@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56956 --- dlls/msvcrt/file.c | 20 ++++++++++---------- dlls/msvcrt/msvcrt.h | 7 +++++++ dlls/ucrtbase/tests/file.c | 6 +++++- 3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 0bf8510c5c9..05630fb54b1 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -883,7 +883,7 @@ static BOOL msvcrt_alloc_buffer(FILE* file) } else { file->_base = (char*)(&file->_charbuf); file->_bufsiz = 2; - file->_flag |= _IONBF; + file->_flag |= MSVCRT__NOBUF; } file->_ptr = file->_base; file->_cnt = 0; @@ -896,7 +896,7 @@ static BOOL add_std_buffer(FILE *file) static char buffers[2][BUFSIZ];
if((file->_file!=STDOUT_FILENO && file->_file!=STDERR_FILENO) - || (file->_flag & (_IONBF | _IOMYBUF | MSVCRT__USERBUF)) + || (file->_flag & (MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF)) || !_isatty(file->_file)) return FALSE;
@@ -3885,7 +3885,7 @@ int CDECL _filbuf(FILE* file) return EOF;
/* Allocate buffer if needed */ - if(!(file->_flag & (_IONBF | _IOMYBUF | MSVCRT__USERBUF))) + if(!(file->_flag & (MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF))) msvcrt_alloc_buffer(file);
if(!(file->_flag & _IOREAD)) { @@ -4136,7 +4136,7 @@ wchar_t * CDECL fgetws(wchar_t *s, int size, FILE* file) int CDECL _flsbuf(int c, FILE* file) { /* Flush output buffer */ - if(!(file->_flag & (_IONBF | _IOMYBUF | MSVCRT__USERBUF))) { + if(!(file->_flag & (MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF))) { msvcrt_alloc_buffer(file); }
@@ -4221,13 +4221,13 @@ size_t CDECL _fwrite_nolock(const void *ptr, size_t size, size_t nmemb, FILE* fi written += pcnt; wrcnt -= pcnt; ptr = (const char*)ptr + pcnt; - } else if((file->_flag & _IONBF) + } else if((file->_flag & MSVCRT__NOBUF) || ((file->_flag & (_IOMYBUF | MSVCRT__USERBUF)) && wrcnt >= file->_bufsiz) || (!(file->_flag & (_IOMYBUF | MSVCRT__USERBUF)) && wrcnt >= MSVCRT_INTERNAL_BUFSIZ)) { size_t pcnt; int bufsiz;
- if(file->_flag & _IONBF) + if(file->_flag & MSVCRT__NOBUF) bufsiz = 1; else if(!(file->_flag & (_IOMYBUF | MSVCRT__USERBUF))) bufsiz = MSVCRT_INTERNAL_BUFSIZ; @@ -4510,7 +4510,7 @@ size_t CDECL _fread_nolock(void *ptr, size_t size, size_t nmemb, FILE* file) } }
- if(rcnt>0 && !(file->_flag & (_IONBF | _IOMYBUF | MSVCRT__USERBUF))) + if(rcnt>0 && !(file->_flag & (MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF))) msvcrt_alloc_buffer(file);
while(rcnt>0) @@ -5084,11 +5084,11 @@ int CDECL setvbuf(FILE* file, char *buf, int mode, size_t size) _fflush_nolock(file); if(file->_flag & _IOMYBUF) free(file->_base); - file->_flag &= ~(_IONBF | _IOMYBUF | MSVCRT__USERBUF); + file->_flag &= ~(MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF); file->_cnt = 0;
if(mode == _IONBF) { - file->_flag |= _IONBF; + file->_flag |= MSVCRT__NOBUF; file->_base = file->_ptr = (char*)&file->_charbuf; file->_bufsiz = 2; }else if(buf) { @@ -5823,7 +5823,7 @@ int CDECL _ungetc_nolock(int c, FILE * file) (file->_flag&_IORW && !(file->_flag&_IOWRT)))) return EOF;
- if((!(file->_flag & (_IONBF | _IOMYBUF | MSVCRT__USERBUF)) + if((!(file->_flag & (MSVCRT__NOBUF | _IOMYBUF | MSVCRT__USERBUF)) && msvcrt_alloc_buffer(file)) || (!file->_cnt && file->_ptr==file->_base)) file->_ptr++; diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index e95b824f3f3..eaaf8b0034d 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -43,6 +43,13 @@ typedef struct _iobuf #define _IOMYBUF 0x0040 #define _IOSTRG 0x1000 #endif + +#define MSVCRT__NOBUF 0x0400 + +#else + +#define MSVCRT__NOBUF _IONBF + #endif
#include <errno.h> diff --git a/dlls/ucrtbase/tests/file.c b/dlls/ucrtbase/tests/file.c index e739934de02..d128a9bffb0 100644 --- a/dlls/ucrtbase/tests/file.c +++ b/dlls/ucrtbase/tests/file.c @@ -107,7 +107,7 @@ static void test_iobuf_layout(void) fp.f = fopen(tempf, "wb"); ok(fp.f != NULL, "fopen failed with error: %d\n", errno);
- ok(!(fp.iobuf->_flag & 0x40), "fp.iobuf->_flag = %x\n", fp.iobuf->_flag); + ok(!(fp.iobuf->_flag & 0x440), "fp.iobuf->_flag = %x\n", fp.iobuf->_flag); r = fprintf(fp.f, "%s", "init"); ok(r == 4, "fprintf returned %d\n", r); ok(fp.iobuf->_flag & 0x40, "fp.iobuf->_flag = %x\n", fp.iobuf->_flag); @@ -129,6 +129,10 @@ static void test_iobuf_layout(void) ok(file_ptr == &fp.iobuf->_ptr, "_ptr = %p, expected %p\n", file_ptr, &fp.iobuf->_ptr); ok(file_cnt == &fp.iobuf->_cnt, "_cnt = %p, expected %p\n", file_cnt, &fp.iobuf->_cnt);
+ r = setvbuf(fp.f, NULL, _IONBF, 0); + ok(!r, "setvbuf returned %d\n", r); + ok(fp.iobuf->_flag & 0x400, "fp.iobuf->_flag = %x\n", fp.iobuf->_flag); + ok(TryEnterCriticalSection(&fp.iobuf->_crit), "TryEnterCriticalSection section returned FALSE\n"); LeaveCriticalSection(&fp.iobuf->_crit);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147084
Your paranoid android.
=== debian11b (64 bit WoW report) ===
ddraw: ddraw1.c:3645: Test failed: Expected (0,0)-(640,480), got (-32000,-32000)-(-31840,-31969).
secur32: schannel.c:1138: Test failed: Wrong buffer size schannel.c:1187: Test failed: InitializeSecurityContext failed: 80090304 schannel.c:1575: Test failed: got 80090304
urlmon: protocol.c:857: Test failed: szStatusText = L"text/javascript"
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000017C00EA, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032