msvcp110: Use sentry in istream<>::seekg.

Signed-off-by: Daniel Lehman <dlehman@esri.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Daniel Lehman 2016-04-04 13:39:30 -07:00 committed by Alexandre Julliard
parent 3888aa4d8d
commit b04b7e2480
1 changed files with 76 additions and 4 deletions

View File

@ -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_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); 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); 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)) { if(!ios_base_fail(&base->base)) {
basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
fpos_int ret; fpos_int ret;
@ -8805,7 +8823,7 @@ basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this
return this; return this;
}else }else
basic_ios_char_clear(base, IOSTATE_goodbit); basic_ios_char_clear(base, IOSTATE_goodbit);
#endif
return this; 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_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); 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)); 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)) { if(!ios_base_fail(&base->base)) {
basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base); basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
fpos_int ret; fpos_int ret;
@ -8831,7 +8867,7 @@ basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char
return this; return this;
}else }else
basic_ios_char_clear(base, IOSTATE_goodbit); basic_ios_char_clear(base, IOSTATE_goodbit);
#endif
return this; 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_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); 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); 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)) { if(!ios_base_fail(&base->base)) {
basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base); basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
fpos_int ret; fpos_int ret;
@ -10344,7 +10398,7 @@ basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *t
return this; return this;
}else }else
basic_ios_wchar_clear(base, IOSTATE_goodbit); basic_ios_wchar_clear(base, IOSTATE_goodbit);
#endif
return this; 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_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); 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)); 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)) { if(!ios_base_fail(&base->base)) {
basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base); basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
fpos_int ret; fpos_int ret;
@ -10372,7 +10444,7 @@ basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wch
return this; return this;
}else }else
basic_ios_wchar_clear(base, IOSTATE_goodbit); basic_ios_wchar_clear(base, IOSTATE_goodbit);
#endif
return this; return this;
} }