Match COutputStream::DoPut (Thanks HeartPiece!)

This commit is contained in:
Phillip Stephens 2022-10-11 21:44:08 -07:00
parent 08e0d97ba3
commit 26d6394bb1
4 changed files with 27 additions and 24 deletions

View File

@ -883,7 +883,7 @@ LIBS = [
"Runtime/e_pow",
["Runtime/e_rem_pio2", True],
["Runtime/k_cos", True],
"Runtime/k_rem_pio2",
["Runtime/k_rem_pio2", True],
["Runtime/k_sin", True],
["Runtime/k_tan", True],
"Runtime/s_atan",

View File

@ -760,7 +760,7 @@ MSL_COMMON_MATH :=\
$(BUILD_DIR)/asm/Runtime/e_pow.o\
$(BUILD_DIR)/src/Runtime/e_rem_pio2.o\
$(BUILD_DIR)/src/Runtime/k_cos.o\
$(BUILD_DIR)/asm/Runtime/k_rem_pio2.o\
$(BUILD_DIR)/src/Runtime/k_rem_pio2.o\
$(BUILD_DIR)/src/Runtime/k_sin.o\
$(BUILD_DIR)/src/Runtime/k_tan.o\
$(BUILD_DIR)/asm/Runtime/s_atan.o\

View File

@ -21,28 +21,32 @@ COutputStream::~COutputStream() {
}
void COutputStream::DoPut(const void* ptr, size_t len) {
if (len == 0) {
return;
}
mNumWrites += len;
if (mBufLen <= len + mUnwrittenLen) {
memcpy((uchar*)mBufPtr + mUnwrittenLen, ptr, len);
mUnwrittenLen += len;
return;
}
while (len != 0) {
uint count = mBufLen - mUnwrittenLen;
uint offset = len;
if (count < len) {
len = count;
uint offset;
uchar* offsetPtr;
uint tempLen = len;
if (tempLen != 0) {
mNumWrites += tempLen;
if (tempLen + mUnwrittenLen <= mBufLen) {
memcpy((uchar*)mBufPtr + mUnwrittenLen, ptr, tempLen);
mUnwrittenLen += tempLen;
return;
}
if (count != 0) {
memcpy((uchar*)mBufPtr + mUnwrittenLen, (uchar*)ptr + offset, len);
mUnwrittenLen += len;
len -= len;
} else {
DoFlush();
offsetPtr = (uchar*)ptr + tempLen;
while (tempLen != 0) {
uint count = mBufLen - mUnwrittenLen;
offset = count;
if (tempLen < count) {
offset = tempLen;
}
if (offset != 0) {
memcpy((uchar*)mBufPtr + mUnwrittenLen, (offsetPtr - tempLen), offset);
tempLen -= offset;
mUnwrittenLen += offset;
} else {
DoFlush();
}
}
}
}

View File

@ -56,7 +56,6 @@
*/
#include "fdlibm.h"
#ifdef __STDC__
static const double
#else