find_wininfo(
    buf_T	*buf,
    int		need_options,
    int		skip_diff_buffer UNUSED)
{
    wininfo_T	*wip;

    FOR_ALL_BUF_WININFO(buf, wip)
	if (wip->wi_win == curwin
#ifdef FEAT_DIFF
		&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
#endif

		&& (!need_options || wip->wi_optset))
	    break;

    // If no wininfo for curwin, use the first in the list (that doesn't have
    // 'diff' set and is in another tab page).
    // If "need_options" is TRUE skip entries that don't have options set,
    // unless the window is editing "buf", so we can copy from the window
    // itself.
    if (wip == NULL)
    {
#ifdef FEAT_DIFF
	if (skip_diff_buffer)
	{
	    FOR_ALL_BUF_WININFO(buf, wip)
		if (!wininfo_other_tab_diff(wip)
			&& (!need_options || wip->wi_optset
			    || (wip->wi_win != NULL
					     && wip->wi_win->w_buffer == buf)))
		    break;
	}
	else
#endif
	    wip = buf->b_wininfo;
    }
    return wip;
}
find_wininfo(
    buf_T	*buf,
    int		need_options,
    int		skip_diff_buffer UNUSED)
{
    wininfo_T	*wip;

    FOR_ALL_BUF_WININFO(buf, wip)
	if (wip->wi_win == curwin
#ifdef FEAT_DIFF
		&& (!skip_diff_buffer || !wininfo_other_tab_diff(wip))
#endif

		&& (!need_options || wip->wi_optset))
	    break;

     
     
     
     
     
    if (wip == NULL)
    {
#ifdef FEAT_DIFF
	if (skip_diff_buffer)
	{
	    FOR_ALL_BUF_WININFO(buf, wip)
		if (!wininfo_other_tab_diff(wip)
			&& (!need_options || wip->wi_optset
			    || (wip->wi_win != NULL
					     && wip->wi_win->w_buffer == buf)))
		    break;
	}
	else
#endif
	    wip = buf->b_wininfo;
    }
    return wip;
}