1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

make format_real_length left-collecting

This commit is contained in:
ailin-nemui 2017-05-05 14:45:13 +02:00
parent e405330e04
commit 451019d05d

View File

@ -480,27 +480,30 @@ int format_real_length(const char *str, int len)
start = str;
tmp = g_string_new(NULL);
while (*str != '\0' && len > 0) {
while (*str != '\0') {
oldstr = str;
if (*str == '%' && str[1] != '\0') {
str++;
if (*str != '%') {
adv = format_expand_styles(tmp, &str, NULL);
str += adv;
if (adv)
continue;
}
/* %% or unknown %code, written as-is */
if (*str != '%') {
if (--len == 0)
break;
if (adv) {
str += adv;
continue;
}
/* discount for unknown % */
if (--len < 0) {
str = oldstr;
break;
}
oldstr = str;
}
}
oldstr = str;
len -= string_advance(&str, utf8);
if (len < 0)
if (len < 0) {
str = oldstr;
break;
}
}
g_string_free(tmp, TRUE);