From 5498a4e835bbb66e3658d298b98e11010c04fb22 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 21 Jan 2015 13:27:20 -0800 Subject: [PATCH] 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. --- reformat/BASIC.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reformat/BASIC.cpp b/reformat/BASIC.cpp index edd85fd..bb2a239 100644 --- a/reformat/BASIC.cpp +++ b/reformat/BASIC.cpp @@ -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); + } } }