Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc #359

Merged
merged 4 commits into from
Dec 2, 2020
Merged

Misc #359

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ void LinuxProcess_makeCommandStr(Process* this) {

mc->commStart = commStart;
mc->commEnd = commEnd;
return;
}

static void LinuxProcess_writeCommand(const Process* this, int attr, int baseAttr, RichString* str) {
Expand All @@ -537,9 +536,7 @@ static void LinuxProcess_writeCommand(const Process* this, int attr, int baseAtt
RichString_append(str, attr, lp->mergedCommand.str);

if (lp->mergedCommand.commEnd) {
if (lp->mergedCommand.separateComm) {
RichString_setAttrn(str, commAttr, commStart, commEnd - 1);
} else if (commStart == baseStart && highlightBaseName) {
if (!lp->mergedCommand.separateComm && commStart == baseStart && highlightBaseName) {
/* If it was matched with procExe's basename, make it bold if needed */
if (commEnd > baseEnd) {
RichString_setAttrn(str, A_BOLD | baseAttr, baseStart, baseEnd - 1);
Expand Down Expand Up @@ -611,7 +608,6 @@ static void LinuxProcess_writeCommandField(const Process *this, RichString *str,
RichString_append(str, CRT_colors[PROCESS_TREE], buffer);
LinuxProcess_writeCommand(this, attr, baseattr, str);
}
return;
}

static void LinuxProcess_writeField(const Process* this, RichString* str, ProcessField field) {
Expand Down
12 changes: 5 additions & 7 deletions linux/LinuxProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static inline uint64_t fast_strtoull_hex(char **str, int maxlen) {
--maxlen;

while (maxlen--) {
nibble = **str;
nibble = (unsigned char)**str;
if (!(valid_mask & (1 << (nibble & 0x1F))))
break;
if ((nibble < '0') || (nibble & ~0x20) > 'F')
Expand Down Expand Up @@ -1117,9 +1117,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
command[i] = '\n';
}
} else if (!tokenEnd) {
if (command[i] == '/') {
tokenStart = i + 1;
} else if (command[i] == '\\' && (!tokenStart || command[tokenStart - 1] == '\\')) {
if (command[i] == '/' || (command[i] == '\\' && (!tokenStart || command[tokenStart - 1] == '\\'))) {
tokenStart = i + 1;
} else if (command[i] == ':' && (command[i + 1] != '/' && command[i + 1] != '\\')) {
tokenEnd = i;
Expand Down Expand Up @@ -1148,7 +1146,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
}

lp->mergedCommand.maxLen = lastChar + 1; /* accommodate cmdline */
if (!process->comm || strcmp(command, process->comm)) {
if (!process->comm || !String_eq(command, process->comm)) {
process->basenameOffset = tokenEnd;
setCommand(process, command, lastChar + 1);
lp->procCmdlineBasenameOffset = tokenStart;
Expand All @@ -1161,7 +1159,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
(amtRead = xread(fd, command, sizeof(command) - 1)) > 0) {
command[amtRead - 1] = 0;
lp->mergedCommand.maxLen += amtRead - 1; /* accommodate comm */
if (!lp->procComm || strcmp(command, lp->procComm)) {
if (!lp->procComm || !String_eq(command, lp->procComm)) {
free(lp->procComm);
lp->procComm = xStrdup(command);
lp->mergedCommand.commChanged = true;
Expand All @@ -1188,7 +1186,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc
if (amtRead > 0) {
filename[amtRead] = 0;
lp->mergedCommand.maxLen += amtRead; /* accommodate exe */
if (!lp->procExe || strcmp(filename, lp->procExe)) {
if (!lp->procExe || !String_eq(filename, lp->procExe)) {
free(lp->procExe);
lp->procExe = xStrdup(filename);
lp->procExeLen = amtRead;
Expand Down