summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Poole <netstar@gmail.com>2020-05-18 18:48:53 +0100
committerAlastair Poole <netstar@gmail.com>2020-05-18 18:48:53 +0100
commit32ec3cc8222b5f3741cbfefd990d273a85bf2f9f (patch)
tree19bb3162bd6a641db1417872fa59cecd5f009630
parent1532038b5d8cb958e3e625d2a8ea41a2f72eaf62 (diff)
proc_view: fix man page string parse.
-rw-r--r--src/bin/ui/ui_process_view.c3
-rw-r--r--src/bin/ui/util.c44
2 files changed, 46 insertions, 1 deletions
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 @@
1#include "ui_process_view.h" 1#include "ui_process_view.h"
2#include "../system/process.h" 2#include "../system/process.h"
3#include "util.c"
3 4
4typedef struct { 5typedef struct {
5 int tid; 6 int tid;
@@ -39,7 +40,7 @@ _exe_response(const char *command)
39 40
40 while ((fgets(buf, sizeof(buf), p)) != NULL) 41 while ((fgets(buf, sizeof(buf), p)) != NULL)
41 { 42 {
42 lines = eina_list_append(lines, elm_entry_markup_to_utf8(buf)); 43 lines = eina_list_append(lines, _man2entry(buf));
43 } 44 }
44 45
45 pclose(p); 46 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 @@
1static char *
2_man2entry(const char *text)
3{
4 const char *p;
5 char *str;
6 void *tmp;
7 int i = 0, len = strlen(text) + 1;
8
9 str = malloc(len);
10 p = text;
11
12 while (*p)
13 {
14 if (*p == '<')
15 {
16 tmp = realloc(str, (len += 4));
17 str = tmp;
18 memcpy(&str[i], "&lt;", 4);
19 i += 4;
20 }
21 else if (*p == '>')
22 {
23 tmp = realloc(str, (len += 4));
24 str = tmp;
25 memcpy(&str[i], "&gt;", 4);
26 i += 4;
27 }
28 else if (*p == '\t')
29 {
30 tmp = realloc(str, (len += 8));
31 str = tmp;
32 memcpy(&str[i], " ", 8);
33 i += 8;
34 }
35 else
36 {
37 str[i++] = *p;
38 }
39 p++;
40 }
41 str[i] = '\0';
42
43 return str;
44}