aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-09-14 11:20:36 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-09-14 11:20:36 +0200
commit44cb1666ef4403a0fa8838d49006567ac960b33a (patch)
treed26bf2ff60c2f3e9ea1d98f5a4fe0d9648e12851
parent8838c6d53ecf9491d862ee090c9bf1579fa64eed (diff)
downloadbusybox-44cb1666ef4403a0fa8838d49006567ac960b33a.tar.gz
hexedit: code shrink
function old new delta hexedit_main 1176 1169 -7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/hexedit.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/miscutils/hexedit.c b/miscutils/hexedit.c
index bdb7683f2..1d683b7de 100644
--- a/miscutils/hexedit.c
+++ b/miscutils/hexedit.c
@@ -274,7 +274,7 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv)
for (;;) {
unsigned cnt;
- int32_t key = key; // for compiler
+ int32_t key = key; /* for compiler */
uint8_t byte;
fflush_all();
@@ -286,11 +286,12 @@ int hexedit_main(int argc UNUSED_PARAM, char **argv)
key = CTRL('X');
cnt = 1;
+ if ((unsigned)(key - 'A') <= 'Z' - 'A')
+ key |= 0x20; /* convert A-Z to a-z */
switch (key) {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- /* lowercase, then convert to '0'+10...15 */
- key = (key | 0x20) - ('a' - '0' - 10);
+ /* convert to '0'+10...15 */
+ key = key - ('a' - '0' - 10);
/* fall through */
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':