Re: [hackers] [dmenu] drw.c: use the same pattern as ellipsis_width to check for infinite recursion || Hiltjo Posthuma
Hello,
> This is what I had initially but this caused some bug because it causes
> mismatch between drw_fontset_getwidth() vs the width that actually gets
> rendered. On the first call, drw_fontset_getwidth() will calculate the
> width with invalid_width being 0 but when rendering it will be non-zero
> which messes up some calculation.
I've attached a patch that fixes this.
> I'm also noticing now that if you put an invalid byte at the very end it
> fails to render the ellipsis when truncating the text. To reproduce try
> to put as many 'a' in there to push the invalid byte *just* beyond the
> width of the reigion.
>
> $ printf "aaaaa....aaaaa\xff" | ./dmenu
>
> I've attached a pic where there should be an ellipsis at the end but
> isn't.
>
> I remember testing this case and fixing it by doing the
> `invalid_width = -1` thing so that it gets initialized even when not
> rendering. But now it happens even after I revert this patch. Weird.
> I'll look into what's going wrong here and fix it.
This bug is not fixed yet. I had a bunch of unexpected things happen
last week and so I wasn't able to work on it. I did figure out the cause
of the bug though, if someone wants to work out a patch before I get to
this, feel free.
Basically, the issue seems to be here:
if (charexists) {
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
In the case of error, this sets `tmpw` to 0 instead of `invalid_width`
which is messing up the ellipsis calculation. I tried doing something
like this, which fixes certain cases, but still is buggy on some other
cases:
if (charexists) {
- drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
+ if (utf8err)
+ tmpw = invalid_width;
+ else
+ drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
- NRK
Received on Wed Jul 24 2024 - 19:41:57 CEST
This archive was generated by hypermail 2.3.0
: Wed Jul 24 2024 - 19:48:39 CEST