msvcirt: Reset the pointers on file sync in most cases.
Signed-off-by: Iván Matellanes <matellanes.ivan@gmail.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e6c85e8436
commit
5101a90bca
|
@ -1126,8 +1126,8 @@ int __thiscall filebuf_sync(filebuf *this)
|
||||||
count = this->base.pptr - this->base.pbase;
|
count = this->base.pptr - this->base.pbase;
|
||||||
if (count > 0 && _write(this->fd, this->base.pbase, count) != count)
|
if (count > 0 && _write(this->fd, this->base.pbase, count) != count)
|
||||||
return EOF;
|
return EOF;
|
||||||
this->base.pbase = this->base.pptr = this->base.epptr = NULL;
|
|
||||||
}
|
}
|
||||||
|
this->base.pbase = this->base.pptr = this->base.epptr = NULL;
|
||||||
/* flush input buffer */
|
/* flush input buffer */
|
||||||
if (this->base.egptr != NULL) {
|
if (this->base.egptr != NULL) {
|
||||||
offset = this->base.egptr - this->base.gptr;
|
offset = this->base.egptr - this->base.gptr;
|
||||||
|
@ -1143,8 +1143,8 @@ int __thiscall filebuf_sync(filebuf *this)
|
||||||
if (_lseek(this->fd, -offset, SEEK_CUR) < 0)
|
if (_lseek(this->fd, -offset, SEEK_CUR) < 0)
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
this->base.eback = this->base.gptr = this->base.egptr = NULL;
|
|
||||||
}
|
}
|
||||||
|
this->base.eback = this->base.gptr = this->base.egptr = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1419,6 +1419,46 @@ static void test_filebuf(void)
|
||||||
ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
|
ok(fb1.base.gptr == NULL, "wrong get pointer, expected %p got %p\n", NULL, fb1.base.gptr);
|
||||||
ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
|
ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
|
||||||
ok(_tell(fb1.fd) == 0, "_tell failed\n");
|
ok(_tell(fb1.fd) == 0, "_tell failed\n");
|
||||||
|
fb1.base.pbase = fb1.base.pptr = fb1.base.base;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
|
||||||
|
ok(fb1.base.pptr == NULL, "wrong put pointer, expected %p got %p\n", NULL, fb1.base.pptr);
|
||||||
|
fb1.base.epptr = fb1.base.ebuf;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb1.base.epptr);
|
||||||
|
fb1.base.pbase = fb1.base.base;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
|
||||||
|
fb1.base.pbase = fb1.base.base;
|
||||||
|
fb1.base.epptr = fb1.base.ebuf;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
|
||||||
|
ok(fb1.base.epptr == NULL, "wrong put end, expected %p got %p\n", NULL, fb1.base.epptr);
|
||||||
|
fb1.base.eback = fb1.base.base;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.eback == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.eback);
|
||||||
|
fb1.base.eback = fb1.base.gptr = fb1.base.base;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.gptr == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.gptr);
|
||||||
|
fb1.base.gptr = fb1.base.base;
|
||||||
|
fb1.base.egptr = fb1.base.base + 100;
|
||||||
|
fb1.base.pbase = fb1.base.base;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
|
||||||
|
ok(fb1.base.gptr == fb1.base.base, "wrong get base, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
|
||||||
|
ok(fb1.base.egptr == fb1.base.base + 100, "wrong get base, expected %p got %p\n", fb1.base.base + 100, fb1.base.egptr);
|
||||||
|
ok(fb1.base.pbase == NULL, "wrong put base, expected %p got %p\n", NULL, fb1.base.pbase);
|
||||||
|
fb1.base.egptr = NULL;
|
||||||
|
ret = (int) call_func1(p_filebuf_sync, &fb1);
|
||||||
|
ok(ret == 0, "wrong return, expected 0 got %d\n", ret);
|
||||||
|
ok(fb1.base.gptr == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.gptr);
|
||||||
|
ok(fb1.base.egptr == NULL, "wrong get base, expected %p got %p\n", NULL, fb1.base.egptr);
|
||||||
ret = (int) call_func1(p_filebuf_sync, &fb2);
|
ret = (int) call_func1(p_filebuf_sync, &fb2);
|
||||||
ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
|
ok(ret == -1, "wrong return, expected -1 got %d\n", ret);
|
||||||
fb3.base.eback = fb3.base.base;
|
fb3.base.eback = fb3.base.base;
|
||||||
|
|
Loading…
Reference in New Issue