configure: check for tinfo matching ncurses
When we selected ncursesw, look for tinfow as well. Since ncurses-6.1 the binary compatibility between tinfo and tinfow disappeared, resulting in crashes and other odd behaviour.
This change checks for tinfo or tinfow based on which ncurses we found to continue with.