diff --git a/common.c b/common.c index f67e904b6..b693cad3e 100644 --- a/common.c +++ b/common.c @@ -24,7 +24,15 @@ parts of fish. #include #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include #include diff --git a/configure.ac b/configure.ac index 3c487e9f8..e22927ba7 100644 --- a/configure.ac +++ b/configure.ac @@ -263,7 +263,7 @@ AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, need AC_SEARCH_LIBS( setupterm, [ncurses curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish])] ) # Check for presense of various header files -AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h]) +AC_CHECK_HEADERS([getopt.h termio.h sys/resource.h term.h ncurses/term.h libintl.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h sys/termios.h]) AC_CHECK_HEADER([regex.h], [AC_DEFINE([HAVE_REGEX_H], [1], [Define to 1 if you have the header file.])], @@ -301,18 +301,25 @@ fi # Check if struct winsize exists -AC_MSG_CHECKING([if struct winsize exists]) +AC_MSG_CHECKING([if struct winsize and TIOCGWINSZ exist]) AC_LINK_IFELSE( [AC_LANG_PROGRAM([ #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif #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])], + [struct winsize termsize = {0}; TIOCGWINSZ;])], + [AC_MSG_RESULT(yes); AC_DEFINE([HAVE_WINSIZE], [1], [Define to 1 if the winsize struct and TIOCGWINSZ macro exist])], AC_MSG_RESULT(no)) # If we have a fwprintf in libc, test that it actually works. As of diff --git a/fish_pager.c b/fish_pager.c index e947a3625..cc934cffa 100644 --- a/fish_pager.c +++ b/fish_pager.c @@ -9,7 +9,14 @@ #include #include +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include #include diff --git a/input.c b/input.c index c057c259c..a17510121 100644 --- a/input.c +++ b/input.c @@ -17,7 +17,15 @@ implementation in fish is as of yet incomplete. #include #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include diff --git a/io.c b/io.c index 77e8e4fc9..d907a1725 100644 --- a/io.c +++ b/io.c @@ -12,7 +12,15 @@ Utilities for io redirection. #include #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include diff --git a/output.c b/output.c index 67def2dfd..657abe05e 100644 --- a/output.c +++ b/output.c @@ -11,7 +11,15 @@ #include #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include #include diff --git a/proc.c b/proc.c index b76fd0698..4ea9802ec 100644 --- a/proc.c +++ b/proc.c @@ -20,7 +20,15 @@ Some of the code in this file is based on code from the Glibc manual. #include #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include #include diff --git a/reader.c b/reader.c index 5cbb1f5e2..69abbd2ab 100644 --- a/reader.c +++ b/reader.c @@ -28,7 +28,15 @@ commence. #include #include #include + +#ifdef HAVE_SYS_TERMIOS_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H #include +#endif + #include #include #include