Strpool is not StrBuf. Fix ecf109900f

This commit is contained in:
pancake 2018-07-05 11:40:59 +02:00
parent 28531f9deb
commit 685ce4e0ed
3 changed files with 14 additions and 19 deletions

View File

@ -297,7 +297,7 @@ R_API int r_cons_less_str(const char *str, const char *exitkeys) {
r_list_free (mla[i]); r_list_free (mla[i]);
} }
free (mla); free (mla);
if (rx) r_regex_free (rx); r_regex_free (rx);
free (lines); free (lines);
free (p); free (p);
r_cons_reset_colors (); r_cons_reset_colors ();

View File

@ -305,43 +305,36 @@ R_API int r_core_visual_hud(RCore *core) {
return (int) (size_t) p; return (int) (size_t) p;
} }
static void append_help_to_strpool(RStrpool *p, const char *title, const char **help) { static void append_help(RStrBuf *p, const char *title, const char **help) {
int i, max_length, padding = 0; int i, max_length = 0, padding = 0;
RCons *cons = r_cons_singleton (); RCons *cons = r_cons_singleton ();
const char *pal_args_color = cons->color ? cons->pal.args : "", const char *pal_args_color = cons->color ? cons->pal.args : "",
*pal_help_color = cons->color ? cons->pal.help : "", *pal_help_color = cons->color ? cons->pal.help : "",
*pal_reset = cons->color ? cons->pal.reset : ""; *pal_reset = cons->color ? cons->pal.reset : "";
char strbuf[128];
for (i = 0; help[i]; i += 2) { for (i = 0; help[i]; i += 2) {
max_length = R_MAX (max_length, strlen (help[i]) ); max_length = R_MAX (max_length, strlen (help[i]));
} }
r_strbuf_appendf (p, "|%s:\n", title);
sprintf (strbuf, "|%s:\n", title);
r_strpool_memcat (p, strbuf, strlen (strbuf));
for (i = 0; help[i]; i += 2) { for (i = 0; help[i]; i += 2) {
padding = max_length - (strlen (help[i])); padding = max_length - (strlen (help[i]));
sprintf (strbuf, "| %s%s%*s %s%s%s\n", r_strbuf_appendf (p, "| %s%s%*s %s%s%s\n",
pal_args_color, help[i], pal_args_color, help[i],
padding, "", padding, "",
pal_help_color, help[i + 1], pal_reset); pal_help_color, help[i + 1], pal_reset);
r_strpool_memcat (p, strbuf, strlen (strbuf));
} }
} }
static int visual_help() { static int visual_help() {
int ret; RStrBuf *p = r_strbuf_new (NULL);
RStrpool *p = r_strpool_new (0);
if (!p) { if (!p) {
return 0; return 0;
} }
r_cons_clear00 (); r_cons_clear00 ();
append_help_to_strpool (p, "Visual mode help", help_msg_visual); append_help (p, "Visual mode help", help_msg_visual);
append_help_to_strpool (p, "Function Keys: (See 'e key.'), defaults to", append_help (p, "Function Keys: (See 'e key.'), defaults to", help_msg_visual_fn);
help_msg_visual_fn); int ret = r_cons_less_str (r_strbuf_get (p), "?");
r_strpool_append (p, ""); r_strbuf_free (p);
ret = r_cons_less_str (p->str, "?");
r_strpool_free (p);
return ret; return ret;
} }

View File

@ -6,7 +6,9 @@
R_API RStrBuf *r_strbuf_new(const char *str) { R_API RStrBuf *r_strbuf_new(const char *str) {
RStrBuf *s = R_NEW0 (RStrBuf); RStrBuf *s = R_NEW0 (RStrBuf);
if (str) r_strbuf_set (s, str); if (str) {
r_strbuf_set (s, str);
}
return s; return s;
} }