From: Chet Ramey Date: Wed, 4 May 2022 15:18:04 +0000 (-0400) Subject: fix for setting RL_STATE_EOF in callback mode X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ef9cec8c48ab1ae3a16b1874a49bd1f58eaaca1;p=thirdparty%2Freadline.git fix for setting RL_STATE_EOF in callback mode --- diff --git a/callback.c b/callback.c index 1a3235f..69df77d 100644 --- a/callback.c +++ b/callback.c @@ -279,8 +279,11 @@ rl_callback_read_char (void) } /* Make sure application hooks can see whether we saw EOF. */ - if (rl_eof_found = eof) - RL_SETSTATE(RL_STATE_EOF); + if (eof > 0) + { + rl_eof_found = eof; + RL_SETSTATE(RL_STATE_EOF); + } if (rl_done) { diff --git a/doc/rltech.texi b/doc/rltech.texi index 6f7ffb9..fe64a42 100644 --- a/doc/rltech.texi +++ b/doc/rltech.texi @@ -2368,6 +2368,7 @@ history list. #include #include #include +#include #if defined (HAVE_STRING_H) # include @@ -2448,6 +2449,8 @@ main (argc, argv) @{ char *line, *s; + setlocale (LC_ALL, ""); + progname = argv[0]; initialize_readline (); /* Bind our completer. */ diff --git a/examples/excallback.c b/examples/excallback.c index 4206acf..923c923 100644 --- a/examples/excallback.c +++ b/examples/excallback.c @@ -50,6 +50,8 @@ Copyright (C) 1999 Jeff Solomon #include #include /* xxx - should make this more general */ +#include + #ifdef READLINE_LIBRARY # include "readline.h" #else @@ -104,6 +106,8 @@ main() { fd_set fds; + setlocale (LC_ALL, ""); + /* Adjust the terminal slightly before the handler is installed. Disable * canonical mode processing and set the input character time flag to be * non-blocking. diff --git a/examples/fileman.c b/examples/fileman.c index f8d0be7..2a8b097 100644 --- a/examples/fileman.c +++ b/examples/fileman.c @@ -417,7 +417,7 @@ com_help (arg) if (!printed) { - printf ("No commands match `%s'. Possibilties are:\n", arg); + printf ("No commands match `%s'. Possibilities are:\n", arg); for (i = 0; commands[i].name; i++) { diff --git a/examples/rl-callbacktest.c b/examples/rl-callbacktest.c index 3525ffd..4373398 100644 --- a/examples/rl-callbacktest.c +++ b/examples/rl-callbacktest.c @@ -2,7 +2,6 @@ #include #include #include -#include /* Used for select(2) */ #include @@ -13,6 +12,10 @@ #include #include +#ifdef HAVE_LOCALE_H +# include +#endif + /* Standard readline include files. */ #if defined (READLINE_LIBRARY) # include "readline.h" @@ -72,7 +75,6 @@ main (int c, char **v) fd_set fds; int r; - setlocale (LC_ALL, ""); /* Handle SIGWINCH */ diff --git a/examples/rl.c b/examples/rl.c index a5cf276..39e5b8e 100644 --- a/examples/rl.c +++ b/examples/rl.c @@ -38,6 +38,10 @@ extern void exit(); #endif +#ifdef HAVE_LOCALE_H +# include +#endif + #if defined (READLINE_LIBRARY) # include "posixstat.h" # include "readline.h" @@ -93,6 +97,10 @@ main (argc, argv) else progname++; +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""); +#endif + /* defaults */ prompt = "readline$ "; fd = nch = 0; diff --git a/examples/rlbasic.c b/examples/rlbasic.c index 6a9601f..1ce4da9 100644 --- a/examples/rlbasic.c +++ b/examples/rlbasic.c @@ -3,6 +3,10 @@ #include #include +#ifdef HAVE_LOCALE_H +# include +#endif + #if defined (READLINE_LIBRARY) # include "readline.h" # include "history.h" @@ -16,6 +20,10 @@ main (int c, char **v) { char *input; +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""); +#endif + for (;;) { input = readline ((char *)NULL); if (input == 0) diff --git a/examples/rlcat.c b/examples/rlcat.c index b494241..aabe0ca 100644 --- a/examples/rlcat.c +++ b/examples/rlcat.c @@ -45,6 +45,10 @@ extern void exit(); #endif +#ifdef HAVE_LOCALE_H +# include +#endif + #ifndef errno extern int errno; #endif @@ -79,6 +83,10 @@ main (argc, argv) char *temp; int opt, Vflag, Nflag; +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""): +#endif + progname = strrchr(argv[0], '/'); if (progname == 0) progname = argv[0]; diff --git a/examples/rlevent.c b/examples/rlevent.c index 8143cb0..1b7f4eb 100644 --- a/examples/rlevent.c +++ b/examples/rlevent.c @@ -44,6 +44,10 @@ extern int sleep(); extern void exit(); #endif +#ifdef HAVE_LOCALE_H +# include +#endif + #if defined (READLINE_LIBRARY) # include "posixstat.h" # include "readline.h" @@ -101,6 +105,10 @@ main (argc, argv) int opt, fd, nch; FILE *ifp; +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""); +#endif + progname = strrchr(argv[0], '/'); if (progname == 0) progname = argv[0]; diff --git a/examples/rlptytest.c b/examples/rlptytest.c index 9c42f8a..0008dd1 100644 --- a/examples/rlptytest.c +++ b/examples/rlptytest.c @@ -25,6 +25,10 @@ #include #endif +#ifdef HAVE_LOCALE_H +# include +#endif + #ifdef READLINE_LIBRARY # include "readline.h" #else @@ -315,6 +319,11 @@ int main() { int val; + +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""); +#endif + val = openpty (&masterfd, &slavefd, NULL, NULL, NULL); if (val == -1) return -1; diff --git a/examples/rltest.c b/examples/rltest.c index 65abe87..8b7c00c 100644 --- a/examples/rltest.c +++ b/examples/rltest.c @@ -36,6 +36,10 @@ extern void exit(); #endif +#ifdef HAVE_LOCALE_H +# include +#endif + #ifdef READLINE_LIBRARY # include "readline.h" # include "history.h" @@ -52,6 +56,10 @@ main () char *temp, *prompt; int done; +#ifdef HAVE_SETLOCALE + setlocale (LC_ALL, ""); +#endif + temp = (char *)NULL; prompt = "readline$ "; done = 0;