summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2008-03-09 02:33:23 +0000
committerHisham Muhammad <hisham@gobolinux.org>2008-03-09 02:33:23 +0000
commit8fa33dc3365f0e27a5013748321def4bef937049 (patch)
treecf1498456001b55157c4ce9dcd516dd5226158e3 /Process.c
parentfa87ff02514cdd148cdcf8d24de0599a400f3918 (diff)
Add Unicode support, enabled with the --enable-unicode
flag, which requires libncursesw. Thanks to Sergej Pupykin!
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/Process.c b/Process.c
index ab66d5bb..0b551ebb 100644
--- a/Process.c
+++ b/Process.c
@@ -11,6 +11,7 @@ in the source distribution for its full text.
#include "CRT.h"
#include "String.h"
#include "Process.h"
+#include "RichString.h"
#include "debug.h"
@@ -265,23 +266,20 @@ static void Process_printTime(RichString* str, unsigned long t) {
}
static inline void Process_writeCommand(Process* this, int attr, int baseattr, RichString* str) {
+ int start = str->len;
+ RichString_append(str, attr, this->comm);
if (this->pl->highlightBaseName) {
- char* firstSpace = strchr(this->comm, ' ');
- if (firstSpace) {
- char* slash = firstSpace;
- while (slash > this->comm && *slash != '/')
- slash--;
- if (slash > this->comm) {
- slash++;
- RichString_appendn(str, attr, this->comm, slash - this->comm);
- }
- RichString_appendn(str, baseattr, slash, firstSpace - slash);
- RichString_append(str, attr, firstSpace);
- } else {
- RichString_append(str, baseattr, this->comm);
+ int finish = str->len - 1;
+ int space = RichString_findChar(str, ' ', start);
+ if (space != -1)
+ finish = space - 1;
+ for (;;) {
+ int slash = RichString_findChar(str, '/', start);
+ if (slash == -1 || slash > finish)
+ break;
+ start = slash + 1;
}
- } else {
- RichString_append(str, attr, this->comm);
+ RichString_setAttrn(str, baseattr, start, finish);
}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy