aboutsummaryrefslogtreecommitdiffstats
path: root/RichString.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2018-04-11 01:26:28 +0200
committerDaniel Lange <DLange@git.local>2018-04-11 01:52:54 +0200
commitdf568a576f7b44ac5a2b9b7222c7f39d9932f626 (patch)
treeb30ce33fd0d49398b52bf9a90b42304a7c32455a /RichString.c
parent2ee50d030178cede83eb9d0005fbc19f819d30fe (diff)
downloaddebian_htop-df568a576f7b44ac5a2b9b7222c7f39d9932f626.tar.gz
debian_htop-df568a576f7b44ac5a2b9b7222c7f39d9932f626.tar.bz2
debian_htop-df568a576f7b44ac5a2b9b7222c7f39d9932f626.zip
Imported Upstream version 2.2.0
Diffstat (limited to 'RichString.c')
-rw-r--r--RichString.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/RichString.c b/RichString.c
index e7dd4e8..370566a 100644
--- a/RichString.c
+++ b/RichString.c
@@ -63,6 +63,10 @@ typedef struct RichString_ {
}*/
+#ifndef CLAMP
+#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
+#endif
+
#define charBytes(n) (sizeof(CharType) * (n))
static void RichString_extendLen(RichString* this, int len) {
@@ -103,6 +107,7 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char*
inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
cchar_t* ch = this->chptr + start;
+ finish = CLAMP(finish, 0, this->chlen - 1);
for (int i = start; i <= finish; i++) {
ch->attr = attrs;
ch++;
@@ -132,6 +137,7 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char*
void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
chtype* ch = this->chptr + start;
+ finish = CLAMP(finish, 0, this->chlen - 1);
for (int i = start; i <= finish; i++) {
*ch = (*ch & 0xff) | attrs;
ch++;

© 2014-2024 Faster IT GmbH | imprint | privacy policy