Subject: bug#75024: Fix check for underlining capability on ttys

From: Gerd Möllmann <[email-masked]>
Date: Fri, 07 Mar 2025 20:27:29 +0100

Stefan Kangas <[email-masked]> writes:

>> -#define TTY_CAP_UNDERLINE_STYLED	(0x32 & TTY_CAP_UNDERLINE)
>> +enum
>> +{
>> +  TTY_CAP_INVERSE = 1 << 1,
>> +  TTY_CAP_UNDERLINE = 1 << 2,
>> +  TTY_CAP_BOLD = 1 << 3,
>> +  TTY_CAP_DIM = 1 << 4,
>> +  TTY_CAP_ITALIC = 1 << 5,
>> +  TTY_CAP_STRIKE_THROUGH = 1 << 6,
>> +  TTY_CAP_UNDERLINE_STYLED = 1 << 7
>> +};
>
> So the values where just wrong before?  IOW, TTY_CAP_INVERSE should be 2
> instead of 1, and so on?  Perhaps this should be mentioned in the commit
> message.
>
> I guess I'm a little bit surprised since most of these values have been
> there, AFAICT, since 2002.

The error was in the definition of TTY_CAP_UNDERLINE_STYLED, the rest are
just bit positions in a bit mask and their values don't matter as long
as they are different.

By defining TTY_CAP_UNDERLINE_STYLED the way it was, it was == to
TM_CAP_UNDERLINE and things went wrong. Took me some time to find back
then because I couldn't imagine an error there.

Making it an enum is for the sake of LLDB which can't handle macros.