From 32ec3cc8222b5f3741cbfefd990d273a85bf2f9f Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Mon, 18 May 2020 18:48:53 +0100 Subject: [PATCH] proc_view: fix man page string parse. --- src/bin/ui/ui_process_view.c | 3 ++- src/bin/ui/util.c | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/bin/ui/util.c diff --git a/src/bin/ui/ui_process_view.c b/src/bin/ui/ui_process_view.c index 531cb29..9aa172b 100644 --- a/src/bin/ui/ui_process_view.c +++ b/src/bin/ui/ui_process_view.c @@ -1,5 +1,6 @@ #include "ui_process_view.h" #include "../system/process.h" +#include "util.c" typedef struct { int tid; @@ -39,7 +40,7 @@ _exe_response(const char *command) while ((fgets(buf, sizeof(buf), p)) != NULL) { - lines = eina_list_append(lines, elm_entry_markup_to_utf8(buf)); + lines = eina_list_append(lines, _man2entry(buf)); } pclose(p); diff --git a/src/bin/ui/util.c b/src/bin/ui/util.c new file mode 100644 index 0000000..5289598 --- /dev/null +++ b/src/bin/ui/util.c @@ -0,0 +1,44 @@ +static char * +_man2entry(const char *text) +{ + const char *p; + char *str; + void *tmp; + int i = 0, len = strlen(text) + 1; + + str = malloc(len); + p = text; + + while (*p) + { + if (*p == '<') + { + tmp = realloc(str, (len += 4)); + str = tmp; + memcpy(&str[i], "<", 4); + i += 4; + } + else if (*p == '>') + { + tmp = realloc(str, (len += 4)); + str = tmp; + memcpy(&str[i], ">", 4); + i += 4; + } + else if (*p == '\t') + { + tmp = realloc(str, (len += 8)); + str = tmp; + memcpy(&str[i], " ", 8); + i += 8; + } + else + { + str[i++] = *p; + } + p++; + } + str[i] = '\0'; + + return str; +}