mirror of https://github.com/xzeldon/htop.git
Don't store invisible trailing whitespace
This commit is contained in:
parent
ea9dc4ab74
commit
1a13b4d0f4
|
@ -470,6 +470,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
|
||||||
int amtRead = xread(fd, command, sizeof(command) - 1);
|
int amtRead = xread(fd, command, sizeof(command) - 1);
|
||||||
close(fd);
|
close(fd);
|
||||||
int tokenEnd = 0;
|
int tokenEnd = 0;
|
||||||
|
int lastChar = 0;
|
||||||
if (amtRead > 0) {
|
if (amtRead > 0) {
|
||||||
for (int i = 0; i < amtRead; i++)
|
for (int i = 0; i < amtRead; i++)
|
||||||
if (command[i] == '\0' || command[i] == '\n') {
|
if (command[i] == '\0' || command[i] == '\n') {
|
||||||
|
@ -477,14 +478,16 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
|
||||||
tokenEnd = i;
|
tokenEnd = i;
|
||||||
}
|
}
|
||||||
command[i] = ' ';
|
command[i] = ' ';
|
||||||
|
} else {
|
||||||
|
lastChar = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tokenEnd == 0) {
|
if (tokenEnd == 0) {
|
||||||
tokenEnd = amtRead;
|
tokenEnd = amtRead;
|
||||||
}
|
}
|
||||||
command[amtRead] = '\0';
|
command[lastChar + 1] = '\0';
|
||||||
process->basenameOffset = tokenEnd;
|
process->basenameOffset = tokenEnd;
|
||||||
setCommand(process, command, amtRead);
|
setCommand(process, command, lastChar + 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue