Preserve ESC not part of a sequence
There are some instances when ESC should just be a normal character (e.g. TCC uses it in aliases to clear the current line), so if no sequence is recognised, pass the ESC through.
This commit is contained in:
		
							parent
							
								
									43b3653c8a
								
							
						
					
					
						commit
						8eb06aad27
					
				
							
								
								
									
										19
									
								
								ANSI.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								ANSI.c
									
									
									
									
									
								
							| @ -152,12 +152,14 @@ | |||||||
|     remove wcstok, avoiding potential interference with the host; |     remove wcstok, avoiding potential interference with the host; | ||||||
|     similarly, use a private heap instead of malloc. |     similarly, use a private heap instead of malloc. | ||||||
| 
 | 
 | ||||||
|   v1.80, 26 October to 3 November, 2017: |   v1.80, 26 October to 7 November, 2017: | ||||||
|     fix unloading; |     fix unloading; | ||||||
|     revert back to (re)storing buffer cursor position; |     revert back to (re)storing buffer cursor position; | ||||||
|     increase cache to five handles; |     increase cache to five handles; | ||||||
|     hook CreateFile & CreateConsoleScreenBuffer to enable readable handles; |     hook CreateFile & CreateConsoleScreenBuffer to enable readable handles; | ||||||
|     fix cursor report with duplicated digits (e.g. "11" was just "1"). |     fix cursor report with duplicated digits (e.g. "11" was just "1"); | ||||||
|  |     preserve escape that isn't part of a sequence; | ||||||
|  |     fix escape followed by CRM in control mode. | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #include "ansicon.h" | #include "ansicon.h" | ||||||
| @ -1202,7 +1204,8 @@ ParseAndPrintString( HANDLE hDev, | |||||||
|     } |     } | ||||||
|     else if (state == 2) |     else if (state == 2) | ||||||
|     { |     { | ||||||
|       if (c == ESC) ;		// \e\e...\e == \e
 |       if (c == ESC) | ||||||
|  | 	PushBuffer( ESC ); | ||||||
|       else if (c >= '\x20' && c <= '\x2f') |       else if (c >= '\x20' && c <= '\x2f') | ||||||
| 	suffix2 = c; | 	suffix2 = c; | ||||||
|       else if (suffix2 != 0) |       else if (suffix2 != 0) | ||||||
| @ -1225,7 +1228,12 @@ ParseAndPrintString( HANDLE hDev, | |||||||
| 	*Pt_arg = '\0'; | 	*Pt_arg = '\0'; | ||||||
| 	state = 6; | 	state = 6; | ||||||
|       } |       } | ||||||
|       else state = 1; |       else | ||||||
|  |       { | ||||||
|  | 	PushBuffer( ESC ); | ||||||
|  | 	PushBuffer( (WCHAR)c ); | ||||||
|  | 	state = 1; | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|     else if (state == 3) |     else if (state == 3) | ||||||
|     { |     { | ||||||
| @ -1329,10 +1337,13 @@ ParseAndPrintString( HANDLE hDev, | |||||||
|       else |       else | ||||||
|       { |       { | ||||||
| 	PushBuffer( ESC ); | 	PushBuffer( ESC ); | ||||||
|  | 	if (c != ESC) | ||||||
|  | 	{ | ||||||
| 	  PushBuffer( (WCHAR)c ); | 	  PushBuffer( (WCHAR)c ); | ||||||
| 	  state = 1; | 	  state = 1; | ||||||
| 	} | 	} | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|     else if (state == 8) |     else if (state == 8) | ||||||
|     { |     { | ||||||
|       if (c == '3') state = 9; |       if (c == '3') state = 9; | ||||||
|  | |||||||
| @ -90,7 +90,7 @@ | |||||||
|     write newline with _putws, not putwchar (fixes redirecting to CON). |     write newline with _putws, not putwchar (fixes redirecting to CON). | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #define PDATE L"3 November, 2017" | #define PDATE L"7 November, 2017" | ||||||
| 
 | 
 | ||||||
| #include "ansicon.h" | #include "ansicon.h" | ||||||
| #include "version.h" | #include "version.h" | ||||||
|  | |||||||
| @ -295,13 +295,15 @@ Version History | |||||||
| 
 | 
 | ||||||
|     Legend: + added, - bug-fixed, * changed. |     Legend: + added, - bug-fixed, * changed. | ||||||
| 
 | 
 | ||||||
|     1.80 - 3 November, 2017: |     1.80 - 7 November, 2017: | ||||||
|     - fix unloading; |     - fix unloading; | ||||||
|     - fix -e et al when redirecting to CON; |     - fix -e et al when redirecting to CON; | ||||||
|     - hook CreateFile and CreateConsoleScreenBuffer to force read/write access |     - hook CreateFile and CreateConsoleScreenBuffer to force read/write access | ||||||
|       (fixes redirecting to CON and Microsoft's conio); |       (fixes redirecting to CON and Microsoft's conio); | ||||||
|     - fix cursor report with duplicated digits (e.g. "11" was only writing "1"); |     - fix cursor report with duplicated digits (e.g. "11" was only writing "1"); | ||||||
|     * go back to saving the buffer cursor position. |     - fix escape followed by CRM in control mode; | ||||||
|  |     * go back to saving the buffer cursor position; | ||||||
|  |     * preserve escape that isn't part of a sequence. | ||||||
| 
 | 
 | ||||||
|     1.72 - 24 December, 2015: |     1.72 - 24 December, 2015: | ||||||
|     - handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile; |     - handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile; | ||||||
| @ -530,4 +532,4 @@ Distribution | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| ============================= | ============================= | ||||||
| Jason Hood, 3 November, 2017. | Jason Hood, 7 November, 2017. | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Jason Hood
						Jason Hood