Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix call to attr_set for ncurses < 6 #24

Merged
merged 1 commit into from
Apr 23, 2018

Conversation

StefansM
Copy link
Contributor

Ncurses with ABI >= 6 support passing a color index to attr_set
through the opts pointer. This work-around is because the params
pointer must remain a short for backwards compatibility and the opts
pointer has never actually been used for anything else.

This commit adds an explicit ABI version check that uses the params
field when ncurses major version is < 6. I've used an explicit
preprocessor guard rather than always calling attr_set(..., p->color, &p->color) because p->color is an int, and it would overflow when
passed as the short params argument. Probably not a problem in
practice, but easy to avoid nonetheless.

Tested on Red Hat 7, which is where I noticed the original bug.

Ncurses with ABI >= 6 support passing a color index to `attr_set`
through the `opts` pointer. This work-around is because the `params`
pointer must remain a `short` for backwards compatibility and the `opts`
pointer has never actually been used for anything else.

This commit adds an explicit ABI version check that uses the `params`
field when ncurses major version is < 6. I've used an explicit
preprocessor guard  rather than always calling `attr_set(..., p->color,
&p->color)` because `p->color` is an `int`, and it would overflow when
passed as the `short params` argument. Probably not a problem in
practice, but easy to avoid nonetheless.
@StefansM StefansM merged commit f9b6213 into pipeseroni:master Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant