0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

don't SIGBUS when deleting at end of line

This commit is contained in:
Mathias Stearn 2011-04-12 12:25:55 -04:00
parent 9d87406196
commit c68392bfe8

View File

@ -480,10 +480,12 @@ static int linenoisePrompt(int fd, char *buf, size_t buflen, const char *prompt)
errno = EAGAIN;
return -1;
case 127: /* delete */
memmove(buf+pos,buf+pos+1,len-pos-1);
len--;
buf[len] = '\0';
refreshLine(fd,prompt,buf,len,pos,cols);
if (len > 0 && pos < len) {
memmove(buf+pos,buf+pos+1,len-pos-1);
len--;
buf[len] = '\0';
refreshLine(fd,prompt,buf,len,pos,cols);
}
break;
case 8: /* backspace or ctrl-h */
if (pos > 0 && len > 0) {