Accept abbreviations for eeprom and flash for the dump and write

commands.

Fix small bug keeping 1 character command lines from being added to
the history.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@40 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Brian S. Dean 2001-01-19 03:43:16 +00:00
parent 7dc244ac12
commit 6cd9862d2c
1 changed files with 9 additions and 7 deletions

16
term.c
View File

@ -196,7 +196,7 @@ int hexdump_buf ( FILE * f, int startaddr, char * buf, int len )
int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] ) int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
{ {
char * e; char * e;
int i, j; int i, j, l;
unsigned short daddr; unsigned short daddr;
char * buf; char * buf;
int maxsize; int maxsize;
@ -213,10 +213,11 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
return -1; return -1;
} }
if (strcmp(argv[1],"flash")==0) { l = strlen(argv[1]);
if (strncasecmp(argv[1],"flash",l)==0) {
memtype = AVR_FLASH; memtype = AVR_FLASH;
} }
else if (strcmp(argv[1],"eeprom")==0) { else if (strncasecmp(argv[1],"eeprom",l)==0) {
memtype = AVR_EEPROM; memtype = AVR_EEPROM;
} }
else { else {
@ -300,7 +301,7 @@ int cmd_dump ( int fd, struct avrpart * p, int argc, char * argv[] )
int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] ) int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
{ {
char * e; char * e;
int i, j; int i, j, l;
int len, maxsize; int len, maxsize;
AVRMEM memtype; AVRMEM memtype;
unsigned short addr, daddr; unsigned short addr, daddr;
@ -313,11 +314,12 @@ int cmd_write ( int fd, struct avrpart * p, int argc, char * argv[] )
return -1; return -1;
} }
if (strcmp(argv[1],"flash")==0) { l = strlen(argv[1]);
if (strncasecmp(argv[1],"flash",l)==0) {
memtype = AVR_FLASH; memtype = AVR_FLASH;
maxsize = p->flash_size; maxsize = p->flash_size;
} }
else if (strcmp(argv[1],"eeprom")==0) { else if (strncasecmp(argv[1],"eeprom",l)==0) {
memtype = AVR_EEPROM; memtype = AVR_EEPROM;
maxsize = p->eeprom_size; maxsize = p->eeprom_size;
} }
@ -592,7 +594,7 @@ int terminal_mode ( int fd, struct avrpart * p )
rc = 0; rc = 0;
while ((cmdbuf = readline("avrprog> ")) != NULL) { while ((cmdbuf = readline("avrprog> ")) != NULL) {
len = strlen(cmdbuf); len = strlen(cmdbuf);
if (len > 1) if (len >= 1)
add_history(cmdbuf); add_history(cmdbuf);
/* /*