From 02cbe4775417d8de9fd85b259c7a799abd4a3164 Mon Sep 17 00:00:00 2001 From: smatz Date: Wed, 22 Oct 2008 20:23:50 +0000 Subject: (svn r14518) -Fix (r14514): forgot win32 and OS/2 files (glx) --- src/os2.cpp | 6 +++--- src/win32.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/os2.cpp b/src/os2.cpp index f5ee66cb1..704ffe4a7 100644 --- a/src/os2.cpp +++ b/src/os2.cpp @@ -196,7 +196,7 @@ bool InsertTextBufferClipboard(Textbuf *tb) { uint w; - if (tb->length + length >= tb->maxlength - 1) break; + if (tb->size + length + 1 > tb->maxsize) break; w = GetCharacterWidth(FS_NORMAL, (byte)*i); if (tb->maxwidth != 0 && width + tb->width + w > tb->maxwidth) break; @@ -205,11 +205,11 @@ bool InsertTextBufferClipboard(Textbuf *tb) length++; } - memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->length - tb->caretpos + 1); + memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->size - tb->caretpos); memcpy(tb->buf + tb->caretpos, text, length); tb->width += width; tb->caretxoffs += width; - tb->length += length; + tb->size += length; tb->caretpos += length; WinCloseClipbrd(hab); diff --git a/src/win32.cpp b/src/win32.cpp index 4c33bfbd4..fffb6e6ca 100644 --- a/src/win32.cpp +++ b/src/win32.cpp @@ -1138,7 +1138,7 @@ bool InsertTextBufferClipboard(Textbuf *tb) if (!IsPrintable(c)) break; byte len = Utf8CharLen(c); - if (tb->length + length >= tb->maxlength - len) break; + if (tb->size + length + len > tb->maxsize) break; byte charwidth = GetCharacterWidth(FS_NORMAL, c); if (tb->maxwidth != 0 && width + tb->width + charwidth > tb->maxwidth) break; @@ -1149,15 +1149,15 @@ bool InsertTextBufferClipboard(Textbuf *tb) if (length == 0) return false; - memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->length - tb->caretpos); + memmove(tb->buf + tb->caretpos + length, tb->buf + tb->caretpos, tb->size - tb->caretpos); memcpy(tb->buf + tb->caretpos, utf8_buf, length); tb->width += width; tb->caretxoffs += width; - tb->length += length; + tb->size += length; tb->caretpos += length; - assert(tb->length < tb->maxlength); - tb->buf[tb->length] = '\0'; // terminating zero + assert(tb->size <= tb->maxsize); + tb->buf[tb->size - 1] = '\0'; // terminating zero return true; } -- cgit v1.2.3-70-g09d2