Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions ext/curses/curses.c
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,7 @@ window_setscrreg(VALUE obj, VALUE top, VALUE bottom)
#endif
}

#if defined(USE_COLOR) && (defined(HAVE_WCOLOR_SET) || defined(HAVE_WATTR_SET))
#if defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET))
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compile-time guard for defining window_color_set was tightened to require HAVE_WATTR_GET when using HAVE_WATTR_SET, but the later rb_define_method(..., "color_set", window_color_set, ...) guard in this file still uses HAVE_WATTR_SET alone. On platforms where HAVE_WATTR_SET is defined but HAVE_WATTR_GET is not (and HAVE_WCOLOR_SET is also not defined), this will lead to a build failure because window_color_set is not compiled but is still referenced. Please update the rb_define_method guard to match this new condition (or otherwise ensure window_color_set is always available when referenced).

Suggested change
#if defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET))
#if defined(USE_COLOR) && (defined(HAVE_WATTR_SET) || defined(HAVE_WCOLOR_SET))

Copilot uses AI. Check for mistakes.
/*
* Document-method: Curses::Window.color_set
* call-seq: color_set(col)
Expand All @@ -2810,13 +2810,11 @@ window_color_set(VALUE obj, VALUE col)
return Qfalse;
return (wattr_set(winp->window, attrs, NUM2INT(col), NULL) == OK) ? Qtrue : Qfalse;
}
#elif defined(HAVE_WATTR_SET)
return (wattr_set(winp->window, 0, NUM2INT(col), NULL) == OK) ? Qtrue : Qfalse;
#else
return (wcolor_set(winp->window, NUM2INT(col), NULL) == OK) ? Qtrue : Qfalse;
#endif
Comment on lines 2814 to 2815
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #endif comment immediately after this function still reflects the old compile-time condition (HAVE_WCOLOR_SET || HAVE_WATTR_SET), but the opening #if now requires HAVE_WATTR_GET when using HAVE_WATTR_SET. Please update that trailing comment to match the new guard so future edits don't accidentally reintroduce the mismatch.

Copilot uses AI. Check for mistakes.
}
#endif /* defined(USE_COLOR) && (defined(HAVE_WCOLOR_SET) || defined(HAVE_WATTR_SET)) */
#endif /* defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET)) */

/*
* Document-method: Curses::Window.scroll
Expand Down Expand Up @@ -5286,9 +5284,9 @@ Init_curses(void)
rb_define_method(cWindow, "move", window_move, 2);
rb_define_method(cWindow, "move_relative", window_move_relative, 2);
rb_define_method(cWindow, "setpos", window_setpos, 2);
#if defined(USE_COLOR) && (defined(HAVE_WCOLOR_SET) || defined(HAVE_WATTR_SET))
#if defined(USE_COLOR) && ((defined(HAVE_WATTR_SET) && defined(HAVE_WATTR_GET)) || defined(HAVE_WCOLOR_SET))
rb_define_method(cWindow, "color_set", window_color_set, 1);
#endif /* USE_COLOR && (HAVE_WCOLOR_SET || HAVE_WATTR_SET) */
#endif
rb_define_method(cWindow, "cury", window_cury, 0);
rb_define_method(cWindow, "curx", window_curx, 0);
rb_define_method(cWindow, "maxy", window_maxy, 0);
Expand Down