aboutsummaryrefslogtreecommitdiff
path: root/contrib/less/ttyin.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/less/ttyin.c')
-rw-r--r--contrib/less/ttyin.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c
index 5d99d335e9e1..ca500f9a8ee8 100644
--- a/contrib/less/ttyin.c
+++ b/contrib/less/ttyin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1984-2002 Mark Nudelman
+ * Copyright (C) 1984-2004 Mark Nudelman
*
* You may distribute under the terms of either the GNU General Public
* License or the Less License, as specified in the README file.
@@ -26,6 +26,7 @@ static DWORD console_mode;
public int tty;
extern int sigs;
+extern int utf_mode;
/*
* Open keyboard for input.
@@ -101,6 +102,8 @@ getchr()
{
char c;
int result;
+ int hex_in = 0;
+ int hex_value = 0;
do
{
@@ -132,6 +135,34 @@ getchr()
quit(QUIT_ERROR);
}
#endif
+#if 0 /* allow entering arbitrary hex chars for testing */
+ /* ctrl-A followed by two hex chars makes a byte */
+ if (c == CONTROL('A'))
+ {
+ hex_in = 2;
+ result = 0;
+ continue;
+ }
+ if (hex_in > 0)
+ {
+ int v;
+ if (c >= '0' && c <= '9')
+ v = c - '0';
+ else if (c >= 'a' && c <= 'f')
+ v = c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ v = c - 'A' + 10;
+ else
+ hex_in = 0;
+ hex_value = (hex_value << 4) | v;
+ if (--hex_in > 0)
+ {
+ result = 0;
+ continue;
+ }
+ c = hex_value;
+ }
+#endif
/*
* Various parts of the program cannot handle
* an input character of '\0'.
@@ -141,5 +172,5 @@ getchr()
c = '\340';
} while (result != 1);
- return (c & 0377);
+ return (c & 0xFF);
}