# HG changeset patch # User Mike Miller # Date 1389567107 18000 # Node ID d033b08e9b0e0366d07296012672a088b9cd52c4 # Parent 09ef57c61b3b9665749dded8b75f3876f80b8739 Detect and use appropriate terminal attribute functions (bug #41212) * configure.ac: Add AC_CHECK_FUNCS for tcgetattr and tcsetattr. * kpty.cpp (_tcgetattr, _tcsetattr): Define to the appropriate terminal attribute functions based on system library support, not OS type macros. Fixes build failures on non-Linux GNU-based systems. Based on a Debian patch to the kde4libs package. diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2186,7 +2186,7 @@ AC_CHECK_FUNCS([log1p log1pf pipe]) AC_CHECK_FUNCS([realpath resolvepath roundl]) AC_CHECK_FUNCS([select setgrent setpwent siglongjmp strsignal]) -AC_CHECK_FUNCS([tempnam tgammaf toascii]) +AC_CHECK_FUNCS([tcgetattr tcsetattr tempnam tgammaf toascii]) AC_CHECK_FUNCS([umask waitpid]) AC_CHECK_FUNCS([_kbhit]) diff --git a/libgui/qterminal/libqterminal/unix/kpty.cpp b/libgui/qterminal/libqterminal/unix/kpty.cpp --- a/libgui/qterminal/libqterminal/unix/kpty.cpp +++ b/libgui/qterminal/libqterminal/unix/kpty.cpp @@ -116,24 +116,24 @@ # define _NEW_TTY_CTRL #endif -#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__) || defined(__APPLE__) || defined (__DragonFly__) +#if defined(HAVE_TCGETATTR) +# define _tcgetattr(fd, ttmode) tcgetattr(fd, ttmode) +#elif defined(TIOCGETA) # define _tcgetattr(fd, ttmode) ioctl(fd, TIOCGETA, (char *)ttmode) +#elif defined(TCGETS) +# define _tcgetattr(fd, ttmode) ioctl(fd, TCGETS, (char *)ttmode) #else -# if defined(_HPUX_SOURCE) || defined(__Lynx__) || defined (__CYGWIN__) -# define _tcgetattr(fd, ttmode) tcgetattr(fd, ttmode) -# else -# define _tcgetattr(fd, ttmode) ioctl(fd, TCGETS, (char *)ttmode) -# endif +# error No method available to get terminal attributes #endif -#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__) || defined(__APPLE__) || defined (__DragonFly__) +#if defined(HAVE_TCSETATTR) && defined(TCSANOW) +# define _tcsetattr(fd, ttmode) tcsetattr(fd, TCSANOW, ttmode) +#elif defined(TIOCSETA) # define _tcsetattr(fd, ttmode) ioctl(fd, TIOCSETA, (char *)ttmode) +#elif defined(TCSETS) +# define _tcsetattr(fd, ttmode) ioctl(fd, TCSETS, (char *)ttmode) #else -# if defined(_HPUX_SOURCE) || defined(__CYGWIN__) -# define _tcsetattr(fd, ttmode) tcsetattr(fd, TCSANOW, ttmode) -# else -# define _tcsetattr(fd, ttmode) ioctl(fd, TCSETS, (char *)ttmode) -# endif +# error No method available to set terminal attributes #endif #include