=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/ttyin.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- src/usr.bin/less/ttyin.c 2003/04/13 18:26:26 1.3 +++ src/usr.bin/less/ttyin.c 2011/09/16 18:12:09 1.4 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2002 Mark Nudelman + * Copyright (C) 1984-2011 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 @@ public int tty; extern int sigs; +extern int utf_mode; /* * Open keyboard for input. @@ -132,6 +133,38 @@ quit(QUIT_ERROR); } #endif +#if 0 /* allow entering arbitrary hex chars for testing */ + /* ctrl-A followed by two hex chars makes a byte */ + { + int hex_in = 0; + int hex_value = 0; + 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 +174,5 @@ c = '\340'; } while (result != 1); - return (c & 0377); + return (c & 0xFF); }