Handle carriage returns in REM statements

With a bit of hex-editing it's possible to embed carriage returns
in REM statements.  The reformatter wasn't handling that well.  The
new output matches what LIST generates.

The output generated cannot be imported by the text-to-BASIC
importer because it doesn't understand the blank lines.  The output
generated before this change didn't work either, though that was a
bit harder to figure out because the CRs are harder to see in Windows
than CRLF.

It should be possible to teach the importer to handle such files,
though I think these files are pretty rare -- I happened to find
them in some Peter Watson freeware.
This commit is contained in:
Andy McFadden 2015-01-21 13:27:20 -08:00
parent a2c15eee55
commit 5498a4e835

View File

@ -170,7 +170,7 @@ int ReformatApplesoft::Process(const ReformatHolder* pHolder,
inRem = true; inRem = true;
} }
} else { } else {
/* simple chracter */ /* simple character */
if (fUseRTF) { if (fUseRTF) {
if (*srcPtr == '"' && !inRem) { if (*srcPtr == '"' && !inRem) {
if (!inQuote) { if (!inQuote) {
@ -185,13 +185,19 @@ int ReformatApplesoft::Process(const ReformatHolder* pHolder,
RTFSetColor(kColonColor); RTFSetColor(kColonColor);
RTFPrintChar(*srcPtr); RTFPrintChar(*srcPtr);
RTFSetColor(kDefaultColor); RTFSetColor(kDefaultColor);
} else if (inRem && *srcPtr == '\r') {
RTFNewPara();
} else { } else {
RTFPrintChar(*srcPtr); RTFPrintChar(*srcPtr);
} }
} else {
if (inRem && *srcPtr == '\r') {
BufPrintf("\r\n");
} else { } else {
BufPrintf("%c", *srcPtr); BufPrintf("%c", *srcPtr);
} }
} }
}
srcPtr++; srcPtr++;
length--; length--;