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:
parent
9d87406196
commit
c68392bfe8
10
third_party/linenoise/linenoise.cpp
vendored
10
third_party/linenoise/linenoise.cpp
vendored
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user