Skip to content

Commit

Permalink
Import upstream bestline changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Nov 10, 2024
1 parent 54d3c72 commit 21af0bf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llamafile/bestline.c
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,10 @@ static ssize_t bestlineCompleteLine(struct bestlineState *ls, char *seq, int siz
ls->len = saved.len;
ls->pos = saved.pos;
ls->buf = saved.buf;
if (lc.len == 1) {
nread = 0;
goto FinishQuickly;
}
} else {
bestlineRefreshLine(ls);
}
Expand All @@ -2045,6 +2049,7 @@ static ssize_t bestlineCompleteLine(struct bestlineState *ls, char *seq, int siz
break;
default:
if (i < lc.len) {
FinishQuickly:
n = strlen(lc.cvec[i]);
if (bestlineGrow(ls, n + 1)) {
memcpy(ls->buf, lc.cvec[i], n + 1);
Expand Down

0 comments on commit 21af0bf

Please sign in to comment.