Clean up the part of the code that fixed the glitch in ansi code (#14180)

This commit is contained in:
Vanellope 2019-05-29 18:10:57 +09:00 committed by radare
parent 80970f9a14
commit 9a0d05a709

View File

@ -148,17 +148,14 @@ static const char *set_attr(RConsCanvas *c, const char *s) {
}
if (p != s) {
//since sometimes ANSI takes up too much buf
//this should be big enough
//at any time when the glitch comes back
//just tweak the size
char tmp[4096];
const int slen = R_MIN (p - s, sizeof (tmp) - 1);
RStrBuf *tmp = r_strbuf_new (NULL);
if (!tmp) {
return NULL;
}
const int slen = p - s;
if (slen > 0) {
memcpy (tmp, s, slen);
tmp[slen] = 0;
// could be faster
c->attr = r_str_const (tmp);
r_strbuf_append_n (tmp, s, slen);
c->attr = r_str_const (r_strbuf_drain (tmp));
}
}
return p;