From 7f713410e51d9a0836cc2f893357964681da6f6a Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Mon, 4 Apr 2016 13:39:30 -0700 Subject: [PATCH 2/2] msvcp110: Use sentry in istream<>::seekg partial revert of Sync istream<>::seekg implementations bc62a7a9dbc689006c5ed2bace9be57a69324479 older visual studios use the old behavior also clear eof bit Signed-off-by: Daniel Lehman --- dlls/msvcp90/ios.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 6b9a820..079c57b 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -8789,9 +8789,27 @@ DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12) basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir) { basic_ios_char *base = basic_istream_char_get_basic_ios(this); +#if _MSVCP_VER >= 110 + IOSB_iostate state; TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), dir); + state = ios_base_rdstate(&base->base); + ios_base_clear(&base->base, state & ~IOSTATE_eofbit); + + if(basic_istream_char_sentry_create(this, TRUE)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + fpos_int ret; + + basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in); + + if(ret.off==-1 && ret.pos==0 && ret.state==0) + basic_ios_char_setstate(base, IOSTATE_failbit); + } + basic_istream_char_sentry_destroy(this); +#else + TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), dir); + if(!ios_base_fail(&base->base)) { basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); fpos_int ret; @@ -8805,7 +8823,7 @@ basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this return this; }else basic_ios_char_clear(base, IOSTATE_goodbit); - +#endif return this; } @@ -8815,9 +8833,27 @@ DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28) basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos) { basic_ios_char *base = basic_istream_char_get_basic_ios(this); +#if _MSVCP_VER >= 110 + IOSB_iostate state; TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos)); + state = ios_base_rdstate(&base->base); + ios_base_clear(&base->base, state & ~IOSTATE_eofbit); + + if(basic_istream_char_sentry_create(this, TRUE)) { + basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); + fpos_int ret; + + basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in); + + if(ret.off==-1 && ret.pos==0 && ret.state==0) + basic_ios_char_setstate(base, IOSTATE_failbit); + } + basic_istream_char_sentry_destroy(this); +#else + TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos)); + if(!ios_base_fail(&base->base)) { basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); fpos_int ret; @@ -8831,7 +8867,7 @@ basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char return this; }else basic_ios_char_clear(base, IOSTATE_goodbit); - +#endif return this; } @@ -10328,9 +10364,27 @@ DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12) basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir) { basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this); +#if _MSVCP_VER >= 110 + IOSB_iostate state; TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), dir); + state = ios_base_rdstate(&base->base); + ios_base_clear(&base->base, state & ~IOSTATE_eofbit); + + if(basic_istream_wchar_sentry_create(this, TRUE)) { + basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base); + fpos_int ret; + + basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in); + + if(ret.off==-1 && ret.pos==0 && ret.state==0) + basic_ios_wchar_setstate(base, IOSTATE_failbit); + } + basic_istream_wchar_sentry_destroy(this); +#else + TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), dir); + if(!ios_base_fail(&base->base)) { basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base); fpos_int ret; @@ -10344,7 +10398,7 @@ basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *t return this; }else basic_ios_wchar_clear(base, IOSTATE_goodbit); - +#endif return this; } @@ -10356,9 +10410,27 @@ DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28) basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos) { basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this); +#if _MSVCP_VER >= 110 + IOSB_iostate state; TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos)); + state = ios_base_rdstate(&base->base); + ios_base_clear(&base->base, state & ~IOSTATE_eofbit); + + if(basic_istream_wchar_sentry_create(this, TRUE)) { + basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base); + fpos_int ret; + + basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in); + + if(ret.off==-1 && ret.pos==0 && ret.state==0) + basic_ios_wchar_setstate(base, IOSTATE_failbit); + } + basic_istream_wchar_sentry_destroy(this); +#else + TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos)); + if(!ios_base_fail(&base->base)) { basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base); fpos_int ret; @@ -10372,7 +10444,7 @@ basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wch return this; }else basic_ios_wchar_clear(base, IOSTATE_goodbit); - +#endif return this; } -- 1.9.5