Skip to content

Commit

Permalink
Merge branch 'htop-dev:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex313031 authored Apr 29, 2024
2 parents a1d6fea + d2ec14f commit 3904c78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion RichString.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ in the source distribution for its full text.

#include "RichString.h"

#include <assert.h>
#include <ctype.h>
#include <limits.h> // IWYU pragma: keep
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -144,7 +146,8 @@ static inline int RichString_writeFromAscii(RichString* this, int attrs, const c
int newLen = from + len;
RichString_setLen(this, newLen);
for (int i = from, j = 0; i < newLen; i++, j++) {
this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (isprint(data[j]) ? data[j] : L'\xFFFD') } };
assert((unsigned char)data[j] <= SCHAR_MAX);
this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (isprint((unsigned char)data[j]) ? data[j] : L'\xFFFD') } };
}

return len;
Expand Down
2 changes: 1 addition & 1 deletion Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static const char* toFieldName(Hashtable* columns, int id, bool* enabled) {
}

static int toFieldIndex(Hashtable* columns, const char* str) {
if (isdigit(str[0])) {
if (isdigit((unsigned char)str[0])) {
// This "+1" is for compatibility with the older enum format.
int id = atoi(str) + 1;
if (toFieldName(columns, id, NULL)) {
Expand Down
20 changes: 16 additions & 4 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,18 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces
#ifdef HAVE_VSERVER
case VXID: xSnprintf(buffer, n, "%5u ", lp->vxid); break;
#endif
case CGROUP: xSnprintf(buffer, n, "%-*.*s ", Row_fieldWidths[CGROUP], Row_fieldWidths[CGROUP], lp->cgroup ? lp->cgroup : "N/A"); break;
case CCGROUP: xSnprintf(buffer, n, "%-*.*s ", Row_fieldWidths[CCGROUP], Row_fieldWidths[CCGROUP], lp->cgroup_short ? lp->cgroup_short : (lp->cgroup ? lp->cgroup : "N/A")); break;
case CONTAINER: xSnprintf(buffer, n, "%-*.*s ", Row_fieldWidths[CONTAINER], Row_fieldWidths[CONTAINER], lp->container_short ? lp->container_short : "N/A"); break;
case CGROUP:
xSnprintf(buffer, n, "%-*.*s ", Row_fieldWidths[CGROUP], Row_fieldWidths[CGROUP], lp->cgroup ? lp->cgroup : "N/A");
RichString_appendWide(str, attr, buffer);
return;
case CCGROUP:
xSnprintf(buffer, n, "%-*.*s ", Row_fieldWidths[CCGROUP], Row_fieldWidths[CCGROUP], lp->cgroup_short ? lp->cgroup_short : (lp->cgroup ? lp->cgroup : "N/A"));
RichString_appendWide(str, attr, buffer);
return;
case CONTAINER:
xSnprintf(buffer, n, "%-*.*s ", Row_fieldWidths[CONTAINER], Row_fieldWidths[CONTAINER], lp->container_short ? lp->container_short : "N/A");
RichString_appendWide(str, attr, buffer);
return;
case OOM: xSnprintf(buffer, n, "%4u ", lp->oom); break;
case IO_PRIORITY: {
int klass = IOPriority_class(lp->ioPriority);
Expand Down Expand Up @@ -317,7 +326,10 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces
}
xSnprintf(buffer, n, "%5lu ", lp->ctxt_diff);
break;
case SECATTR: snprintf(buffer, n, "%-*.*s ", Row_fieldWidths[SECATTR], Row_fieldWidths[SECATTR], lp->secattr ? lp->secattr : "N/A"); break;
case SECATTR:
snprintf(buffer, n, "%-*.*s ", Row_fieldWidths[SECATTR], Row_fieldWidths[SECATTR], lp->secattr ? lp->secattr : "N/A");
RichString_appendWide(str, attr, buffer);
return;
case AUTOGROUP_ID:
if (lp->autogroup_id != -1) {
xSnprintf(buffer, n, "%4ld ", lp->autogroup_id);
Expand Down

0 comments on commit 3904c78

Please sign in to comment.