summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-08-20 00:31:48 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-08-20 00:31:48 -0300
commit8bd603cb68fb5dd768b5b23ffe0c6f09f5340ceb (patch)
treefe5506bbbd80dca2b318e7d89c51218f31d880a4
parent78be8201dc86c4d57226d845f04ac496cd64d9b6 (diff)
Make Unicode strings safe for ncurses 6 ABI.
Closes #241.
-rw-r--r--RichString.c8
-rw-r--r--RichString.h4
-rw-r--r--configure.ac5
3 files changed, 10 insertions, 7 deletions
diff --git a/RichString.c b/RichString.c
index 22ffecb5..ad90a0ac 100644
--- a/RichString.c
+++ b/RichString.c
@@ -32,8 +32,8 @@ in the source distribution for its full text.
#define RichString_size(this) ((this)->chlen)
#define RichString_sizeVal(this) ((this).chlen)
-#define RichString_begin(this) RichString (this); (this).chlen = 0; (this).chptr = (this).chstr;
-#define RichString_beginAllocated(this) (this).chlen = 0; (this).chptr = (this).chstr;
+#define RichString_begin(this) RichString (this); memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
+#define RichString_beginAllocated(this) memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
#define RichString_end(this) RichString_prune(&(this));
#ifdef HAVE_LIBNCURSESW
@@ -79,6 +79,7 @@ static void RichString_extendLen(RichString* this, int len) {
this->chptr = realloc(this->chptr, charBytes(len+1));
}
}
+
RichString_setChar(this, len, 0);
this->chlen = len;
}
@@ -155,9 +156,8 @@ int RichString_findChar(RichString* this, char c, int start) {
void RichString_prune(RichString* this) {
if (this->chlen > RICHSTRING_MAXLEN)
free(this->chptr);
+ memset(this, 0, sizeof(RichString));
this->chptr = this->chstr;
- this->chlen = 0;
- RichString_setChar(this, 0, 0);
}
void RichString_setAttr(RichString* this, int attrs) {
diff --git a/RichString.h b/RichString.h
index 971e3acb..3179bb97 100644
--- a/RichString.h
+++ b/RichString.h
@@ -30,8 +30,8 @@ in the source distribution for its full text.
#define RichString_size(this) ((this)->chlen)
#define RichString_sizeVal(this) ((this).chlen)
-#define RichString_begin(this) RichString (this); (this).chlen = 0; (this).chptr = (this).chstr;
-#define RichString_beginAllocated(this) (this).chlen = 0; (this).chptr = (this).chstr;
+#define RichString_begin(this) RichString (this); memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
+#define RichString_beginAllocated(this) memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
#define RichString_end(this) RichString_prune(&(this));
#ifdef HAVE_LIBNCURSESW
diff --git a/configure.ac b/configure.ac
index f9e58eea..13b09a6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,7 +143,10 @@ fi
AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="yes")
if test "x$enable_unicode" = xyes; then
- AC_CHECK_LIB([ncursesw6], [refresh], [], [
+ AC_CHECK_LIB([ncursesw6], [refresh], [
+ AC_DEFINE(HAVE_LIBNCURSESW, 1, [])
+ LIBS="-lncursesw6 $LIBS "
+ ], [
AC_CHECK_LIB([ncursesw], [refresh], [], [
missing_libraries="$missing_libraries libncursesw"
AC_MSG_ERROR([You may want to use --disable-unicode or install libncursesw.])

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