summaryrefslogtreecommitdiffstats
path: root/contrib/less/ttyin.c
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2002-01-07 20:29:38 +0000
committerps <ps@FreeBSD.org>2002-01-07 20:29:38 +0000
commitc0c85bc41cb6c023adae56cf0a7e3495bd528cb2 (patch)
tree22ed5b4269586d3d5c21d37a27645897709341e3 /contrib/less/ttyin.c
parent5d465776b9e058088e1f29636cf7cdcb0c13eb0d (diff)
downloadFreeBSD-src-c0c85bc41cb6c023adae56cf0a7e3495bd528cb2.zip
FreeBSD-src-c0c85bc41cb6c023adae56cf0a7e3495bd528cb2.tar.gz
Import less v371
Diffstat (limited to 'contrib/less/ttyin.c')
-rw-r--r--contrib/less/ttyin.c36
1 files changed, 10 insertions, 26 deletions
diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c
index ef87e25..b342ed9 100644
--- a/contrib/less/ttyin.c
+++ b/contrib/less/ttyin.c
@@ -14,6 +14,10 @@
*/
#include "less.h"
+#if OS2
+#include "cmd.h"
+#include "pckeys.h"
+#endif
#if MSDOS_COMPILER==WIN32C
#include "windows.h"
extern char WIN32getch();
@@ -42,7 +46,7 @@ open_getchr()
/* Make sure we get Ctrl+C events. */
SetConsoleMode((HANDLE)tty, ENABLE_PROCESSED_INPUT);
#else
-#if MSDOS_COMPILER || OS2
+#if MSDOS_COMPILER
extern int fd0;
/*
* Open a new handle to CON: in binary mode
@@ -65,7 +69,12 @@ open_getchr()
* which in Unix is usually attached to the screen,
* but also usually lets you read from the keyboard.
*/
+#if OS2
+ /* The __open() system call translates "/dev/tty" to "con". */
+ tty = __open("/dev/tty", OPEN_READ);
+#else
tty = open("/dev/tty", OPEN_READ);
+#endif
if (tty < 0)
tty = 2;
#endif
@@ -111,30 +120,6 @@ getchr()
if (c == '\003')
return (READ_INTR);
#else
-#if OS2
- {
- static int scan = -1;
- flush();
- if (scan >= 0)
- {
- c = scan;
- scan = -1;
- } else
- {
- if ((c = _read_kbd(0, 1, 0)) == -1)
- return (READ_INTR);
- if (c == '\0')
- {
- /*
- * Zero is usually followed by another byte,
- * since certain keys send two bytes.
- */
- scan = _read_kbd(0, 0, 0);
- }
- }
- result = 1;
- }
-#else
result = iread(tty, &c, sizeof(char));
if (result == READ_INTR)
return (READ_INTR);
@@ -147,7 +132,6 @@ getchr()
quit(QUIT_ERROR);
}
#endif
-#endif
/*
* Various parts of the program cannot handle
* an input character of '\0'.
OpenPOWER on IntegriCloud