aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-10-30 23:58:29 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-10-31 00:00:30 +0100
commitef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3 (patch)
tree623db7a6453e07d073f776ef37545430e131c823
parent2a351b150dbe133037afffef01375c39aacd9d74 (diff)
downloadtermo-ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3.tar.gz
termo-ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3.tar.xz
termo-ef29b7587d536bf8a9c68c0ecbe5e45cd5a3bec3.zip
Fix error handling in termo_strfkey()
If in any case snprintf() returned a negative value, we would mishandle it.
-rw-r--r--README.adoc1
-rw-r--r--termo.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/README.adoc b/README.adoc
index ce63059..ba458c0 100644
--- a/README.adoc
+++ b/README.adoc
@@ -5,6 +5,7 @@ termo
input. ncurses does a really terrible job at that, mainly wrt. mouse support
which seems to be utterly broken. If you can drag things in a terminal
application, such as in VIM, I can assure you it's not using ncurses for that.
+(At least not with ncurses older than 6.0.)
Since terminal I/O is really complicated and full of special cases, this project
doesn't aspire to also replace the output part of ncurses, but is rather
diff --git a/termo.c b/termo.c
index 704116b..38caba2 100644
--- a/termo.c
+++ b/termo.c
@@ -1444,7 +1444,7 @@ termo_strfkey (termo_t *tk, char *buffer, size_t len,
termo_key_t *key, termo_format_t format)
{
size_t pos = 0;
- size_t l = 0;
+ int l = 0;
struct modnames *mods = &modnames[
!!(format & TERMO_FORMAT_LONGMOD) +
@@ -1477,7 +1477,7 @@ termo_strfkey (termo_t *tk, char *buffer, size_t len,
{
l = snprintf (buffer + pos, len - pos,
wrapbracket ? "<^%c>" : "^%c", (char) codepoint);
- if(l <= 0)
+ if (l <= 0)
return pos;
pos += l;
return pos;