Provide fallback is struct winsize is not defined

darcs-hash:20060730205544-ac50b-26f34eb04b56924baa34f560fd274cf38413b5f5.gz
This commit is contained in:
axel 2006-07-31 06:55:44 +10:00
parent 60f0533821
commit e79fdcb194
3 changed files with 31 additions and 0 deletions

View file

@ -1412,10 +1412,15 @@ int acquire_lock_file( const char *lockfile, const int timeout, int force )
void common_handle_winch( int signal )
{
#ifdef HAVE_WINSIZE
if (ioctl(1,TIOCGWINSZ,&termsize)!=0)
{
return;
}
#else
termsize.ws_col = 80;
termsizews_row = 24;
#endif
}
int common_get_width()

View file

@ -286,6 +286,22 @@ else
AC_MSG_RESULT(no)
fi
# Check if struct winsize exists
AC_MSG_CHECKING([if struct winsize exists])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([
#include <sys/types.h>
#include <signal.h>
#include <sys/ioctl.h>
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif],
[struct winsize termsize; ioctl(1,TIOCGWINSZ,&termsize);])],
[AC_MSG_RESULT(yes); AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct exists])],
AC_MSG_RESULT(no))
# If we have a fwprintf in libc, test that it actually works. As of
# March 2006, it is broken under Dragonfly BSD.
if test "$ac_cv_func_fwprintf" = yes; then

View file

@ -43,6 +43,16 @@ typedef int tputs_arg_t;
typedef char tputs_arg_t;
#endif
#ifndef HAVE_WINSIZE
struct winsize
{
unsigned short ws_row;
unsigned short ws_col;
}
;
#endif
#ifdef TPUTS_KLUDGE
/**