diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-22 22:56:28 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-23 18:14:35 -0300 |
commit | 54f8d8154bf69d5f8477e3b067f41c6611a02944 (patch) | |
tree | 1d7ea03b4b58f627864cb1bda3a7167734377cf9 | |
parent | ade7993fcb468433d28e569e16e90de4251114ab (diff) |
Do not trust isalpha(c) for values > 255.
Fixes #174.
Conflicts:
Panel.c
-rw-r--r-- | AvailableColumnsPanel.c | 2 | ||||
-rw-r--r-- | CategoriesPanel.c | 2 | ||||
-rw-r--r-- | ColumnsPanel.c | 2 | ||||
-rw-r--r-- | IncSet.c | 2 | ||||
-rw-r--r-- | Panel.c | 2 | ||||
-rw-r--r-- | RichString.c | 2 | ||||
-rw-r--r-- | htop.c | 2 |
7 files changed, 7 insertions, 7 deletions
diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c index 70d75807..6865b8bc 100644 --- a/AvailableColumnsPanel.c +++ b/AvailableColumnsPanel.c @@ -54,7 +54,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) { } default: { - if (isalpha(ch)) + if (ch < 255 && isalpha(ch)) result = Panel_selectByTyping(super, ch); break; } diff --git a/CategoriesPanel.c b/CategoriesPanel.c index fe55a88a..8cb442e4 100644 --- a/CategoriesPanel.c +++ b/CategoriesPanel.c @@ -97,7 +97,7 @@ static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) { break; } default: - if (isalpha(ch)) + if (ch < 255 && isalpha(ch)) result = Panel_selectByTyping(super, ch); if (result == BREAK_LOOP) result = IGNORED; diff --git a/ColumnsPanel.c b/ColumnsPanel.c index b2fa5b5e..918ee320 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -100,7 +100,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { } default: { - if (isalpha(ch)) + if (ch < 255 && isalpha(ch)) result = Panel_selectByTyping(super, ch); if (result == BREAK_LOOP) result = IGNORED; @@ -151,7 +151,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue } } doSearch = false; - } else if (isprint((char)ch) && (mode->index < INCMODE_MAX)) { + } else if (ch < 255 && isprint((char)ch) && (mode->index < INCMODE_MAX)) { mode->buffer[mode->index] = ch; mode->index++; mode->buffer[mode->index] = 0; @@ -431,7 +431,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) { this->eventHandlerState = calloc(100, 1); char* buffer = this->eventHandlerState; - if (isalnum(ch)) { + if (ch < 255 && isalnum(ch)) { int len = strlen(buffer); if (len < 99) { buffer[len] = ch; diff --git a/RichString.c b/RichString.c index 51914b08..22ffecb5 100644 --- a/RichString.c +++ b/RichString.c @@ -128,7 +128,7 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char* int newLen = from + len; RichString_setLen(this, newLen); for (int i = from, j = 0; i < newLen; i++, j++) - this->chptr[i] = (isprint(data_c[j]) ? data_c[j] : '?') | attrs; + this->chptr[i] = (data_c[j] >= 32 ? data_c[j] : '?') | attrs; this->chptr[newLen] = 0; } @@ -381,7 +381,7 @@ int main(int argc, char** argv) { continue; } - if (isdigit((char)ch)) { + if (ch < 255 && isdigit((char)ch)) { if (Panel_size(panel) == 0) continue; pid_t pid = ch-48 + acc; for (int i = 0; i < ProcessList_size(pl); i++) { |