diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-22 15:17:37 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-07-22 15:17:37 +0000 |
commit | 35d09baa84f3e029646e3a2f2f0e9b348de57517 (patch) | |
tree | 9e108a9d304ab73d8e596b65dae1b83f82b6d095 /cpukit/libmisc/shell/main_mwdump.c | |
parent | 2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-35d09baa84f3e029646e3a2f2f0e9b348de57517.tar.bz2 |
2009-07-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_chmod.c,
libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c,
libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c,
libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c,
libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c,
libmisc/shell/shell.h, libmisc/shell/shell_script.c,
libmisc/stringto/stringto_template.h: Convert all shell code to use
stringto.h mehods with better error checking.
* libmisc/shell/str2int.c: Removed.
Diffstat (limited to 'cpukit/libmisc/shell/main_mwdump.c')
-rw-r--r-- | cpukit/libmisc/shell/main_mwdump.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/cpukit/libmisc/shell/main_mwdump.c b/cpukit/libmisc/shell/main_mwdump.c index 1105656814..3a4f4c6ddd 100644 --- a/cpukit/libmisc/shell/main_mwdump.c +++ b/cpukit/libmisc/shell/main_mwdump.c @@ -23,6 +23,7 @@ #include <rtems.h> #include <rtems/shell.h> +#include <rtems/stringto.h> #include "internal.h" int rtems_shell_main_mwdump( @@ -30,22 +31,32 @@ int rtems_shell_main_mwdump( char *argv[] ) { - unsigned char n, m; + unsigned long tmp; + unsigned char n; + unsigned char m; int max; int res; uintptr_t addr = 0; unsigned char *pb; - if (argc>1) - addr = rtems_shell_str2int(argv[1]); + if ( argc > 1 ) { + if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) { + printf( "Address argument (%s) is not a number\n", argv[1] ); + return -1; + } + addr = (uintptr_t) tmp; + } + + if ( argc > 2 ) { + if ( !rtems_string_to_int(argv[2], &max, NULL, 0) ) { + printf( "Address argument (%s) is not a number\n", argv[1] ); + return -1; + } - if (argc>2) { - max = rtems_shell_str2int(argv[2]); if (max <= 0) { max = 1; /* print 1 item if 0 or neg. */ res = 0; - } - else { + } else { max--; res = max & 0xf;/* num bytes in last row */ max >>= 4; /* div by 16 */ @@ -55,15 +66,14 @@ int rtems_shell_main_mwdump( res = 0xf; /* 16 bytes print in last row */ } } - } - else { + } else { max = 20; res = 0xf; } for (m=0;m<max;m++) { - printf("0x%08" PRIXPTR " ",addr); pb = (unsigned char *) addr; + printf("%p ", pb); for (n=0;n<=(m==(max-1)?res:0xf);n+=2) printf("%04X%c",*((unsigned short*)(pb+n)),n==6?'-':' '); for (;n<=0xf;n+=2) |