proc_view: fix man page string parse.

This commit is contained in:
Alastair Poole 2020-05-18 18:48:53 +01:00
parent 1532038b5d
commit 32ec3cc822
2 changed files with 46 additions and 1 deletions

View File

@ -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);

44
src/bin/ui/util.c Normal file
View File

@ -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], "&lt;", 4);
i += 4;
}
else if (*p == '>')
{
tmp = realloc(str, (len += 4));
str = tmp;
memcpy(&str[i], "&gt;", 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;
}