From 3bb731c645d1bcde6ecf6ca23e44eb6655da8726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 10 Jan 2021 11:14:02 +0100 Subject: RichString_setAttrn: refactor to take a length instead of a stop index Fixes: #459 --- Process.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Process.c') diff --git a/Process.c b/Process.c index 1e2d53c0..9524dfbe 100644 --- a/Process.c +++ b/Process.c @@ -183,7 +183,8 @@ void Process_fillStarttimeBuffer(Process* this) { } static inline void Process_writeCommand(const Process* this, int attr, int baseattr, RichString* str) { - int start = RichString_size(str), finish = 0; + int start = RichString_size(str); + int len = 0; const char* comm = this->comm; if (this->settings->highlightBaseName || !this->settings->showProgramPath) { @@ -192,25 +193,24 @@ static inline void Process_writeCommand(const Process* this, int attr, int basea if (comm[i] == '/') { basename = i + 1; } else if (comm[i] == ':') { - finish = i + 1; + len = i + 1; break; } } - if (!finish) { + if (len == 0) { if (this->settings->showProgramPath) { start += basename; } else { comm += basename; } - finish = this->basenameOffset - basename; + len = this->basenameOffset - basename; } - finish += start - 1; } RichString_appendWide(str, attr, comm); if (this->settings->highlightBaseName) { - RichString_setAttrn(str, baseattr, start, finish); + RichString_setAttrn(str, baseattr, start, len); } } -- cgit v1.2.3