sb: when skipping buffer on the left and the buffer is empty, remove gap

This commit is contained in:
Boris Faure 2019-12-04 23:09:19 +01:00
parent 6bfd508a58
commit e1f3a4d486
Signed by: borisfaure
GPG Key ID: EAA9CD729F522998
1 changed files with 11 additions and 2 deletions

View File

@ -108,8 +108,17 @@ void
ty_sb_lskip(struct ty_sb *sb, int len)
{
sb->len -= len;
sb->gap += len;
sb->buf += len;
if (sb->len)
{
sb->gap += len;
sb->buf += len;
}
else
{
/* buffer is empty, get rid of gap */
sb->buf -= sb->gap;
sb->gap = 0;
}
}
void