[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs util.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs util.c |
Date: |
Fri, 23 Dec 2016 04:47:12 -0500 (EST) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/12/23 04:47:12
Modified files:
. : util.c
Log message:
simplified buf_write() and buf_putc_utf8()
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.73&r2=1.74
Patches:
Index: util.c
===================================================================
RCS file: /sources/qemacs/qemacs/util.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- util.c 26 Jun 2016 08:35:26 -0000 1.73
+++ util.c 23 Dec 2016 09:47:11 -0000 1.74
@@ -1526,15 +1526,17 @@
int buf_write(buf_t *bp, const void *src, int size)
{
- int n = buf_avail(bp);
+ int n = 0;
+ if (bp->pos < bp->size) {
+ int n = bp->size - bp->pos - 1;
if (n > size)
n = size;
memcpy(bp->buf + bp->len, src, n);
- bp->pos += size;
bp->len += n;
- if (bp->len < bp->size)
bp->buf[bp->len] = '\0';
+ }
+ bp->pos += size;
return n;
}
@@ -1576,7 +1578,7 @@
len = utf8_encode(buf, c);
- if (buf_avail(bp) >= len) {
+ if (bp->pos + len < bp->size) {
memcpy(bp->buf + bp->len, buf, len);
bp->pos += len;
bp->len += len;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs util.c,
Charlie Gordon <=