mirror of https://github.com/xzeldon/htop.git
Declare for loop variables inside the loop
This commit is contained in:
parent
7ff654f2df
commit
e103ec0317
|
@ -187,8 +187,8 @@ static inline void Process_writeCommand(const Process* this, int attr, int basea
|
||||||
const char* comm = this->comm;
|
const char* comm = this->comm;
|
||||||
|
|
||||||
if (this->settings->highlightBaseName || !this->settings->showProgramPath) {
|
if (this->settings->highlightBaseName || !this->settings->showProgramPath) {
|
||||||
int i, basename = 0;
|
int basename = 0;
|
||||||
for (i = 0; i < this->basenameOffset; i++) {
|
for (int i = 0; i < this->basenameOffset; i++) {
|
||||||
if (comm[i] == '/') {
|
if (comm[i] == '/') {
|
||||||
basename = i + 1;
|
basename = i + 1;
|
||||||
} else if (comm[i] == ':') {
|
} else if (comm[i] == ':') {
|
||||||
|
|
|
@ -198,12 +198,11 @@ static bool findCommInCmdline(const char *comm, const char *cmdline, int cmdline
|
||||||
/* Try to find procComm in tokenized cmdline - this might in rare cases
|
/* Try to find procComm in tokenized cmdline - this might in rare cases
|
||||||
* mis-identify a string or fail, if comm or cmdline had been unsuitably
|
* mis-identify a string or fail, if comm or cmdline had been unsuitably
|
||||||
* modified by the process */
|
* modified by the process */
|
||||||
const char *token;
|
|
||||||
const char *tokenBase;
|
const char *tokenBase;
|
||||||
size_t tokenLen;
|
size_t tokenLen;
|
||||||
const size_t commLen = strlen(comm);
|
const size_t commLen = strlen(comm);
|
||||||
|
|
||||||
for (token = cmdline + cmdlineBasenameOffset; *token; ) {
|
for (const char *token = cmdline + cmdlineBasenameOffset; *token; ) {
|
||||||
for (tokenBase = token; *token && *token != '\n'; ++token) {
|
for (tokenBase = token; *token && *token != '\n'; ++token) {
|
||||||
if (*token == '/') {
|
if (*token == '/') {
|
||||||
tokenBase = token + 1;
|
tokenBase = token + 1;
|
||||||
|
|
Loading…
Reference in New Issue