Fix CR and CRM issues
CR and BS would still be processed during CRM. Fix all the partial CRM sequences followed by a complete CRM sequence. It's possible for some text files to have `\r\r\n` endings (Microsoft converts LF to CRLF even when the CR is already there). Collapse multiple CRs to a single CR to catch this. It is also necessary to always delay flushing if the last character is CR, to see if the next character is CR or LF.
This commit is contained in:
parent
2120ff3efa
commit
44e5941a08
23
ANSI.c
23
ANSI.c
@ -179,6 +179,12 @@
|
||||
only flush before accessing the console, adding a mode to flush immediately;
|
||||
added DECSTR & RIS;
|
||||
fix state problems with windowless processes.
|
||||
|
||||
v1.81-wip, 26 December, 2017:
|
||||
combine multiple CRs as one (to ignore all CRs before LF);
|
||||
don't process CR or BS during CRM;
|
||||
don't flush CR immediately (to catch following LF);
|
||||
fix CRM with all partial RM sequences.
|
||||
*/
|
||||
|
||||
#include "ansicon.h"
|
||||
@ -898,8 +904,11 @@ void PushBuffer( WCHAR c )
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!pState->crm)
|
||||
{
|
||||
if (nCharInBuffer > 0 && ChBuffer[nCharInBuffer-1] == '\r')
|
||||
{
|
||||
if (c == '\r') return; // \r\r\r... == \r, thus \r\r\n == \r\n
|
||||
FlushBuffer();
|
||||
if (nWrapped)
|
||||
{
|
||||
@ -926,6 +935,7 @@ void PushBuffer( WCHAR c )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shifted && c >= FIRST_G1 && c <= LAST_G1)
|
||||
c = G1[c-FIRST_G1];
|
||||
ChBuffer[nCharInBuffer] = c;
|
||||
@ -2363,30 +2373,39 @@ ParseAndPrintString( HANDLE hDev,
|
||||
{
|
||||
PushBuffer( ESC );
|
||||
PushBuffer( '[' );
|
||||
if (c == ESC) state = 7;
|
||||
else
|
||||
{
|
||||
PushBuffer( (WCHAR)c );
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state == 9)
|
||||
{
|
||||
if (c == 'l')
|
||||
{
|
||||
FlushBuffer();
|
||||
pState->crm = FALSE;
|
||||
state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PushBuffer( ESC );
|
||||
PushBuffer( '[' );
|
||||
PushBuffer( '3' );
|
||||
if (c == ESC) state = 7;
|
||||
else
|
||||
{
|
||||
PushBuffer( (WCHAR)c );
|
||||
}
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nCharInBuffer > 0)
|
||||
{
|
||||
if (pState->fm) FlushBuffer();
|
||||
if (pState->fm && ChBuffer[nCharInBuffer-1] != '\r') FlushBuffer();
|
||||
else
|
||||
{
|
||||
LARGE_INTEGER due;
|
||||
|
@ -91,7 +91,7 @@
|
||||
use -pu to unload from the parent.
|
||||
*/
|
||||
|
||||
#define PDATE L"24 December, 2017"
|
||||
#define PDATE L"26 December, 2017"
|
||||
|
||||
#include "ansicon.h"
|
||||
#include "version.h"
|
||||
|
@ -334,6 +334,10 @@ Version History
|
||||
|
||||
Legend: + added, - bug-fixed, * changed.
|
||||
|
||||
1.81-wip - 26 December, 2017:
|
||||
- fix multiple CRs before LF (including preventing an immediate flush);
|
||||
- fix CR, BS and partial RM during CRM.
|
||||
|
||||
1.80 - 24 December, 2017:
|
||||
- fix unloading;
|
||||
- fix -e et al when redirecting to CON;
|
||||
@ -590,4 +594,4 @@ Distribution
|
||||
|
||||
|
||||
==============================
|
||||
Jason Hood, 24 December, 2017.
|
||||
Jason Hood, 26 December, 2017.
|
||||
|
10
version.h
10
version.h
@ -2,11 +2,11 @@
|
||||
version.h - Version defines.
|
||||
*/
|
||||
|
||||
#define PVERS L"1.80" // wide string
|
||||
#define PVERSA "1.80" // ANSI string (windres 2.16.91 didn't like L)
|
||||
#define PVERE L"180" // wide environment string
|
||||
#define PVEREA "180" // ANSI environment string
|
||||
#define PVERB 1,8,0,0 // binary (resource)
|
||||
#define PVERS L"1.81-wip" // wide string
|
||||
#define PVERSA "1.81-wip" // ANSI string (windres 2.16.91 didn't like L)
|
||||
#define PVERE L"181" // wide environment string
|
||||
#define PVEREA "181" // ANSI environment string
|
||||
#define PVERB 1,8,1,0 // binary (resource)
|
||||
|
||||
#ifdef _WIN64
|
||||
# define BITS L"64"
|
||||
|
Loading…
x
Reference in New Issue
Block a user