Why do we have `OCTAVE_CHECK_LIB_TERMLIB`?

Does anybody know why we check for tputs in a terminal library during configure?
octave: 870036573716 m4/acinclude.m4 (gnu.org)

dnl
dnl Find a suitable termlib to use.
dnl
AC_DEFUN([OCTAVE_CHECK_LIB_TERMLIB], [
  TERM_LIBS=
  ac_octave_save_LIBS="$LIBS"
  AC_SEARCH_LIBS([tputs],
                 [ncurses curses termcap terminfo termlib],
                 [], [])
  LIBS="$ac_octave_save_LIBS"
  case "$ac_cv_search_tputs" in
    -l*)
      TERM_LIBS="$ac_cv_search_tputs"
    ;;
    no)
      warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, or -ltermlib!"
      AC_MSG_WARN([$warn_termlibs])
    ;;
  esac

I can’t find where we use that function anywhere in our codebase.

Is it because some versions of the readline library require to also link to a terminal library?
Would it make sense to use the readline gnulib module instead?
readline\modules - gnulib.git - gnulib - GNU portability library

Their .m4 file contains a check for a terminal library on systems that need it:
readline.m4\m4 - gnulib.git - gnulib - GNU portability library

    dnl On some systems, -lreadline doesn't link without an additional
    dnl -lncurses or -ltermcap.
    dnl Try -lncurses before -ltermcap, because libtermcap is insecure
    dnl by design and obsolete since 1994. Try -lcurses last, because
    dnl libcurses is unusable on some old Unices.

Yes, that’s a very old check for a library that may be required for readline. If there is a gnulib module for readline capability, then it would probably be good to use it. Does it try to provide replacement functions or just the configure checks?

IIUC, it first checks for the link flags in a configure test.
There is also a replacement function for readline:
readline.c\lib - gnulib.git - gnulib - GNU portability library

But that would probably not be enough for our use case. So, I’d guess we should still fail if their configure test can’t find a working library (and not use their replacement).

I pushed a change here that uses the gnulib module for readline detection and removes the separate terminal library detection:
octave: 00e2eafd1c0f (gnu.org)