From: Chet Ramey Date: Tue, 13 Dec 2022 15:10:50 +0000 (-0500) Subject: changes for systems that lack select/pselect/gettimeofday; call application input... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e03d8fca9c36f72fd2a579479c085f96df8f73e;p=thirdparty%2Freadline.git changes for systems that lack select/pselect/gettimeofday; call application input available hook in rl_input_available; fix for redisplay of newline on a single empty input line --- diff --git a/CHANGELOG b/CHANGELOG index b2fcb53..c499df3 100644 --- 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() + diff --git a/MANIFEST b/MANIFEST index db689b3..24da6e8 100644 --- 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 diff --git a/Makefile.in b/Makefile.in index 2120daa..6c9de8b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 diff --git a/display.c b/display.c index 0e42930..2d3747f 100644 --- 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 index 0000000..5c2815e --- /dev/null +++ b/gettimeofday.c @@ -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 . +*/ + +#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 9118fed..17ad5fe 100644 --- 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 4cf933b..9952125 100644 --- 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 int diff --git a/parens.c b/parens.c index 57ce704..38b5e70 100644 --- a/parens.c +++ b/parens.c @@ -38,6 +38,7 @@ # include #endif +#include "rlstdc.h" #include "posixselect.h" #if defined (HAVE_STRING_H) diff --git a/posixselect.h b/posixselect.h index 9d40001..9d54e18 100644 --- a/posixselect.h +++ b/posixselect.h @@ -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 diff --git a/posixtime.h b/posixtime.h index e70ebec..8d5f426 100644 --- a/posixtime.h +++ b/posixtime.h @@ -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. */ diff --git a/readline.c b/readline.c index eb3ddc7..6f53845 100644 --- a/readline.c +++ b/readline.c @@ -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 diff --git a/rlprivate.h b/rlprivate.h index fc3171a..8067661 100644 --- a/rlprivate.h +++ b/rlprivate.h @@ -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