[4/5] msvcrt: Move write flag setting code for reuse.
Grazvydas Ignotas
notasas at gmail.com
Fri Jun 13 18:23:57 CDT 2014
---
dlls/msvcrt/file.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 7523bbb..d6fb9ef 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3641,6 +3641,17 @@ MSVCRT_wchar_t * CDECL MSVCRT_fgetws(MSVCRT_wchar_t *s, int size, MSVCRT_FILE* f
return buf_start;
}
+static inline int msvcrt_set_write_direction(MSVCRT_FILE* file)
+{
+ if(!(file->_flag & MSVCRT__IOWRT)) {
+ if(file->_flag & MSVCRT__IORW)
+ file->_flag |= MSVCRT__IOWRT;
+ else
+ return MSVCRT_EOF;
+ }
+ return 0;
+}
+
/*********************************************************************
* _flsbuf (MSVCRT.@)
*/
@@ -3650,12 +3661,8 @@ int CDECL MSVCRT__flsbuf(int c, MSVCRT_FILE* file)
if(file->_bufsiz == 0 && !(file->_flag & MSVCRT__IONBF)) {
msvcrt_alloc_buffer(file);
}
- if(!(file->_flag & MSVCRT__IOWRT)) {
- if(file->_flag & MSVCRT__IORW)
- file->_flag |= MSVCRT__IOWRT;
- else
- return MSVCRT_EOF;
- }
+ if(msvcrt_set_write_direction(file) != 0)
+ return MSVCRT_EOF;
if(file->_bufsiz) {
int res = 0;
@@ -3706,12 +3713,8 @@ MSVCRT_size_t CDECL MSVCRT_fwrite(const void *ptr, MSVCRT_size_t size, MSVCRT_si
wrcnt -= pcnt;
ptr = (const char*)ptr + pcnt;
} else if(!file->_bufsiz && (file->_flag & MSVCRT__IONBF)) {
- if(!(file->_flag & MSVCRT__IOWRT)) {
- if(file->_flag & MSVCRT__IORW)
- file->_flag |= MSVCRT__IOWRT;
- else
- break;
- }
+ if(msvcrt_set_write_direction(file) != 0)
+ break;
if(MSVCRT__write(file->_file, ptr, wrcnt) <= 0) {
file->_flag |= MSVCRT__IOERR;
--
1.7.9.5
More information about the wine-patches
mailing list