forked from external/yambar
particle/string: simplify; no need to call c32len(wtext) twice
This commit is contained in:
parent
36a4250a96
commit
1b03bd6bc0
1 changed files with 13 additions and 17 deletions
|
@ -179,24 +179,20 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
size_t chars = c32len(wtext);
|
||||
|
||||
/* Truncate, if necessary */
|
||||
if (p->max_len > 0) {
|
||||
const size_t len = c32len(wtext);
|
||||
if (len > p->max_len) {
|
||||
if (p->max_len > 0 && chars > p->max_len) {
|
||||
size_t end = p->max_len;
|
||||
if (end >= 1) {
|
||||
/* "allocate" room for three dots at the end */
|
||||
end -= 1;
|
||||
}
|
||||
|
||||
size_t end = p->max_len;
|
||||
if (end >= 1) {
|
||||
/* "allocate" room for three dots at the end */
|
||||
end -= 1;
|
||||
}
|
||||
|
||||
if (p->max_len > 1) {
|
||||
wtext[end] = U'…';
|
||||
wtext[end + 1] = U'\0';
|
||||
chars = end + 1;
|
||||
} else {
|
||||
wtext[end] = U'\0';
|
||||
chars = 0;
|
||||
}
|
||||
if (p->max_len > 1) {
|
||||
wtext[end] = U'…';
|
||||
wtext[end + 1] = U'\0';
|
||||
chars = end + 1;
|
||||
} else {
|
||||
wtext[end] = U'\0';
|
||||
chars = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue