[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH 16/17] handle builds on systems w/out termios.h
From: |
Mike Frysinger |
Subject: |
[Nano-devel] [PATCH 16/17] handle builds on systems w/out termios.h |
Date: |
Tue, 21 Feb 2017 17:04:48 -0500 |
Windows doesn't have this, so add some build time checks'
---
configure.ac | 2 +-
src/nano.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 432de4242baf..b37d3196e6a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,7 +57,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are
placed to.])
dnl Checks for header files.
-AC_CHECK_HEADERS(libintl.h limits.h pwd.h sys/param.h)
+AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
diff --git a/src/nano.c b/src/nano.c
index c6f2cef9ef88..b9c064292a86 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -34,7 +34,9 @@
#ifdef ENABLE_UTF8
#include <langinfo.h>
#endif
+#ifdef HAVE_TERMIOS_H
#include <termios.h>
+#endif
#include <getopt.h>
#ifndef NANO_TINY
#include <sys/ioctl.h>
@@ -48,7 +50,12 @@ static int oldinterval = -1;
static bool no_rcfiles = FALSE;
/* Should we ignore all rcfiles? */
#endif
+#ifdef HAVE_TERMIOS_H
static struct termios oldterm;
+#else
+# define tcsetattr(...)
+# define tcgetattr(...)
+#endif
/* The user's original terminal settings. */
static struct sigaction act;
/* Used to set up all our fun signal handlers. */
@@ -1413,23 +1420,27 @@ void do_toggle_void(void)
* settings. */
void disable_extended_io(void)
{
+#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_lflag &= ~IEXTEN;
term.c_oflag &= ~OPOST;
tcsetattr(0, TCSANOW, &term);
+#endif
}
/* Disable interpretation of the special control keys in our terminal
* settings. */
void disable_signals(void)
{
+#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_lflag &= ~ISIG;
tcsetattr(0, TCSANOW, &term);
+#endif
}
#ifndef NANO_TINY
@@ -1437,11 +1448,13 @@ void disable_signals(void)
* settings. */
void enable_signals(void)
{
+#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_lflag |= ISIG;
tcsetattr(0, TCSANOW, &term);
+#endif
}
#endif
@@ -1449,22 +1462,26 @@ void enable_signals(void)
* settings. */
void disable_flow_control(void)
{
+#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_iflag &= ~IXON;
tcsetattr(0, TCSANOW, &term);
+#endif
}
/* Enable interpretation of the flow control characters in our terminal
* settings. */
void enable_flow_control(void)
{
+#ifdef HAVE_TERMIOS_H
struct termios term;
tcgetattr(0, &term);
term.c_iflag |= IXON;
tcsetattr(0, TCSANOW, &term);
+#endif
}
/* Set up the terminal state. Put the terminal in raw mode (read one
--
2.11.1
- [Nano-devel] [PATCH 04/17] drop various str fallback functions, (continued)
- [Nano-devel] [PATCH 04/17] drop various str fallback functions, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 01/17] configure: require autoconf-2.69/automake-1.14, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 03/17] add support for gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 08/17] assume getopt_long support is always available, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 07/17] assume regex.h support is always available, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 12/17] fix build on systems w/out pwd.h, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 09/17] drop glib fallback for snprintf/vsnprintf, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 17/17] pull in sys_wait module from gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 14/17] pull in lstat module from gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 13/17] add an explicit test for set_escdelay, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 16/17] handle builds on systems w/out termios.h,
Mike Frysinger <=
- [Nano-devel] [PATCH 02/17] gettext: update to 0.18.3 release, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 11/17] pull in glob module from gnulib, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 10/17] drop wchar.h/wctype.h/stdarg.h checks, Mike Frysinger, 2017/02/21
- [Nano-devel] [PATCH 15/17] handle deficient signal systems, Mike Frysinger, 2017/02/21
- Re: [Nano-devel] [PATCH 00/17 v3] update autotools & add gnulib support, Benno Schulenberg, 2017/02/22