]> git.ipfire.org Git - thirdparty/readline.git/commitdiff
changes for systems that lack select/pselect/gettimeofday; call application input...
authorChet Ramey <chet.ramey@case.edu>
Tue, 13 Dec 2022 15:10:50 +0000 (10:10 -0500)
committerChet Ramey <chet.ramey@case.edu>
Tue, 13 Dec 2022 15:10:50 +0000 (10:10 -0500)
12 files changed:
CHANGELOG
MANIFEST
Makefile.in
display.c
gettimeofday.c [new file with mode: 0644]
input.c
kill.c
parens.c
posixselect.h
posixtime.h
readline.c
rlprivate.h

index b2fcb534e0935b612983f7b8aba80b4d546c215e..c499df32c3b1b080500077bf382315e25883379e 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1448,3 +1448,15 @@ configure.ac
          readline library to be linked against a shared termcap/curses library
          that configure finds. If the argument begins with `-l', use that
          library instead; updated INSTALL accordingly
+
+                               11/25/2022
+                               ----------
+gettimeofday.c
+       - add file from bash's lib/sh/gettimeofday.c, only compiled in if
+         HAVE_GETTIMEOFDAY is not defined
+
+Makefile.in
+       - gettimeofday.o: link in, it will not define any symbols if
+         HAVE_GETTIMEOFDAY is defined. This is for systems like _WIN32 that
+         don't have gettimeofday()
+
index db689b3779ab79d588b56c0c140896f1b4ea655d..24da6e8858e303683401b7f7282af52786ea62b1 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -82,6 +82,7 @@ vi_keymap.c   f
 vi_mode.c      f
 xfree.c                f
 xmalloc.c      f
+gettimeofday.c f
 history.c      f
 histexpand.c   f
 histfile.c     f
index 2120daa68ef3cb3a59c92d15e31fbf59817a1f40..6c9de8b585c9434b27294f255b3235a8f76e1b04 100644 (file)
@@ -120,7 +120,7 @@ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
           $(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
           $(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
           $(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
-          $(srcdir)/mbutil.c
+          $(srcdir)/mbutil.c $(srcdir)/gettimeofday.c
 
 # The header files for this library.
 HSOURCES = $(srcdir)/readline.h $(srcdir)/rldefs.h $(srcdir)/chardefs.h \
@@ -139,7 +139,7 @@ OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
          rltty.o complete.o bind.o isearch.o display.o signals.o \
          util.o kill.o undo.o macro.o input.o callback.o terminal.o \
          text.o nls.o misc.o $(HISTOBJ) $(TILDEOBJ) $(COLORSOBJ) \
-         xmalloc.o xfree.o compat.o
+         xmalloc.o xfree.o compat.o gettimeofday.o
 
 # The texinfo files which document this library.
 DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
@@ -454,6 +454,9 @@ xfree.o: ansi_stdlib.h
 xmalloc.o: ${BUILD_DIR}/config.h
 xmalloc.o: ansi_stdlib.h
 
+gettimeofday.o: ${BUILD_DIR}/config.h
+gettimeofday.o: posixtime.h
+
 colors.o: ${BUILD_DIR}/config.h colors.h
 colors.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
 colors.o: rlconf.h  
index 0e42930aefd2622228d24a20a8429a58875a06cc..2d3747f252367283e1e62a94de4043833e8bf5f8 100644 (file)
--- a/display.c
+++ b/display.c
@@ -3394,9 +3394,9 @@ _rl_update_final (void)
       puts_face (&last_line[_rl_screenwidth - 1 + woff],
                 &last_face[_rl_screenwidth - 1 + woff], 1);
     }
-  _rl_vis_botlin = 0;
-  if (botline_length > 0 || _rl_last_c_pos > 0)
+  if ((_rl_vis_botlin == 0 && botline_length == 0) || botline_length > 0 || _rl_last_c_pos > 0)
     rl_crlf ();
+  _rl_vis_botlin = 0;
   fflush (rl_outstream);
   rl_display_fixed++;
 }
diff --git a/gettimeofday.c b/gettimeofday.c
new file mode 100644 (file)
index 0000000..5c2815e
--- /dev/null
@@ -0,0 +1,35 @@
+/* gettimeofday.c - gettimeofday replacement using time() */
+
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+
+   This file is part of GNU Bash, the Bourne Again SHell.
+
+   Bash is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   Bash is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+
+#if !defined (HAVE_GETTIMEOFDAY)
+
+#include "posixtime.h"
+
+/* A version of gettimeofday that just sets tv_sec from time(3) */
+int
+gettimeofday (struct timeval *restrict tv, void *restrict tz)
+{
+  tv->tv_sec = (time_t) time ((time_t *)0);
+  tv->tv_usec = 0;
+  return 0;
+}
+#endif
diff --git a/input.c b/input.c
index 9118fed3d6458f782f5fe5fcb3f10aba1e951f7b..17ad5fe760511139fd4815a543870319231ef793 100644 (file)
--- a/input.c
+++ b/input.c
@@ -284,6 +284,13 @@ rl_gather_tyi (void)
     chars_avail = 0;
 #endif
 
+  if (result == -1 && rl_input_available_hook)
+    {
+      result = (*rl_input_available_hook) ();
+      if (result == 0)
+        result = -1;
+    }
+
 #if defined (O_NDELAY)
   if (result == -1)
     {
diff --git a/kill.c b/kill.c
index 4cf933b20096ec0ceafa573fa3f06d43f4a178af..995212564b3df682738f2f2b8e699048867964c0 100644 (file)
--- a/kill.c
+++ b/kill.c
@@ -865,6 +865,8 @@ _rl_bracketed_read_mbstring (char *mb, int mlen)
 
 /* A special paste command for Windows users. */
 #if defined (_WIN32)
+#define WIN32_LEAN_AND_MEAN
+
 #include <windows.h>
 
 int
index 57ce70458dad86f8532d009a5d2a1a9643067470..38b5e703775ef92d091f848fd21af2e921c5b935 100644 (file)
--- a/parens.c
+++ b/parens.c
@@ -38,6 +38,7 @@
 #  include <unistd.h>
 #endif
 
+#include "rlstdc.h"
 #include "posixselect.h"
 
 #if defined (HAVE_STRING_H)
index 9d4000164e28ffa203c2b6b7c46efaac2549d9ab..9d54e1889f89c199a6405bc5984caae87ae35e2e 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _POSIXSELECT_H_
 #define _POSIXSELECT_H_
 
-#if defined (FD_SET) && !defined (HAVE_SELECT)
+#if defined (FD_SET) && !defined (HAVE_SELECT) && !defined (_WIN32)
 #  define HAVE_SELECT 1
 #endif
 
index e70ebec67cf08e756b0f32af79234ff11de103d8..8d5f42611de9e95336aac1433a78f69f435fa557 100644 (file)
@@ -49,7 +49,7 @@ struct timeval
 #endif
 
 #if !HAVE_GETTIMEOFDAY
-extern int gettimeofday PARAMS((struct timeval *, void *));
+extern int gettimeofday PARAMS((struct timeval * restrict, void * restrict));
 #endif
 
 /* These exist on BSD systems, at least. */
index eb3ddc7092033077e2bd1fb6dcb63e4ea097412e..6f538454391f82d59d501ed2691203f5a41cf4aa 100644 (file)
@@ -596,8 +596,7 @@ readline_internal_charloop (void)
          if (RL_ISSTATE (RL_STATE_TIMEOUT))
            {
              RL_SETSTATE (RL_STATE_DONE);
-             rl_done = 1;
-             return 1;
+             return (rl_done = 1);
            }
 
          /* If we get here, we're not being called from something dispatched
index fc3171aa2d15ccb0e8f60777e0ba3c3d7f110832..806766131a0d6b4085b4775a6f8be1ed954949ad 100644 (file)
@@ -303,7 +303,7 @@ extern int _rl_pushed_input_available (void);
 
 extern int _rl_timeout_init (void);
 extern int _rl_timeout_handle_sigalrm (void);
-#if defined (_POSIXSELECT_H_) && !defined (__MINGW32__)
+#if defined (_POSIXSELECT_H_) && !defined (__MINGW32__) && (defined (HAVE_SELECT) || defined (HAVE_PSELECT))
 /* use as a sentinel for fd_set, struct timeval,  and sigset_t definitions */
 extern int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
 #endif