Temporary fix for WSL

This commit is contained in:
Renaud 2021-08-19 10:07:13 +08:00
parent e6921a8ed1
commit 679d8d098b
2 changed files with 27 additions and 25 deletions

View File

@ -7,7 +7,7 @@
# if __NetBSD__ # if __NetBSD__
# define BSD 1 # define BSD 1
# define POSIX 1 # define POSIX 1
# elsif __linux__ # elif __linux__
# define USG 1 # define USG 1
# define SVR4 1 /* locks */ # define SVR4 1 /* locks */
# define POSIX 1 # define POSIX 1

20
posix.c
View File

@ -149,27 +149,28 @@ void ttflush(void)
exit(15); exit(15);
} }
/*
* Read a character from the terminal, performing no editing and doing no echo /* Read a character from the terminal, performing no editing and doing no
* at all. echo at all.
* Very simple on CPM, because the system can do exactly what you want.
*/ */
int ttgetc(void) int ttgetc( void) {
{
static char buffer[ 32] ; static char buffer[ 32] ;
static int pending ; static int pending ;
unicode_t c ; unicode_t c ;
int count, bytes = 1, expected;
count = pending; int count = pending ;
if( !count) { if( !count) {
count = read( 0, buffer, sizeof( buffer)) ; count = read( 0, buffer, sizeof( buffer)) ;
if( count <= 0) if( count <= 0)
return 0 ; return 0 ;
pending = count ; pending = count ;
} }
int bytes = 1 ;
c = (unsigned char) buffer[ 0] ; c = (unsigned char) buffer[ 0] ;
#if 0 // temporary fix for wsl
if (c >= 32 && c < 128) if (c >= 32 && c < 128)
goto done; goto done;
@ -186,7 +187,7 @@ int ttgetc(void)
* delay for some *very* unusual utf8 character * delay for some *very* unusual utf8 character
* input. * input.
*/ */
expected = 2; int expected = 2;
if ((c & 0xe0) == 0xe0) if ((c & 0xe0) == 0xe0)
expected = 6; expected = 6;
@ -220,6 +221,7 @@ int ttgetc(void)
bytes = utf8_to_unicode(buffer, 0, pending, &c); bytes = utf8_to_unicode(buffer, 0, pending, &c);
done: done:
#endif
pending -= bytes ; pending -= bytes ;
memmove( buffer, buffer + bytes, pending) ; memmove( buffer, buffer + bytes, pending) ;
return c ; return c ;