summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2019-12-04 23:09:19 +0100
committerBoris Faure <billiob@gmail.com>2019-12-04 23:10:39 +0100
commite1f3a4d486f66eb85ef915809aa8a0a8878491f6 (patch)
tree62fc23e40b516c0ff507162e40290292f1b2aa44
parent6bfd508a5887273b5b68a4d1bb973ed1bf4201e2 (diff)
sb: when skipping buffer on the left and the buffer is empty, remove gap
-rw-r--r--src/bin/sb.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/bin/sb.c b/src/bin/sb.c
index a0dd9e8..f52f9d4 100644
--- a/src/bin/sb.c
+++ b/src/bin/sb.c
@@ -108,8 +108,17 @@ void
108ty_sb_lskip(struct ty_sb *sb, int len) 108ty_sb_lskip(struct ty_sb *sb, int len)
109{ 109{
110 sb->len -= len; 110 sb->len -= len;
111 sb->gap += len; 111 if (sb->len)
112 sb->buf += len; 112 {
113 sb->gap += len;
114 sb->buf += len;
115 }
116 else
117 {
118 /* buffer is empty, get rid of gap */
119 sb->buf -= sb->gap;
120 sb->gap = 0;
121 }
113} 122}
114 123
115void 124void