Skip to content

Commit

Permalink
Merge pull request #102 from MaxGyver83/bestline-avoid-null-char-warning
Browse files Browse the repository at this point in the history
bestline: Avoid null character warning for empty commands
  • Loading branch information
rakitzis authored Jul 1, 2024
2 parents a8ee324 + e743ece commit d6b2dc9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions edit-bestline.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,10 @@ char *edit_alloc(void *cookie, size_t *count) {
c->buffer = bestline(prompt);
if (c->buffer) {
*count = strlen(c->buffer);
if (*count) {
if (*count)
bestlineHistoryAdd(c->buffer);
c->buffer[*count] = '\n';
++*count;
}
c->buffer[*count] = '\n';
++*count; /* include the \n */
}
return c->buffer;
}
Expand Down

0 comments on commit d6b2dc9

Please sign in to comment.