Compare commits
1 Commits
cleanup/se
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b75eece02 |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 85.98% | 76.01% | 56.92% | 86.74% |
|
||||
| 85.99% | 76.05% | 56.92% | 86.74% |
|
||||
|
||||
units 752/1027 complete, functions 11082/12563 matched.
|
||||
units 752/1027 complete, functions 11085/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
@@ -238,9 +238,10 @@ static NWC24Err QDecode(char* decoded, u32 decodedCapacity, u32* decodedSize, ch
|
||||
u32 value = 0;
|
||||
NWC24Err result = NWC24_OK;
|
||||
|
||||
if (decoded == NULL || encoded == NULL) {
|
||||
if (decoded == NULL)
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
if (encoded == NULL)
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
if (decodedCapacity == 0) {
|
||||
return NWC24_ERR_OVERFLOW;
|
||||
}
|
||||
@@ -370,10 +371,10 @@ static NWC24Err EncodeWord(char* encoded, u32 encodedCapacity, u32* encodedSize,
|
||||
}
|
||||
}
|
||||
if (result == NWC24_OK) {
|
||||
char value[1];
|
||||
value[0] = encoding;
|
||||
if (encoding == 'B' || encoding == 'b' || encoding == 'Q' || encoding == 'q') {
|
||||
char value[1];
|
||||
u32 length = Mail_strlen(encoded);
|
||||
value[0] = encoding;
|
||||
if (length + 1 < encodedCapacity) {
|
||||
Mail_strncat(encoded, value, 1);
|
||||
} else {
|
||||
@@ -502,12 +503,23 @@ static BOOL CopyWithoutLinearWhiteSpaces(char* output, int* outputSize, char* in
|
||||
return inputSize == 0 || *input == '\0';
|
||||
}
|
||||
|
||||
static inline char* FindMarker(char* input, u32 size, const char* marker) {
|
||||
u32 markerLength = Mail_strlen(marker);
|
||||
u32 offset;
|
||||
for (offset = 0; offset <= size; offset++) {
|
||||
char* current = input + offset;
|
||||
if (Mail_strncmp(current, marker, markerLength) == 0)
|
||||
return current;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static NWC24Err DecodeWord(char* charsetData, u32 charsetCapacity, char* decoded, u32 decodedCapacity, u32* decodedSize, char* encoded,
|
||||
u32 encodedSize, u32* encodedSizeOut) {
|
||||
int encodedWordPosition = 0;
|
||||
int encodedLength;
|
||||
u32 decodedLength;
|
||||
u32 consumedSize;
|
||||
u32 decodedLength;
|
||||
NWC24Err result = NWC24_OK;
|
||||
|
||||
if (encodedSizeOut != NULL) {
|
||||
@@ -579,9 +591,7 @@ static NWC24Err DecodeWord(char* charsetData, u32 charsetCapacity, char* decoded
|
||||
encodedLength = encodedWordPosition - (int)encoded;
|
||||
}
|
||||
if (!CopyWithoutLinearWhiteSpaces(decoded, (int*)&localSize, encoded, encodedLength)) {
|
||||
if (decodedSize != NULL) {
|
||||
*decodedSize = localSize;
|
||||
}
|
||||
*decodedSize = localSize;
|
||||
if (encodedSizeOut != NULL) {
|
||||
*encodedSizeOut = encodedLength;
|
||||
}
|
||||
@@ -616,7 +626,7 @@ NWC24Err NWC24DecodeMIMEHeaderFieldBody(u8* charsetData, u32 charsetDataSize, u8
|
||||
u32 encodedSize) {
|
||||
int result = 0;
|
||||
u8* output;
|
||||
u32 inputSize = encodedSize;
|
||||
u32 inputSize;
|
||||
|
||||
if (decodedSize == NULL) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
@@ -634,6 +644,7 @@ NWC24Err NWC24DecodeMIMEHeaderFieldBody(u8* charsetData, u32 charsetDataSize, u8
|
||||
*decoded = 0;
|
||||
*charsetData = 0;
|
||||
*decodedSize = 1;
|
||||
inputSize = encodedSize;
|
||||
output = decoded;
|
||||
while ((s32)inputSize > 0 && (s32)decodedCapacity > 0 && *encoded != '\0') {
|
||||
u32 copiedSize = 0;
|
||||
@@ -666,61 +677,46 @@ static NWC24Err ConcatEncodedText(char* encoded, u32 encodedCapacity, u32* encod
|
||||
int available = encodedCapacity - prefixSize - 2;
|
||||
NWC24Err result;
|
||||
|
||||
if (available <= 0) {
|
||||
return NWC24_ERR_OVERFLOW;
|
||||
}
|
||||
if (encoding == 'B' || encoding == 'b') {
|
||||
result = Base64Encode(decoded, decodedSize, decodedSizeOut, (u8*)encoded + prefixSize, (u32)(available - 1), encodedSize);
|
||||
} else if (encoding == 'Q' || encoding == 'q') {
|
||||
result = QEncode(encoded + prefixSize, (u32)(available - 1), encodedSize, decoded, decodedSize, decodedSizeOut, 1);
|
||||
if (available > 0) {
|
||||
if (encoding == 'B' || encoding == 'b') {
|
||||
result = Base64Encode(decoded, decodedSize, decodedSizeOut, (u8*)encoded + prefixSize, (u32)(available - 1), encodedSize);
|
||||
} else if (encoding == 'Q' || encoding == 'q') {
|
||||
result = QEncode(encoded + prefixSize, (u32)(available - 1), encodedSize, decoded, decodedSize, decodedSizeOut, 1);
|
||||
} else {
|
||||
result = NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
if (result == NWC24_OK || result == NWC24_ERR_OVERFLOW) {
|
||||
encoded[prefixSize + *encodedSize] = '\0';
|
||||
*encodedSize += 1;
|
||||
}
|
||||
} else {
|
||||
result = NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
if (result == NWC24_OK || result == NWC24_ERR_OVERFLOW) {
|
||||
encoded[prefixSize + *encodedSize] = '\0';
|
||||
*encodedSize += 1;
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static NWC24Err ExtractCharset(char* charset, u32 charsetCapacity, u32* charsetSize, char* encoded, u32 encodedSize) {
|
||||
u32 markerLength;
|
||||
u32 offset;
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
char* start;
|
||||
char* end;
|
||||
u32 charsetLength;
|
||||
|
||||
if (charset == NULL) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
markerLength = Mail_strlen("=?");
|
||||
for (offset = 0; offset <= encodedSize; offset++) {
|
||||
int current = (int)(encoded + offset);
|
||||
if (Mail_strncmp((char*)current, "=?", markerLength) == 0) {
|
||||
start = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start == 0) {
|
||||
start = FindMarker(encoded, encodedSize, "=?");
|
||||
if (start == NULL) {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
markerLength = Mail_strlen("?");
|
||||
start += 2;
|
||||
for (offset = 0; offset <= encodedSize - (u32)(start - (int)encoded); offset++) {
|
||||
int current = start + offset;
|
||||
if (Mail_strncmp((char*)current, "?", markerLength) == 0) {
|
||||
end = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (end == 0) {
|
||||
end = FindMarker(start, encodedSize - (u32)(start - encoded), "?");
|
||||
if (end == NULL) {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
charsetLength = (u32)(end - start);
|
||||
if (charsetLength >= charsetCapacity) {
|
||||
return NWC24_ERR_OVERFLOW;
|
||||
}
|
||||
Mail_strncpy(charset, (char*)start, charsetLength);
|
||||
Mail_strncpy(charset, start, charsetLength);
|
||||
charset[charsetLength] = '\0';
|
||||
*charsetSize = charsetLength + 2;
|
||||
return NWC24_OK;
|
||||
@@ -728,10 +724,8 @@ static NWC24Err ExtractCharset(char* charset, u32 charsetCapacity, u32* charsetS
|
||||
|
||||
static NWC24Err ExtractEncodedText(char* decoded, u32 decodedCapacity, u32* decodedSize, char encoding, char* encoded, u32 encodedSize,
|
||||
u32* encodedSizeOut) {
|
||||
u32 markerLength;
|
||||
u32 offset;
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
char* start;
|
||||
char* end;
|
||||
int length;
|
||||
NWC24Err result;
|
||||
|
||||
@@ -743,27 +737,13 @@ static NWC24Err ExtractEncodedText(char* decoded, u32 decodedCapacity, u32* deco
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
*encodedSizeOut = 0;
|
||||
markerLength = Mail_strlen("?");
|
||||
for (offset = 0; offset <= encodedSize; offset++) {
|
||||
int current = (int)(encoded + offset);
|
||||
if (Mail_strncmp((char*)current, "?", markerLength) == 0) {
|
||||
start = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start == 0) {
|
||||
start = FindMarker(encoded, encodedSize, "?");
|
||||
if (start == NULL) {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
markerLength = Mail_strlen("?=");
|
||||
start++;
|
||||
for (offset = 0; offset <= encodedSize - (u32)(start - (int)encoded); offset++) {
|
||||
int current = start + offset;
|
||||
if (Mail_strncmp((char*)current, "?=", markerLength) == 0) {
|
||||
end = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (end == 0) {
|
||||
end = FindMarker(start, encodedSize - (u32)(start - encoded), "?=");
|
||||
if (end == NULL) {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
length = end - start;
|
||||
@@ -774,7 +754,7 @@ static NWC24Err ExtractEncodedText(char* decoded, u32 decodedCapacity, u32* deco
|
||||
*decodedSize += 1;
|
||||
}
|
||||
} else if (encoding == 'Q' || encoding == 'q') {
|
||||
result = QDecode(decoded, decodedCapacity - 1, decodedSize, (char*)start, length, NULL, 1);
|
||||
result = QDecode(decoded, decodedCapacity - 1, decodedSize, start, length, NULL, 1);
|
||||
if (result == NWC24_OK || result == NWC24_ERR_OVERFLOW) {
|
||||
decoded[*decodedSize] = '\0';
|
||||
*decodedSize += 1;
|
||||
@@ -782,6 +762,6 @@ static NWC24Err ExtractEncodedText(char* decoded, u32 decodedCapacity, u32* deco
|
||||
} else {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
*encodedSizeOut = (u32)(end - (int)encoded) + 2;
|
||||
*encodedSizeOut = (u32)(end - encoded) + 2;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -278,8 +278,11 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
subjectWork = work + textWorkSize;
|
||||
textSourceSize = textSize;
|
||||
result = NWC24iConvertFromInternalEncoding(work, &textWorkSize, text, &textSourceSize, nwcWork->stringWork, 0x40, region, alternative);
|
||||
if (result != NWC24_OK) {
|
||||
goto done;
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
default:
|
||||
goto done;
|
||||
}
|
||||
|
||||
result = ENCIs7BitEncoding(&is7Bit, nwcWork->stringWork);
|
||||
@@ -304,8 +307,11 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
result = 0;
|
||||
}
|
||||
result = NWC24SetMsgText(msg, (char*)work, textWorkSize - 1, charset, result);
|
||||
if (result != NWC24_OK) {
|
||||
goto done;
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
default:
|
||||
goto done;
|
||||
}
|
||||
if (charset == 0) {
|
||||
result = NWC24iSetMsgSubjectPlain(msg, subject, subjectSize, region, alternative, subjectWork, subjectWorkSize, charset, nwcWork->stringWork);
|
||||
@@ -320,8 +326,6 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
result = 3;
|
||||
break;
|
||||
case 3:
|
||||
result = 2;
|
||||
break;
|
||||
case 4:
|
||||
result = 2;
|
||||
break;
|
||||
@@ -542,70 +546,74 @@ done:
|
||||
|
||||
NWC24Err NWC24iDetectEncodingToSend(char* charset, u32 charsetSize, const u16* subject, u32 subjectSize, const u16* text, u32 textSize,
|
||||
NWC24EncodingRegion region) {
|
||||
int endIndex;
|
||||
u32 subjectBytes;
|
||||
u32 textBytes;
|
||||
int startIndex;
|
||||
int lastIndex;
|
||||
int index;
|
||||
const char** names;
|
||||
int numNames;
|
||||
int index;
|
||||
int lastIndex;
|
||||
int endIndex;
|
||||
int startIndex;
|
||||
int subjectIndex;
|
||||
int result;
|
||||
|
||||
index = 0;
|
||||
startIndex = 0;
|
||||
lastIndex = -1;
|
||||
if (region == 3) {
|
||||
names = KoreanCharsets;
|
||||
numNames = 3;
|
||||
} else if (region < 3) {
|
||||
if (region == 0) {
|
||||
switch (region) {
|
||||
case 0:
|
||||
names = JapaneseCharsets;
|
||||
numNames = 3;
|
||||
} else if (region >= 0) {
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
names = WesternCharsets;
|
||||
numNames = 8;
|
||||
} else {
|
||||
break;
|
||||
case 3:
|
||||
names = KoreanCharsets;
|
||||
numNames = 3;
|
||||
break;
|
||||
case 4:
|
||||
names = ChineseCharsets;
|
||||
numNames = 2;
|
||||
break;
|
||||
default:
|
||||
names = WesternCharsets;
|
||||
numNames = 8;
|
||||
}
|
||||
} else if (region < 5) {
|
||||
names = ChineseCharsets;
|
||||
numNames = 2;
|
||||
} else {
|
||||
names = WesternCharsets;
|
||||
numNames = 8;
|
||||
break;
|
||||
}
|
||||
subjectBytes = subjectSize << 1;
|
||||
textBytes = textSize << 1;
|
||||
endIndex = numNames - 1;
|
||||
startIndex = 0;
|
||||
do {
|
||||
subjectIndex = index;
|
||||
if (endIndex <= index) {
|
||||
break;
|
||||
}
|
||||
result = ENCCheckEncoding(&index, names + startIndex, endIndex - startIndex, subject, subjectSize << 1);
|
||||
while (index < endIndex) {
|
||||
result = ENCCheckEncoding(&index, names + startIndex, endIndex - startIndex, subject, subjectBytes);
|
||||
if (result != ENC_OK) {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
if (index == ENC_CHECK_ENCODING_NOT_FOUND) {
|
||||
subjectIndex = numNames - 1;
|
||||
index = numNames - 1;
|
||||
break;
|
||||
}
|
||||
subjectIndex = startIndex + index;
|
||||
if ((text == NULL) || (lastIndex == subjectIndex)) {
|
||||
startIndex += index;
|
||||
if ((text == NULL) || (lastIndex == startIndex)) {
|
||||
index = startIndex;
|
||||
break;
|
||||
}
|
||||
lastIndex = subjectIndex;
|
||||
result = ENCCheckEncoding(&index, names + subjectIndex, endIndex - subjectIndex, text, textSize << 1);
|
||||
result = ENCCheckEncoding(&index, names + startIndex, endIndex - startIndex, text, textBytes);
|
||||
if (result != ENC_OK) {
|
||||
return NWC24_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
if (index == ENC_CHECK_ENCODING_NOT_FOUND) {
|
||||
subjectIndex = numNames - 1;
|
||||
index = numNames - 1;
|
||||
break;
|
||||
}
|
||||
lastIndex = startIndex + index;
|
||||
if (lastIndex == startIndex) {
|
||||
index = lastIndex;
|
||||
break;
|
||||
}
|
||||
lastIndex = subjectIndex + index;
|
||||
startIndex = lastIndex;
|
||||
} while (lastIndex != subjectIndex);
|
||||
index = subjectIndex;
|
||||
}
|
||||
strncpy(charset, names[index], charsetSize - 1);
|
||||
charset[charsetSize - 1] = '\0';
|
||||
return NWC24_OK;
|
||||
@@ -669,57 +677,62 @@ NWC24Err NWC24iSetMsgSubjectPlain(NWC24MsgObj* msg, const u16* subject, u32 subj
|
||||
u32 workSize, NWC24Charset charset, char* charsetName) {
|
||||
u32 workHalf;
|
||||
u32 secondSize;
|
||||
u32 sourceOffset;
|
||||
u8* second;
|
||||
u32 subjectLength;
|
||||
u32 lineLength;
|
||||
u32 sourceOffset;
|
||||
s32 copied;
|
||||
u32 i;
|
||||
NWC24Err result;
|
||||
|
||||
workHalf = workSize >> 1;
|
||||
secondSize = workSize - workHalf;
|
||||
second = work + workHalf;
|
||||
secondSize = workSize - (workSize >> 1);
|
||||
second = work + (workSize >> 1);
|
||||
subjectLength = subjectSize;
|
||||
lineLength = 0;
|
||||
workHalf = workSize >> 1;
|
||||
result = NWC24iConvertFromInternalEncoding(work, &workHalf, subject, &subjectLength, charsetName, 0x40, region, alternative);
|
||||
if (result == NWC24_OK) {
|
||||
subjectLength = workHalf - 1;
|
||||
for (i = 0; i < workHalf; i++) {
|
||||
if ((work[i] == '\n') || (work[i] == '\r')) {
|
||||
work[i] = ' ';
|
||||
switch (result) {
|
||||
default:
|
||||
goto done;
|
||||
case NWC24_OK:
|
||||
subjectLength = workHalf - 1;
|
||||
for (i = 0; i < workHalf; i++) {
|
||||
if ((work[i] == '\n') || (work[i] == '\r')) {
|
||||
work[i] = ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work, subjectLength, 0x3F);
|
||||
if (lineLength == subjectLength) {
|
||||
result = NWC24SetMsgSubject(msg, (char*)work, subjectLength);
|
||||
} else if (lineLength < secondSize) {
|
||||
copied = NWC24iStrLCpy((char*)second, (char*)work, lineLength + 1);
|
||||
workHalf = secondSize;
|
||||
for (sourceOffset = lineLength; sourceOffset < subjectLength; sourceOffset += lineLength) {
|
||||
if (workHalf - copied < 3) {
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work, subjectLength, 0x3F);
|
||||
if (lineLength == subjectLength) {
|
||||
result = NWC24SetMsgSubject(msg, (char*)work, subjectLength);
|
||||
} else {
|
||||
workHalf = secondSize;
|
||||
sourceOffset = lineLength;
|
||||
if (workHalf <= sourceOffset) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
second[copied] = '\r';
|
||||
second[copied + 1] = '\n';
|
||||
copied += 2;
|
||||
if (work[sourceOffset] != ' ') {
|
||||
second[copied] = ' ';
|
||||
copied++;
|
||||
copied = NWC24iStrLCpy((char*)second, (char*)work, lineLength + 1);
|
||||
for (; sourceOffset < subjectLength; sourceOffset += lineLength) {
|
||||
if (workHalf - copied < 3) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
second[copied++] = '\r';
|
||||
second[copied++] = '\n';
|
||||
if (work[sourceOffset] != ' ') {
|
||||
second[copied] = ' ';
|
||||
copied++;
|
||||
}
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work + sourceOffset, subjectLength - sourceOffset, 0x47);
|
||||
if (workHalf - copied <= lineLength) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
copied += NWC24iStrLCpy((char*)second + copied, (char*)work + sourceOffset, lineLength + 1);
|
||||
}
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work + sourceOffset, subjectLength - sourceOffset, 0x47);
|
||||
if (workHalf - copied <= lineLength) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
copied += NWC24iStrLCpy((char*)second + copied, (char*)work + sourceOffset, lineLength + 1);
|
||||
second[copied] = 0;
|
||||
result = NWC24SetMsgSubject(msg, (char*)second, copied);
|
||||
}
|
||||
second[copied] = 0;
|
||||
result = NWC24SetMsgSubject(msg, (char*)second, copied);
|
||||
} else {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
@@ -729,63 +742,72 @@ done:
|
||||
NWC24Err NWC24iSetMsgSubjectQP(NWC24MsgObj* msg, const u16* subject, u32 subjectSize, NWC24EncodingRegion region, u16 alternative, u8* work,
|
||||
u32 workSize, NWC24Charset charset, char* charsetName) {
|
||||
u32 workHalf;
|
||||
u32 sourceOffset;
|
||||
u32 secondSize;
|
||||
u8* second;
|
||||
u32 subjectLength;
|
||||
u32 lineLength;
|
||||
u32 outputLength;
|
||||
u32 sourceOffset;
|
||||
u32 nextOutput;
|
||||
u32 total;
|
||||
u32 combinedLength;
|
||||
u32 i;
|
||||
u32 charsetLength;
|
||||
NWC24Err result;
|
||||
|
||||
workHalf = workSize >> 1;
|
||||
secondSize = workSize - workHalf;
|
||||
second = work + workHalf;
|
||||
secondSize = workSize - (workSize >> 1);
|
||||
second = work + (workSize >> 1);
|
||||
subjectLength = subjectSize;
|
||||
lineLength = 0;
|
||||
workHalf = workSize >> 1;
|
||||
result = NWC24iConvertFromInternalEncoding(work, &workHalf, subject, &subjectLength, charsetName, 0x40, region, alternative);
|
||||
if (result == NWC24_OK) {
|
||||
subjectLength = workHalf - 1;
|
||||
for (i = 0; i < workHalf; i++) {
|
||||
if ((work[i] == '\n') || (work[i] == '\r')) {
|
||||
work[i] = ' ';
|
||||
}
|
||||
}
|
||||
charsetLength = strlen(charsetName);
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work, subjectLength, (0x38 - charsetLength) / 3);
|
||||
result = NWC24EncodeWord(second, secondSize, &outputLength, charsetName, 0x40, 'Q', work, lineLength);
|
||||
sourceOffset = lineLength;
|
||||
if (result == NWC24_OK) {
|
||||
if (lineLength == subjectLength) {
|
||||
result = NWC24SetMsgSubject(msg, (char*)second, outputLength - 1);
|
||||
} else {
|
||||
charsetLength = strlen(charsetName);
|
||||
total = outputLength;
|
||||
workHalf = secondSize;
|
||||
for (; sourceOffset < subjectLength; sourceOffset += lineLength) {
|
||||
nextOutput = total - 1;
|
||||
if (workHalf - nextOutput < 3) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
second[nextOutput] = '\r';
|
||||
second[total] = '\n';
|
||||
second[total + 1] = ' ';
|
||||
total += 2;
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work + sourceOffset, subjectLength - sourceOffset, (0x40 - charsetLength) / 3);
|
||||
result =
|
||||
NWC24EncodeWord(second + total, workHalf - total, &outputLength, charsetName, 0x40, 'Q', work + sourceOffset, lineLength);
|
||||
if (result != NWC24_OK) {
|
||||
goto done;
|
||||
}
|
||||
total += outputLength;
|
||||
switch (result) {
|
||||
default:
|
||||
goto done;
|
||||
case NWC24_OK:
|
||||
subjectLength = workHalf - 1;
|
||||
for (i = 0; i < workHalf; i++) {
|
||||
if ((work[i] == '\n') || (work[i] == '\r')) {
|
||||
work[i] = ' ';
|
||||
}
|
||||
result = NWC24SetMsgSubject(msg, (char*)second, total - 1);
|
||||
}
|
||||
}
|
||||
charsetLength = strlen(charsetName);
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work, subjectLength, (0x38 - charsetLength) / 3);
|
||||
result = NWC24EncodeWord(second, secondSize, &outputLength, charsetName, 0x40, 'Q', work, lineLength);
|
||||
switch (result) {
|
||||
default:
|
||||
goto done;
|
||||
case NWC24_OK:
|
||||
sourceOffset = lineLength;
|
||||
if (lineLength == subjectLength) {
|
||||
result = NWC24SetMsgSubject(msg, (char*)second, outputLength - 1);
|
||||
} else {
|
||||
charsetLength = (0x40 - strlen(charsetName)) / 3;
|
||||
total = outputLength - 1;
|
||||
workHalf = secondSize;
|
||||
for (; sourceOffset < subjectLength;) {
|
||||
if (workHalf - total < 3) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
second[total++] = '\r';
|
||||
second[total++] = '\n';
|
||||
second[total++] = ' ';
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work + sourceOffset, subjectLength - sourceOffset, charsetLength);
|
||||
result = NWC24EncodeWord(second + total, workHalf - total, &outputLength, charsetName, 0x40, 'Q', work + sourceOffset,
|
||||
lineLength);
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
default:
|
||||
goto done;
|
||||
}
|
||||
combinedLength = total + outputLength;
|
||||
sourceOffset += lineLength;
|
||||
total = combinedLength - 1;
|
||||
}
|
||||
result = NWC24SetMsgSubject(msg, (char*)second, total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
@@ -75,3 +75,55 @@ Combination of moving QDecode cursor initialization and sequential nibble
|
||||
conversion gives 86.54794%. Combining bounded MIME-header scanning, independent
|
||||
input validation and decoder-owned consumed count gives 86.03261%.
|
||||
No other unit or shared header was changed.
|
||||
|
||||
## Continuation 2026-09-30
|
||||
|
||||
Baseline: 8/16 exact functions; 2240/6124 code bytes; 88/88 data bytes.
|
||||
|
||||
CopyWithoutLinearWhiteSpaces | signed output count with unsigned bound comparison | (98.561646, -17) | src 0x124 base 0x124 insns 73/73
|
||||
CopyWithoutLinearWhiteSpaces | declare capacity before newline state | (98.561646, -17) | src 0x124 base 0x124 insns 73/73
|
||||
CopyWithoutLinearWhiteSpaces | for scan with advancing input in iteration expression | (98.561646, -17) | src 0x124 base 0x124 insns 73/73
|
||||
CopyWithoutLinearWhiteSpaces | signed output-size count with character declared early | (98.561646, -17) | src 0x124 base 0x124 insns 73/73
|
||||
ConcatEncodedText | defer result before remaining-byte count | (93.492065, -41) | src 0xfc base 0xfc insns 63/63
|
||||
ConcatEncodedText | unsigned available-byte count with signed exhaustion check | (93.492065, -41) | src 0xfc base 0xfc insns 63/63
|
||||
ConcatEncodedText | increment encoded size before terminator store | (91.42857, -41) | src 0xfc base 0xfc insns 63/63
|
||||
ConcatEncodedText | positive capacity body before overflow case | (100.0, 0) | src 0xfc base 0xfc insns 63/63
|
||||
ExtractEncodedText | inline marker search with pointer-valued results | (91.25926, -9999) | src 0x208 base 0x21c insns 130/135
|
||||
ExtractEncodedText | independent invalid pointer checks | (86.85185, -9999) | src 0x20c base 0x21c insns 131/135
|
||||
ExtractEncodedText | cache encoded-word span before decoding | (84.36296, -9999) | src 0x204 base 0x21c insns 129/135
|
||||
QDecode | separate null input and output checks | (87.60959, -9999) | src 0x238 base 0x248 insns 142/146
|
||||
QDecode | unsigned nibble values | (86.54794, -9999) | src 0x230 base 0x248 insns 140/146
|
||||
QDecode | reverse valid-nibble conjunction | (86.58219, -9999) | src 0x230 base 0x248 insns 140/146
|
||||
NWC24DecodeMIMEHeaderFieldBody | late input count initialization | (88.36957, -9999) | src 0x17c base 0x170 insns 95/92
|
||||
NWC24DecodeMIMEHeaderFieldBody | use signed remaining count and final test | (86.08696, -9999) | src 0x17c base 0x170 insns 95/92
|
||||
NWC24DecodeMIMEHeaderFieldBody | fold error status into loop continuation | (83.58696, -9999) | src 0x17c base 0x170 insns 95/92
|
||||
DecodeWord | pointer scan for inter-word whitespace | (77.26111, -161) | src 0x2d0 base 0x2d0 insns 180/180
|
||||
DecodeWord | permissive output size updated unconditionally on copy failure | (78.833336, -9999) | src 0x2c8 base 0x2d0 insns 178/180
|
||||
DecodeWord | signed marker-match position length | (0, -9999) | [1/1] MWCC build/43U/src/libs/RevoEX/src/nwc24/NWC24Mime.o
|
||||
ExtractCharset | inline marker search with pointer-valued results | (83.75, -9999) | src 0x148 base 0x150 insns 82/84
|
||||
ExtractCharset | comparison expressed as positive capacity test | (75.34524, -9999) | src 0x144 base 0x150 insns 81/84
|
||||
ExtractCharset | delay initial delimiter variables | (76.72619, -9999) | src 0x144 base 0x150 insns 81/84
|
||||
EncodeWord | store encoding character before validation | (71.681816, -9999) | src 0x2c0 base 0x318 insns 176/198
|
||||
EncodeWord | defer encoded overflow flag until concat result | (69.91919, -9999) | src 0x2c0 base 0x318 insns 176/198
|
||||
EncodeWord | positive charset pointer branch first | (69.81313, -9999) | src 0x2c4 base 0x318 insns 177/198
|
||||
ExtractCharset | moving marker cursor with base-plus-index return | (84.64286, -9999) | src 0x154 base 0x150 insns 85/84
|
||||
ExtractEncodedText | moving marker cursor with base-plus-index return | (89.85185, -9999) | src 0x214 base 0x21c insns 133/135
|
||||
|
||||
DecodeWord | consumed count declared before decoded count | (78.88333, -9999) | src 0x2c8 base 0x2d0 insns 178/180
|
||||
|
||||
Retained continuation: positive-capacity ConcatEncodedText is instruction-exact.
|
||||
FindMarker provides shared bounded scans with real pointer results.
|
||||
Header decoding initializes its remaining input after argument validation;
|
||||
QDecode validates each pointer separately. DecodeWord copies its size output
|
||||
unconditionally on the copy-overflow path, as in the target.
|
||||
All existing exact functions and all data bytes are preserved.
|
||||
|
||||
## Remaining functions
|
||||
|
||||
CopyWithoutLinearWhiteSpaces, 98.561646%: 73/73 instructions; saved-register allocation and scheduling differ.
|
||||
ExtractEncodedText, 91.25926%: bounded-marker scans and decoder dispatch still have different control flow.
|
||||
NWC24DecodeMIMEHeaderFieldBody, 88.36957%: error handling and loop termination emit different branches.
|
||||
QDecode, 87.60959%: hex-digit classification and input-loop branches differ.
|
||||
ExtractCharset, 83.75%: 82/84 instructions; second delimiter scan and register lifetimes differ.
|
||||
DecodeWord, 78.88333%: 178/180 instructions; delimiter search, whitespace handling, and error exits differ.
|
||||
EncodeWord, 71.681816%: 176/198 instructions; append-capacity checks and overflow exits differ.
|
||||
|
||||
@@ -98,3 +98,82 @@ NWC24iSetMsgSubjectQP 88.4375%: word-size accounting, folding control flow and a
|
||||
NWC24iSetMsgSubjectBase64 81.94853%: conversion/encoding status flow and folding allocation
|
||||
|
||||
Retained: 5/12 exact functions; 1840/5352 code bytes; 232/232 data bytes.
|
||||
|
||||
## Continuation 2026-09-30
|
||||
|
||||
Baseline: 5/12 exact functions; 1840/5352 code bytes; 232/232 data bytes.
|
||||
|
||||
NWC24ReadMsgTextPublic | inline status-acceptance helper | (97.14286, -9999) | src 0x110 base 0x118 insns 68/70
|
||||
NWC24ReadMsgTextPublic | successful reader branch before exceptional branch | (97.14286, -9999) | src 0x110 base 0x118 insns 68/70
|
||||
NWC24ReadMsgTextPublic | subject conversion status separate from reader status | (97.14286, -9999) | src 0x110 base 0x118 insns 68/70
|
||||
NWC24ReadMsgSubjectPublic | inline status-acceptance helper | (96.15385, -9999) | src 0x190 base 0x1a0 insns 100/104
|
||||
NWC24ReadMsgSubjectPublic | walk subject through separate character pointer | (95.94231, -9999) | src 0x190 base 0x1a0 insns 100/104
|
||||
NWC24ReadMsgSubjectPublic | signed decoded capacity temporary | (96.15385, -9999) | src 0x190 base 0x1a0 insns 100/104
|
||||
NWC24SetMsgSubjectAndTextPublic | status switches | (96.52631, -9999) | src 0x304 base 0x2f8 insns 193/190
|
||||
NWC24SetMsgSubjectAndTextPublic | grouped regional cases | (97.07895, -9999) | src 0x2f0 base 0x2f8 insns 188/190
|
||||
NWC24SetMsgSubjectAndTextPublic | switches and grouped regional cases | (98.23684, -65) | src 0x2f8 base 0x2f8 insns 190/190
|
||||
NWC24SetMsgSubjectAndTextPublic | work pointer declared before message alias | (98.23684, -65) | src 0x2f8 base 0x2f8 insns 190/190
|
||||
NWC24SetMsgSubjectAndTextPublic | late work pointer initialization | (0, -9999) | [1/1] MWCC build/43U/src/libs/RevoEX/src/nwc24/NWC24MsgSubject.o
|
||||
NWC24SetMsgSubjectAndTextPublic | derive subject buffer after text conversion | (98.23684, -65) | src 0x2f8 base 0x2f8 insns 190/190
|
||||
NWC24SetMsgSubjectAndTextPublic | retain charset pointer instead of work object | (98.23684, -65) | src 0x2f8 base 0x2f8 insns 190/190
|
||||
NWC24SetMsgSubjectAndTextPublic | declare input buffer partitions before work pointer | (98.23684, -65) | src 0x2f8 base 0x2f8 insns 190/190
|
||||
NWC24SetMsgSubjectAndTextPublic | assign work pointer inside detection argument | (98.23684, -65) | src 0x2f8 base 0x2f8 insns 190/190
|
||||
NWC24iSetMsgSubjectPlain | conversion status switch | (0, -9999) | [1/1] MWCC build/43U/src/libs/RevoEX/src/nwc24/NWC24MsgSubject.o
|
||||
NWC24iSetMsgSubjectPlain | prepare fold capacity before fit test | (92.096, -96) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | capture consumed first line before copy | (91.296, -9999) | src 0x1f0 base 0x1f4 insns 124/125
|
||||
NWC24iSetMsgSubjectQP | signed encoded word length | (88.4375, -9999) | src 0x22c base 0x240 insns 139/144
|
||||
NWC24iSetMsgSubjectQP | capture fold capacity before charset length | (88.4375, -9999) | src 0x22c base 0x240 insns 139/144
|
||||
NWC24iSetMsgSubjectQP | normalize via moving source pointer | (87.986115, -9999) | src 0x22c base 0x240 insns 139/144
|
||||
NWC24iSetMsgSubjectBase64 | signed encoded word length | (81.94853, -9999) | src 0x20c base 0x220 insns 131/136
|
||||
NWC24iSetMsgSubjectBase64 | multiply line length before shifting | (81.42647, -9999) | src 0x20c base 0x220 insns 131/136
|
||||
NWC24iSetMsgSubjectBase64 | capture remaining input after fold capacity check | (79.94118, -9999) | src 0x20c base 0x220 insns 131/136
|
||||
NWC24iDetectEncodingToSend | text status stored in search convergence index | (72.23853, -9999) | src 0x18c base 0x1b4 insns 99/109
|
||||
NWC24iDetectEncodingToSend | encoding checks use status switches | (72.376144, -9999) | src 0x18c base 0x1b4 insns 99/109
|
||||
NWC24iDetectEncodingToSend | region table selected with switch | (82.55963, -9999) | src 0x198 base 0x1b4 insns 102/109
|
||||
NWC24iDetectEncodingToSend | store selected index at each search exit | (96.04587, -46) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iDetectEncodingToSend | exit index plus cached byte sizes | (93.99083, -47) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iSetMsgSubjectPlain | explicit fold overflow first and postincrement writes | (99.144, -20) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | postincrement writes with initial source cursor | (94.944, -9999) | src 0x1f0 base 0x1f4 insns 124/125
|
||||
NWC24iDetectEncodingToSend | initialize search start before region dispatch | (96.60551, -32) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iDetectEncodingToSend | byte count locals after region selection | (96.27523, -47) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iDetectEncodingToSend | order table count and search locals by lifetime | (96.04587, -46) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iSetMsgSubjectPlain | source offset declared before second buffer | (99.904, -2) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | line length initialized before buffer capacity | (99.0, -23) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | fold pointer declared after counters | (99.904, -2) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | zero break length before source size initialization | (99.904, -2) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | zero break length before partition pointer initialization | (99.904, -2) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | initialize source and break sizes before work capacity | (99.76, -6) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iDetectEncodingToSend | cache byte lengths before end index | (98.073395, -34) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iDetectEncodingToSend | byte lengths and table local order | (98.073395, -34) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iDetectEncodingToSend | search start variable declared after previous index | (96.60551, -32) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iSetMsgSubjectPlain | break length initialized at declaration | (99.76, -6) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | break length declared first | (99.768, -20) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | input length declared after break length | (99.808, -14) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectPlain | work capacity initialized at declaration | (99.904, -2) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iDetectEncodingToSend | locals ordered by independent search roles | (100.0, 0) | src 0x1b4 base 0x1b4 insns 109/109
|
||||
NWC24iSetMsgSubjectPlain | partition capacity computed after break initialization | (100.0, 0) | src 0x1f4 base 0x1f4 insns 125/125
|
||||
NWC24iSetMsgSubjectQP | running output count excludes terminator and cached fold limit | (96.30556, -28) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | source cursor lifetime and partition initialization | (99.34028, -16) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | fold limit before source offset declaration | (99.34028, -16) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | source cursor declared before capacity variable | (99.34028, -16) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | running output computed through temporary before cursor advance | (99.548615, -12) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | fold limit replaces exhausted partition capacity | (99.548615, -12) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | source offset declared after output word size | (99.270836, -20) | src 0x240 base 0x240 insns 144/144
|
||||
NWC24iSetMsgSubjectQP | capacity declared after folded buffer | (99.548615, -12) | src 0x240 base 0x240 insns 144/144
|
||||
|
||||
Retained continuation: encoding detection stores each selected charset index
|
||||
at its actual search exit and caches input byte lengths. Plain folding uses
|
||||
the explicit overflow branch and increments its output cursor for CR/LF.
|
||||
Both functions are instruction-exact. SubjectAndText has matching control
|
||||
flow but different saved-register allocation. QP caches its fold limit and
|
||||
tracks the output length without the terminator; 144/144 instructions remain,
|
||||
with twelve differences from the capacity/source-cursor register exchange.
|
||||
All prior exact functions and all charset tables and strings are preserved.
|
||||
|
||||
## Remaining functions
|
||||
|
||||
NWC24iSetMsgSubjectQP, 99.548615%: 144/144 instructions; twelve register differences from capacity/source-offset allocation.
|
||||
NWC24SetMsgSubjectAndTextPublic, 98.23684%: 190/190 instructions; 65 saved-register differences.
|
||||
NWC24ReadMsgTextPublic, 97.14286%: 68/70 instructions; overflow-status branch lowering omits two target branches.
|
||||
NWC24ReadMsgSubjectPublic, 96.15385%: 100/104 instructions; two overflow-status blocks each omit two target branches.
|
||||
NWC24iSetMsgSubjectBase64, 81.94853%: 131/136 instructions; conversion-status branches and folded-output accumulation differ.
|
||||
|
||||
Reference in New Issue
Block a user