From e79fdcb194f81eaf40d6f973d413bc45c38c65ce Mon Sep 17 00:00:00 2001 From: axel Date: Mon, 31 Jul 2006 06:55:44 +1000 Subject: [PATCH] Provide fallback is struct winsize is not defined darcs-hash:20060730205544-ac50b-26f34eb04b56924baa34f560fd274cf38413b5f5.gz --- common.c | 5 +++++ configure.ac | 16 ++++++++++++++++ fallback.h | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/common.c b/common.c index cd7323440..80eaf1447 100644 --- a/common.c +++ b/common.c @@ -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() diff --git a/configure.ac b/configure.ac index e4ce5d353..4c2adcc66 100644 --- a/configure.ac +++ b/configure.ac @@ -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 +#include +#include + +#ifdef HAVE_SIGINFO_H +#include +#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 diff --git a/fallback.h b/fallback.h index 6bfaed635..d9a119a82 100644 --- a/fallback.h +++ b/fallback.h @@ -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 /**