From 5297f4bc59da861bbe3beb5ee12839fa05e79882 Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 20 Aug 2006 15:49:51 +0000 Subject: Import less v394 --- contrib/less/ttyin.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'contrib/less/ttyin.c') diff --git a/contrib/less/ttyin.c b/contrib/less/ttyin.c index 5d99d33..ca500f9 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); } -- cgit v1.1