msvcirt: Cast to unsigned char before promotion to int.
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
69d895ac86
commit
46978629fd
|
@ -740,7 +740,7 @@ DEFINE_THISCALL_WRAPPER(streambuf_sputc, 8)
|
|||
int __thiscall streambuf_sputc(streambuf *this, int ch)
|
||||
{
|
||||
TRACE("(%p %d)\n", this, ch);
|
||||
return (this->pptr < this->epptr) ? *this->pptr++ = ch : call_streambuf_overflow(this, ch);
|
||||
return (this->pptr < this->epptr) ? (unsigned char)(*this->pptr++ = ch) : call_streambuf_overflow(this, ch);
|
||||
}
|
||||
|
||||
/* ?sgetn@streambuf@@QAEHPADH@Z */
|
||||
|
@ -773,7 +773,7 @@ int __thiscall streambuf_snextc(streambuf *this)
|
|||
if (this->gptr >= this->egptr)
|
||||
call_streambuf_underflow(this);
|
||||
this->gptr++;
|
||||
return (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
|
||||
return (this->gptr < this->egptr) ? (unsigned char)(*this->gptr) : call_streambuf_underflow(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +792,7 @@ int __thiscall streambuf_sbumpc(streambuf *this)
|
|||
if (ret == EOF)
|
||||
ret = call_streambuf_underflow(this);
|
||||
} else {
|
||||
ret = (this->gptr < this->egptr) ? *this->gptr : call_streambuf_underflow(this);
|
||||
ret = (this->gptr < this->egptr) ? (unsigned char)(*this->gptr) : call_streambuf_underflow(this);
|
||||
this->gptr++;
|
||||
}
|
||||
return ret;
|
||||
|
@ -1159,7 +1159,7 @@ int __thiscall filebuf_underflow(filebuf *this)
|
|||
TRACE("(%p)\n", this);
|
||||
|
||||
if (this->base.unbuffered)
|
||||
return (_read(this->fd, &c, 1) < 1) ? EOF : c;
|
||||
return (_read(this->fd, &c, 1) < 1) ? EOF : (unsigned char) c;
|
||||
|
||||
if (this->base.gptr >= this->base.egptr) {
|
||||
if (call_streambuf_sync(&this->base) == EOF)
|
||||
|
@ -1171,7 +1171,7 @@ int __thiscall filebuf_underflow(filebuf *this)
|
|||
this->base.eback = this->base.gptr = this->base.base;
|
||||
this->base.egptr = this->base.base + read_bytes;
|
||||
}
|
||||
return *this->base.gptr;
|
||||
return (unsigned char) *this->base.gptr;
|
||||
}
|
||||
|
||||
/* ??0strstreambuf@@QAE@ABV0@@Z */
|
||||
|
@ -1467,14 +1467,14 @@ int __thiscall strstreambuf_underflow(strstreambuf *this)
|
|||
{
|
||||
TRACE("(%p)\n", this);
|
||||
if (this->base.gptr < this->base.egptr)
|
||||
return *this->base.gptr;
|
||||
return (unsigned char) *this->base.gptr;
|
||||
/* extend the get area to include the characters written */
|
||||
if (this->base.egptr < this->base.pptr) {
|
||||
this->base.gptr = this->base.base + (this->base.gptr - this->base.eback);
|
||||
this->base.eback = this->base.base;
|
||||
this->base.egptr = this->base.pptr;
|
||||
}
|
||||
return (this->base.gptr < this->base.egptr) ? *this->base.gptr : EOF;
|
||||
return (this->base.gptr < this->base.egptr) ? (unsigned char)(*this->base.gptr) : EOF;
|
||||
}
|
||||
|
||||
/* ??0stdiobuf@@QAE@ABV0@@Z */
|
||||
|
@ -1701,7 +1701,7 @@ int __thiscall stdiobuf_underflow(stdiobuf *this)
|
|||
memmove(this->base.egptr - read_bytes, this->base.eback, read_bytes);
|
||||
this->base.gptr = this->base.egptr - read_bytes;
|
||||
}
|
||||
return *this->base.gptr++;
|
||||
return (unsigned char) *this->base.gptr++;
|
||||
}
|
||||
|
||||
/* ??0ios@@IAE@ABV0@@Z */
|
||||
|
|
|
@ -901,6 +901,18 @@ static void test_streambuf(void)
|
|||
ok(overflow_count == 0, "no call to overflow expected\n");
|
||||
ok(*sb.pbase == 'c', "expected 'c' in the put area, got %c\n", *sb.pbase);
|
||||
ok(sb.pptr == sb.pbase + 1, "wrong put pointer, expected %p got %p\n", sb.pbase + 1, sb.pptr);
|
||||
sb.pptr--;
|
||||
ret = (int) call_func2(p_streambuf_sputc, &sb, 150);
|
||||
ok(ret == 150, "wrong return value, expected 150 got %d\n", ret);
|
||||
ok(overflow_count == 0, "no call to overflow expected\n");
|
||||
ok(*sb.pbase == -106, "expected -106 in the put area, got %d\n", *sb.pbase);
|
||||
ok(sb.pptr == sb.pbase + 1, "wrong put pointer, expected %p got %p\n", sb.pbase + 1, sb.pptr);
|
||||
sb.pptr--;
|
||||
ret = (int) call_func2(p_streambuf_sputc, &sb, -50);
|
||||
ok(ret == 206, "wrong return value, expected 206 got %d\n", ret);
|
||||
ok(overflow_count == 0, "no call to overflow expected\n");
|
||||
ok(*sb.pbase == -50, "expected -50 in the put area, got %d\n", *sb.pbase);
|
||||
ok(sb.pptr == sb.pbase + 1, "wrong put pointer, expected %p got %p\n", sb.pbase + 1, sb.pptr);
|
||||
test_this = &sb2;
|
||||
ret = (int) call_func2(p_streambuf_sputc, &sb2, 'c');
|
||||
ok(ret == 'c', "wrong return value, expected 'c' got %d\n", ret);
|
||||
|
@ -996,6 +1008,10 @@ static void test_streambuf(void)
|
|||
ret = (int) call_func1(p_streambuf_snextc, &sb);
|
||||
ok(ret == 'e', "expected 'e' got '%c'\n", ret);
|
||||
ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
|
||||
*sb.gptr-- = -50;
|
||||
ret = (int) call_func1(p_streambuf_snextc, &sb);
|
||||
ok(ret == 206, "expected 206 got %d\n", ret);
|
||||
ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
|
||||
test_this = &sb2;
|
||||
ret = (int) call_func1(p_streambuf_snextc, &sb2);
|
||||
ok(ret == EOF, "expected EOF got '%c'\n", ret);
|
||||
|
@ -1043,8 +1059,12 @@ static void test_streambuf(void)
|
|||
ok(underflow_count == 49, "expected 2 calls to underflow, got %d\n", underflow_count - 47);
|
||||
|
||||
/* sbumpc */
|
||||
sb.gptr = sb.eback;
|
||||
ret = (int) call_func1(p_streambuf_sbumpc, &sb);
|
||||
ok(ret == 'e', "expected 'e' got '%c'\n", ret);
|
||||
ok(ret == 'T', "expected 'T' got '%c'\n", ret);
|
||||
ok(sb.gptr == sb.eback + 1, "wrong get pointer, expected %p got %p\n", sb.eback + 1, sb.gptr);
|
||||
ret = (int) call_func1(p_streambuf_sbumpc, &sb);
|
||||
ok(ret == 206, "expected 206 got %d\n", ret);
|
||||
ok(sb.gptr == sb.eback + 2, "wrong get pointer, expected %p got %p\n", sb.eback + 2, sb.gptr);
|
||||
test_this = &sb2;
|
||||
ret = (int) call_func1(p_streambuf_sbumpc, &sb2);
|
||||
|
@ -1477,6 +1497,11 @@ static void test_filebuf(void)
|
|||
ok(ret == 'A', "wrong return, expected 'A' got %d\n", ret);
|
||||
ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
|
||||
ok(fb1.base.pptr == fb1.base.base + 256, "wrong put pointer, expected %p got %p\n", fb1.base.base + 256, fb1.base.pptr);
|
||||
*fb1.base.gptr = -50;
|
||||
ret = (int) call_func1(p_filebuf_underflow, &fb1);
|
||||
ok(ret == 206, "wrong return, expected 206 got %d\n", ret);
|
||||
ok(fb1.base.gptr == fb1.base.base, "wrong get pointer, expected %p got %p\n", fb1.base.base, fb1.base.gptr);
|
||||
ok(fb1.base.pptr == fb1.base.base + 256, "wrong put pointer, expected %p got %p\n", fb1.base.base + 256, fb1.base.pptr);
|
||||
fb1.base.gptr = fb1.base.ebuf;
|
||||
ret = (int) call_func1(p_filebuf_underflow, &fb1);
|
||||
ok(ret == EOF, "wrong return, expected EOF got %d\n", ret);
|
||||
|
@ -1497,6 +1522,11 @@ static void test_filebuf(void)
|
|||
ok(ret == 'A', "wrong return, expected 'A' got %d\n", ret);
|
||||
ret = (int) call_func1(p_filebuf_underflow, &fb2);
|
||||
ok(ret == '\n', "wrong return, expected '\\n' got %d\n", ret);
|
||||
ok(_lseek(fb2.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
|
||||
ok(_write(fb2.fd, "\xCE\n", 2) == 2, "_write failed\n");
|
||||
ok(_lseek(fb2.fd, 0, SEEK_SET) == 0, "_lseek failed\n");
|
||||
ret = (int) call_func1(p_filebuf_underflow, &fb2);
|
||||
ok(ret == 206, "wrong return, expected 206 got %d\n", ret);
|
||||
fb2.base.do_lock = 0;
|
||||
pret = call_func1(p_filebuf_close, &fb2);
|
||||
ok(pret == &fb2, "wrong return, expected %p got %p\n", &fb2, pret);
|
||||
|
@ -1782,6 +1812,10 @@ static void test_strstreambuf(void)
|
|||
ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
|
||||
ok(ret == 'G', "expected 'G' got %d\n", ret);
|
||||
ok(ssb1.base.egptr == buffer + 25, "wrong get end, expected %p got %p\n", buffer + 25, ssb1.base.egptr);
|
||||
*ssb1.base.gptr = -50;
|
||||
ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
|
||||
ok(ret == 206, "expected 206 got %d\n", ret);
|
||||
ok(ssb1.base.egptr == buffer + 25, "wrong get end, expected %p got %p\n", buffer + 25, ssb1.base.egptr);
|
||||
ssb1.base.gptr = ssb1.base.egptr = ssb1.base.pptr = ssb1.base.epptr;
|
||||
ret = (int) call_func1(p_strstreambuf_underflow, &ssb1);
|
||||
ok(ret == EOF, "expected EOF got %d\n", ret);
|
||||
|
@ -1811,8 +1845,9 @@ static void test_strstreambuf(void)
|
|||
ssb2.base.eback = ssb2.base.egptr = ssb2.base.base + 1;
|
||||
ssb2.base.gptr = ssb2.base.base + 3;
|
||||
ssb2.base.pptr = ssb2.base.base + 5;
|
||||
*(ssb2.base.base + 2) = -50;
|
||||
ret = (int) call_func1(p_strstreambuf_underflow, &ssb2);
|
||||
ok(ret == 'e', "expected 'e' got %d\n", ret);
|
||||
ok(ret == 206, "expected 206 got %d\n", ret);
|
||||
ok(ssb2.base.eback == ssb2.base.base, "wrong get base, expected %p got %p\n", ssb2.base.base, ssb2.base.eback);
|
||||
ok(ssb2.base.gptr == ssb2.base.base + 2, "wrong get pointer, expected %p got %p\n", ssb2.base.base, ssb2.base.gptr);
|
||||
ok(ssb2.base.egptr == ssb2.base.base + 5, "wrong get end, expected %p got %p\n", ssb2.base.base + 5, ssb2.base.egptr);
|
||||
|
@ -2115,6 +2150,10 @@ static void test_stdiobuf(void)
|
|||
ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
|
||||
ok(ret == 'v', "expected 'v' got %d\n", ret);
|
||||
ok(stb1.base.gptr == stb1.base.egptr - 46, "wrong get pointer, expected %p got %p\n", stb1.base.egptr - 46, stb1.base.gptr);
|
||||
*stb1.base.gptr = -50;
|
||||
ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
|
||||
ok(ret == 206, "expected 206 got %d\n", ret);
|
||||
ok(stb1.base.gptr == stb1.base.egptr - 45, "wrong get pointer, expected %p got %p\n", stb1.base.egptr - 45, stb1.base.gptr);
|
||||
stb1.base.gptr = stb1.base.egptr;
|
||||
ret = (int) call_func1(p_stdiobuf_underflow, &stb1);
|
||||
ok(ret == EOF, "expected EOF got %d\n", ret);
|
||||
|
|
Loading…
Reference in New Issue