From 6086140a91cf89a3b3f3edc01620f82ce4ee5423 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 18 Jul 2011 22:40:22 +0200 Subject: [PATCH] workaround for libncurses macro warnings --- Makefile.am | 1 + src/colors.c | 4 +++- src/hscroll.c | 5 +++-- src/ncfix.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 src/ncfix.h diff --git a/Makefile.am b/Makefile.am index 1c178d6..124fb49 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,6 +22,7 @@ ncmpc_headers = \ src/conf.h \ src/command.h \ src/ncu.h \ + src/ncfix.h \ src/player_command.h \ src/window.h \ src/title_bar.h \ diff --git a/src/colors.c b/src/colors.c index 361a7e9..9f5409b 100644 --- a/src/colors.c +++ b/src/colors.c @@ -19,6 +19,8 @@ #include "colors.h" #include "i18n.h" +#include "ncfix.h" + #ifdef ENABLE_COLORS #include "options.h" #endif @@ -267,7 +269,7 @@ colors_use(WINDOW *w, enum color id) assert(id > 0 && id < COLOR_END); - wattr_get(w, &attrs, &pair, NULL); + fix_wattr_get(w, &attrs, &pair, NULL); #ifdef ENABLE_COLORS if (options.enable_colors) { diff --git a/src/hscroll.c b/src/hscroll.c index 164f178..dafae93 100644 --- a/src/hscroll.c +++ b/src/hscroll.c @@ -19,6 +19,7 @@ #include "hscroll.h" #include "charset.h" +#include "ncfix.h" #include "glib_compat.h" #include @@ -87,7 +88,7 @@ hscroll_set(struct hscroll *hscroll, unsigned x, unsigned y, unsigned width, /* obtain the ncurses attributes and the current color, store them */ - wattr_get(hscroll->w, &hscroll->attrs, &hscroll->pair, NULL); + fix_wattr_get(hscroll->w, &hscroll->attrs, &hscroll->pair, NULL); hscroll->text = g_strdup(text); hscroll->offset = 0; @@ -121,7 +122,7 @@ hscroll_draw(struct hscroll *hscroll) assert(hscroll->text != NULL); /* set stored attributes and color */ - wattr_get(hscroll->w, &old_attrs, &old_pair, NULL); + fix_wattr_get(hscroll->w, &old_attrs, &old_pair, NULL); wattr_set(hscroll->w, hscroll->attrs, hscroll->pair, NULL); /* scroll the string, and draw it */ diff --git a/src/ncfix.h b/src/ncfix.h new file mode 100644 index 0000000..e63efa6 --- /dev/null +++ b/src/ncfix.h @@ -0,0 +1,46 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2011 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * Workarounds for libncurses oddities. + */ + +#ifndef NCFIX_H +#define NCFIX_H + +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#else +#include +#endif + +/** + * Workaround for "comparison will always evaluate as 'true' for the + * address of ...". By wrapping the macro in this inline function, + * gcc stops bitching about this. + */ +static inline int +fix_wattr_get(WINDOW *win, attr_t *attrs, short *pair, void *opts) +{ + (void)opts; + + return wattr_get(win, attrs, pair, opts); +} + +#endif -- 2.30.2