From caf0e53e8f428e48f1c66e378d304f7412bd15f0 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 1 Oct 2008 20:02:34 +0000 Subject: 2008-10-01 Gene Smith PR 1328/cpukit * libmisc/shell/main_mdump.c, libmisc/shell/main_mwdump.c: Fix printing of more than 256 bytes. --- cpukit/libmisc/shell/main_mdump.c | 35 ++++++++++++++++++++++-------- cpukit/libmisc/shell/main_mwdump.c | 44 ++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 23 deletions(-) (limited to 'cpukit/libmisc/shell') diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c index f245afb183..721b3a5658 100644 --- a/cpukit/libmisc/shell/main_mdump.c +++ b/cpukit/libmisc/shell/main_mdump.c @@ -34,7 +34,9 @@ int rtems_shell_main_mdump( char *argv[] ) { - unsigned char n, m, max=20; + unsigned char n, m; + int max; + int res; uintptr_t addr = 0; unsigned char *pb; @@ -43,19 +45,34 @@ int rtems_shell_main_mdump( if (argc>2) { max = rtems_shell_str2int(argv[2]); - max /= 16; + if (max <= 0) { + max = 1; /* print 1 item if 0 or neg. */ + res = 0; + } + else { + max--; + res = max & 0xf;/* num bytes in last row */ + max >>= 4; /* div by 16 */ + max++; /* num of rows to print */ + if (max > 20) { /* limit to 20 */ + max = 20; + res = 0xf; /* 16 bytes print in last row */ + } + } + } + else { + max = 20; + res = 0xf; } - - - if (!max) - max = 1; for (m=0; m1) addr = rtems_shell_str2int(argv[1]); if (argc>2) { max = rtems_shell_str2int(argv[2]); - max /= 16; + if (max <= 0) { + max = 1; /* print 1 item if 0 or neg. */ + res = 0; + } + else { + max--; + res = max & 0xf;/* num bytes in last row */ + max >>= 4; /* div by 16 */ + max++; /* num of rows to print */ + if (max > 20) { /* limit to 20 */ + max = 20; + res = 0xf; /* 16 bytes print in last row */ + } + } + } + else { + max = 20; + res = 0xf; } - - if (!max) - max = 1; for (m=0;m