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
1 changed files with 8 additions and 2 deletions

View File

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