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.
This commit is contained in:
Joel Sherrill
2009-07-22 15:17:37 +00:00
parent e8d59ca6af
commit 35d09baa84
15 changed files with 252 additions and 184 deletions

View File

@@ -22,6 +22,7 @@
#include <rtems.h>
#include <rtems/shell.h>
#include <rtems/stringto.h>
#include "internal.h"
extern int rtems_shell_main_mdump(int, char *);
@@ -31,19 +32,38 @@ int rtems_shell_main_medit(
char *argv[]
)
{
unsigned char * pb;
int n,i;
unsigned long tmp;
unsigned char *pb;
int n;
int i;
if (argc<3) {
if ( argc < 3 ) {
fprintf(stderr,"%s: too few arguments\n", argv[0]);
return -1;
}
pb = (unsigned char*)rtems_shell_str2int(argv[1]);
i = 2;
/*
* Convert arguments into numbers
*/
if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
pb = (unsigned char *) tmp;
/*
* Now edit the memory
*/
n = 0;
while (i<=argc) {
pb[n++] = rtems_shell_str2int(argv[i++]) % 0x100;
for (i=2 ; i<=argc ; i++) {
unsigned char tmpc;
if ( !rtems_string_to_unsigned_char(argv[i], &tmpc, NULL, 0) ) {
printf( "Value (%s) is not a number\n", argv[i] );
continue;
}
pb[n++] = tmpc;
}
return 0;