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_pow",
["Runtime/e_rem_pio2", True], ["Runtime/e_rem_pio2", True],
["Runtime/k_cos", True], ["Runtime/k_cos", True],
"Runtime/k_rem_pio2", ["Runtime/k_rem_pio2", True],
["Runtime/k_sin", True], ["Runtime/k_sin", True],
["Runtime/k_tan", True], ["Runtime/k_tan", True],
"Runtime/s_atan", "Runtime/s_atan",

View File

@ -760,7 +760,7 @@ MSL_COMMON_MATH :=\
$(BUILD_DIR)/asm/Runtime/e_pow.o\ $(BUILD_DIR)/asm/Runtime/e_pow.o\
$(BUILD_DIR)/src/Runtime/e_rem_pio2.o\ $(BUILD_DIR)/src/Runtime/e_rem_pio2.o\
$(BUILD_DIR)/src/Runtime/k_cos.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_sin.o\
$(BUILD_DIR)/src/Runtime/k_tan.o\ $(BUILD_DIR)/src/Runtime/k_tan.o\
$(BUILD_DIR)/asm/Runtime/s_atan.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) { void COutputStream::DoPut(const void* ptr, size_t len) {
if (len == 0) { uint offset;
return; uchar* offsetPtr;
} uint tempLen = len;
if (tempLen != 0) {
mNumWrites += len; mNumWrites += tempLen;
if (mBufLen <= len + mUnwrittenLen) { if (tempLen + mUnwrittenLen <= mBufLen) {
memcpy((uchar*)mBufPtr + mUnwrittenLen, ptr, len); memcpy((uchar*)mBufPtr + mUnwrittenLen, ptr, tempLen);
mUnwrittenLen += len; mUnwrittenLen += tempLen;
return; return;
}
while (len != 0) {
uint count = mBufLen - mUnwrittenLen;
uint offset = len;
if (count < len) {
len = count;
} }
if (count != 0) {
memcpy((uchar*)mBufPtr + mUnwrittenLen, (uchar*)ptr + offset, len); offsetPtr = (uchar*)ptr + tempLen;
mUnwrittenLen += len; while (tempLen != 0) {
len -= len; uint count = mBufLen - mUnwrittenLen;
} else { offset = count;
DoFlush(); 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" #include "fdlibm.h"
#ifdef __STDC__ #ifdef __STDC__
static const double static const double
#else #else