2005-03-28 Mark Mitchell * readline/aclocal.m4: Use AC_TRY_LINK to check for mbstate_t. * readline/complete.c (pwd.h): Guard with HAVE_PWD_H. (getpwent): Guard with HAVE_GETPWENT. (rl_username_completion_function): Guard use of getpwent. (endpwent): Likewise. * readline/config.h.in (HAVE_FCNTL): New macro. (HAVE_GETPWENT): Likewise. (HAVE_GETPWNAM): Likewise. (HAVE_GETPWUID): Likewise. (HAVE_PWD_H): Likewise. * readline/configure: Regenerated. * readline/configure.in: Handle MinGW when cross compiling. Check for getpwnam, getpwent, getpwuid, and pwd.h. * readline/display.c (rl_clear_screen): Treat Windows like DOS. (insert_some_chars): Likewise. (delete_chars): Likewise. * readline/shell.c (pwd.h): Guard with HAVE_PWD_H. (getpwuid): Guard with HAVE_GETPWUID. (sh_unset_nodelay_mode): Guard use of fnctl with HAVE_FNCTL_H. * readline/signals.c (rl_signal_handler): Don't use SIGALRM or SIGQUIT if not defined. Use "raise" rather than "kill". (rl_set_signals): Don't set handlers for SIGQUIT or SIGALRM if they are not defined. (rl_clear_signals): Likewise. * readline/tilde.c (pwd.h): Guard with HAVE_PWD_H. (getpwuid): Guard declaration with HAVE_GETPWUID. (getpwnam): Guard declaration with HAVE_GETPWNAM. (tilde_expand_word): Guard use of getpwnam with HAVE_GETPWNAM. Index: aclocal.m4 =================================================================== RCS file: /cvs/src/src/readline/aclocal.m4,v retrieving revision 1.7 retrieving revision 1.7.34.1 diff -c -5 -p -r1.7 -r1.7.34.1 *** aclocal.m4 27 May 2003 23:29:47 -0000 1.7 --- aclocal.m4 28 Mar 2005 19:34:24 -0000 1.7.34.1 *************** else *** 1661,1673 **** WCWIDTH_OBJ= fi AC_SUBST(WCWIDTH_OBJ) AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t, ! [AC_TRY_RUN([ ! #include ! int main () { mbstate_t ps; return 0; }], bash_cv_have_mbstate_t=yes, bash_cv_have_mbstate_t=no)]) --- 1661,1673 ---- WCWIDTH_OBJ= fi AC_SUBST(WCWIDTH_OBJ) AC_CACHE_CHECK([for mbstate_t], bash_cv_have_mbstate_t, ! [AC_TRY_LINK( ! [#include ], ! [int main () { mbstate_t ps; return 0; }], bash_cv_have_mbstate_t=yes, bash_cv_have_mbstate_t=no)]) Index: complete.c =================================================================== RCS file: /cvs/src/src/readline/complete.c,v retrieving revision 1.5 retrieving revision 1.5.60.1 diff -c -5 -p -r1.5 -r1.5.60.1 *** complete.c 8 Dec 2002 22:31:37 -0000 1.5 --- complete.c 28 Mar 2005 19:34:24 -0000 1.5.60.1 *************** *** 46,56 **** --- 46,58 ---- #include #if !defined (errno) extern int errno; #endif /* !errno */ + #ifdef HAVE_PWD_H #include + #endif #include "posixdir.h" #include "posixstat.h" /* System-specific feature definitions and include files. */ *************** typedef int QSFUNC (); *** 77,89 **** /* Unix version of a hidden file. Could be different on other systems. */ #define HIDDEN_FILE(fname) ((fname)[0] == '.') /* Most systems don't declare getpwent in if _POSIX_SOURCE is defined. */ ! #if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE) extern struct passwd *getpwent PARAMS((void)); ! #endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */ /* If non-zero, then this is the address of a function to call when completing a word would normally display the list of possible matches. This function is called instead of actually doing the display. It takes three arguments: (char **matches, int num_matches, int max_length) --- 79,92 ---- /* Unix version of a hidden file. Could be different on other systems. */ #define HIDDEN_FILE(fname) ((fname)[0] == '.') /* Most systems don't declare getpwent in if _POSIX_SOURCE is defined. */ ! #if defined(HAVE_GETPWENT) && \ ! (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)) extern struct passwd *getpwent PARAMS((void)); ! #endif /* defiend (HAVE_GETPWENT) && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */ /* If non-zero, then this is the address of a function to call when completing a word would normally display the list of possible matches. This function is called instead of actually doing the display. It takes three arguments: (char **matches, int num_matches, int max_length) *************** rl_username_completion_function (text, s *** 1660,1679 **** --- 1663,1686 ---- username = savestring (&text[first_char_loc]); namelen = strlen (username); setpwent (); } + #ifdef HAVE_GETPWENT while (entry = getpwent ()) { /* Null usernames should result in all users as possible completions. */ if (namelen == 0 || (STREQN (username, entry->pw_name, namelen))) break; } + #endif if (entry == 0) { + #ifdef HAVE_GETPWENT endpwent (); + #endif return ((char *)NULL); } else { value = (char *)xmalloc (2 + strlen (entry->pw_name)); Index: config.h.in =================================================================== RCS file: /cvs/src/src/readline/config.h.in,v retrieving revision 1.5 retrieving revision 1.5.56.1 diff -c -5 -p -r1.5 -r1.5.56.1 *** config.h.in 3 Mar 2003 18:52:27 -0000 1.5 --- config.h.in 28 Mar 2005 19:34:25 -0000 1.5.56.1 *************** *** 20,29 **** --- 20,32 ---- /* Define if the `S_IS*' macros in do not work properly. */ #undef STAT_MACROS_BROKEN #undef VOID_SIGHANDLER + /* Define if you have the fcntl function. */ + #undef HAVE_FCNTL + /* Define if you have the isascii function. */ #undef HAVE_ISASCII /* Define if you have the isxdigit function. */ #undef HAVE_ISXDIGIT *************** *** 41,50 **** --- 44,62 ---- #undef HAVE_MEMMOVE /* Define if you have the putenv function. */ #undef HAVE_PUTENV + /* Define if you have the getpwent function. */ + #undef HAVE_GETPWENT + + /* Define if you have the getpwnam function. */ + #undef HAVE_GETPWNAM + + /* Define if you have the getpwnam function. */ + #undef HAVE_GETPWUID + /* Define if you have the select function. */ #undef HAVE_SELECT /* Define if you have the setenv function. */ #undef HAVE_SETENV *************** *** 88,97 **** --- 100,112 ---- #undef HAVE_MEMORY_H /* Define if you have the header file. */ #undef HAVE_NDIR_H + /* Define if you have the header file. */ + #undef HAVE_PWD_H + /* Define if you have the header file. */ #undef HAVE_STDARG_H /* Define if you have the header file. */ #undef HAVE_STDLIB_H Index: configure.in =================================================================== RCS file: /cvs/src/src/readline/configure.in,v retrieving revision 1.6 retrieving revision 1.6.60.1 diff -c -5 -p -r1.6 -r1.6.60.1 *** configure.in 17 Dec 2002 02:52:32 -0000 1.6 --- configure.in 28 Mar 2005 19:34:27 -0000 1.6.60.1 *************** dnl load up the cross-building cache fil *** 54,73 **** dnl files as necessary if test "x$cross_compiling" = "xyes"; then case "${host}" in *-cygwin*) cross_cache=${srcdir}/cross-build/cygwin.cache - if test -r "${cross_cache}"; then - echo "loading cross-build cache file ${cross_cache}" - . ${cross_cache} - fi LOCAL_CFLAGS="$LOCAL_CFLAGS -I${srcdir}/../libtermcap" - unset cross_cache ;; *) echo "configure: cross-compiling for a non-cygwin target is not supported" >&2 ;; esac fi if test "x$cross_compiling" = "xyes"; then CROSS_COMPILING_FLAG=-DCROSS_COMPILING else --- 54,79 ---- dnl files as necessary if test "x$cross_compiling" = "xyes"; then case "${host}" in *-cygwin*) cross_cache=${srcdir}/cross-build/cygwin.cache LOCAL_CFLAGS="$LOCAL_CFLAGS -I${srcdir}/../libtermcap" ;; + *-mingw32*) + cross_cache=${srcdir}/cross-build/mingw.cache + ;; *) echo "configure: cross-compiling for a non-cygwin target is not supported" >&2 ;; esac + + if test "x$cross_cache" != "x"; then + if test -r "${cross_cache}"; then + echo "loading cross-build cache file ${cross_cache}" + . ${cross_cache} + fi + unset cross_cache + fi fi if test "x$cross_compiling" = "xyes"; then CROSS_COMPILING_FLAG=-DCROSS_COMPILING else *************** AC_TYPE_SIZE_T *** 110,127 **** AC_CHECK_TYPE(ssize_t, int) AC_HEADER_STAT AC_HEADER_DIRENT ! AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \ ! strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit) AC_FUNC_STRCOLL AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \ limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ ! termcap.h termios.h termio.h sys/file.h locale.h memory.h ) BASH_SYS_SIGNAL_VINTAGE BASH_SYS_REINSTALL_SIGHANDLERS BASH_FUNC_POSIX_SETJMP --- 116,135 ---- AC_CHECK_TYPE(ssize_t, int) AC_HEADER_STAT AC_HEADER_DIRENT ! AC_CHECK_FUNCS(fcntl lstat memmove putenv select setenv setlocale \ ! strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit \ ! getpwname getpwent getpwuid) AC_FUNC_STRCOLL AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \ limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ ! termcap.h termios.h termio.h sys/file.h locale.h memory.h \ ! pwd.h) BASH_SYS_SIGNAL_VINTAGE BASH_SYS_REINSTALL_SIGHANDLERS BASH_FUNC_POSIX_SETJMP Index: display.c =================================================================== RCS file: /cvs/src/src/readline/display.c,v retrieving revision 1.8 retrieving revision 1.8.20.1 diff -c -5 -p -r1.8 -r1.8.20.1 *** display.c 30 Dec 2003 07:25:18 -0000 1.8 --- display.c 28 Mar 2005 19:34:27 -0000 1.8.20.1 *************** _rl_clear_screen () *** 1905,1917 **** static void insert_some_chars (string, count, col) char *string; int count, col; { ! #ifdef __MSDOS__ _rl_output_some_chars (string, count); ! #else /* !__MSDOS__ */ /* DEBUGGING */ if (MB_CUR_MAX == 1 || rl_byte_oriented) if (count != col) fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col); --- 1905,1917 ---- static void insert_some_chars (string, count, col) char *string; int count, col; { ! #if defined(__MSDOS__) || defined(__MINGW32__) _rl_output_some_chars (string, count); ! #else /* !__MSDOS__ && !__MINGW32__ */ /* DEBUGGING */ if (MB_CUR_MAX == 1 || rl_byte_oriented) if (count != col) fprintf(stderr, "readline: debug: insert_some_chars: count (%d) != col (%d)\n", count, col); *************** delete_chars (count) *** 1957,1967 **** int count; { if (count > _rl_screenwidth) /* XXX */ return; ! #ifndef __MSDOS__ if (_rl_term_DC && *_rl_term_DC) { char *buffer; buffer = tgoto (_rl_term_DC, count, count); tputs (buffer, count, _rl_output_character_function); --- 1957,1967 ---- int count; { if (count > _rl_screenwidth) /* XXX */ return; ! #if !defined(__MSDOS__) && !defined(__MINGW32__) if (_rl_term_DC && *_rl_term_DC) { char *buffer; buffer = tgoto (_rl_term_DC, count, count); tputs (buffer, count, _rl_output_character_function); *************** delete_chars (count) *** 1970,1980 **** { if (_rl_term_dc && *_rl_term_dc) while (count--) tputs (_rl_term_dc, 1, _rl_output_character_function); } ! #endif /* !__MSDOS__ */ } void _rl_update_final () { --- 1970,1980 ---- { if (_rl_term_dc && *_rl_term_dc) while (count--) tputs (_rl_term_dc, 1, _rl_output_character_function); } ! #endif /* !__MSDOS__ && !__MINGW32__ */ } void _rl_update_final () { Index: shell.c =================================================================== RCS file: /cvs/src/src/readline/shell.c,v retrieving revision 1.4 retrieving revision 1.4.60.1 diff -c -5 -p -r1.4 -r1.4.60.1 *** shell.c 8 Dec 2002 22:31:37 -0000 1.4 --- shell.c 28 Mar 2005 19:34:27 -0000 1.4.60.1 *************** *** 48,58 **** --- 48,60 ---- #if defined (HAVE_LIMITS_H) # include #endif #include + #ifdef HAVE_PWD_H #include + #endif #include #include "rlstdc.h" #include "rlshell.h" *************** sh_get_home_dir () *** 154,166 **** --- 156,170 ---- { char *home_dir; struct passwd *entry; home_dir = (char *)NULL; + #ifdef HAVE_GETPWUID entry = getpwuid (getuid ()); if (entry) home_dir = entry->pw_dir; + #endif return (home_dir); } #if !defined (O_NDELAY) # if defined (FNDELAY) *************** sh_get_home_dir () *** 170,179 **** --- 174,184 ---- int sh_unset_nodelay_mode (fd) int fd; { + #ifdef HAVE_FNCTL int flags, bflags; if ((flags = fcntl (fd, F_GETFL, 0)) < 0) return -1; *************** sh_unset_nodelay_mode (fd) *** 190,197 **** --- 195,203 ---- if (flags & bflags) { flags &= ~bflags; return (fcntl (fd, F_SETFL, flags)); } + #endif return 0; } Index: signals.c =================================================================== RCS file: /cvs/src/src/readline/signals.c,v retrieving revision 1.5 retrieving revision 1.5.60.1 diff -c -5 -p -r1.5 -r1.5.60.1 *** signals.c 8 Dec 2002 22:31:37 -0000 1.5 --- signals.c 28 Mar 2005 19:34:27 -0000 1.5.60.1 *************** rl_signal_handler (sig) *** 125,135 **** RL_SETSTATE(RL_STATE_SIGHANDLER); #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) /* Since the signal will not be blocked while we are in the signal handler, ignore it until rl_clear_signals resets the catcher. */ ! if (sig == SIGINT || sig == SIGALRM) rl_set_sighandler (sig, SIG_IGN, &dummy_cxt); #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ switch (sig) { --- 125,139 ---- RL_SETSTATE(RL_STATE_SIGHANDLER); #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) /* Since the signal will not be blocked while we are in the signal handler, ignore it until rl_clear_signals resets the catcher. */ ! if (sig == SIGINT ! #ifdef SIGALRM ! || sig == SIGALRM ! #endif ! ) rl_set_sighandler (sig, SIG_IGN, &dummy_cxt); #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ switch (sig) { *************** rl_signal_handler (sig) *** 140,152 **** --- 144,160 ---- #if defined (SIGTSTP) case SIGTSTP: case SIGTTOU: case SIGTTIN: #endif /* SIGTSTP */ + #ifdef SIGALRM case SIGALRM: + #endif case SIGTERM: + #ifdef SIGQUIT case SIGQUIT: + #endif rl_cleanup_after_signal (); #if defined (HAVE_POSIX_SIGNALS) sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set); sigdelset (&set, sig); *************** rl_signal_handler (sig) *** 158,168 **** #if defined (__EMX__) signal (sig, SIG_ACK); #endif ! kill (getpid (), sig); /* Let the signal that we just sent through. */ #if defined (HAVE_POSIX_SIGNALS) sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); #else /* !HAVE_POSIX_SIGNALS */ --- 166,176 ---- #if defined (__EMX__) signal (sig, SIG_ACK); #endif ! raise (sig); /* Let the signal that we just sent through. */ #if defined (HAVE_POSIX_SIGNALS) sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); #else /* !HAVE_POSIX_SIGNALS */ *************** rl_set_signals () *** 275,286 **** --- 283,297 ---- if (rl_catch_signals && signals_set_flag == 0) { rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int); rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term); + #ifdef SIGQUIT rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit); + #endif + #ifdef SIGALRM oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm); if (oh == (SigHandler *)SIG_IGN) rl_sigaction (SIGALRM, &old_alrm, &dummy); #if defined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART) /* If the application using readline has already installed a signal *************** rl_set_signals () *** 288,297 **** --- 299,309 ---- automatically, so readline should just get out of the way. Since we tested for SIG_IGN above, we can just test for SIG_DFL here. */ if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART)) rl_sigaction (SIGALRM, &old_alrm, &dummy); #endif /* HAVE_POSIX_SIGNALS */ + #endif /* SIGALRM */ #if defined (SIGTSTP) rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp); #endif /* SIGTSTP */ *************** rl_clear_signals () *** 326,337 **** --- 338,353 ---- { sigemptyset (&dummy.sa_mask); rl_sigaction (SIGINT, &old_int, &dummy); rl_sigaction (SIGTERM, &old_term, &dummy); + #ifdef SIGQUIT rl_sigaction (SIGQUIT, &old_quit, &dummy); + #endif + #ifdef SIGALRM rl_sigaction (SIGALRM, &old_alrm, &dummy); + #endif #if defined (SIGTSTP) rl_sigaction (SIGTSTP, &old_tstp, &dummy); #endif /* SIGTSTP */ Index: tilde.c =================================================================== RCS file: /cvs/src/src/readline/tilde.c,v retrieving revision 1.4 retrieving revision 1.4.60.1 diff -c -5 -p -r1.4 -r1.4.60.1 *** tilde.c 8 Dec 2002 22:31:37 -0000 1.4 --- tilde.c 28 Mar 2005 19:34:27 -0000 1.4.60.1 *************** *** 41,64 **** #else # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ #include #include #include "tilde.h" #if defined (TEST) || defined (STATIC_MALLOC) static void *xmalloc (), *xrealloc (); #else # include "xmalloc.h" #endif /* TEST || STATIC_MALLOC */ ! #if !defined (HAVE_GETPW_DECLS) extern struct passwd *getpwuid PARAMS((uid_t)); extern struct passwd *getpwnam PARAMS((const char *)); ! #endif /* !HAVE_GETPW_DECLS */ #if !defined (savestring) #define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x)) #endif /* !savestring */ --- 41,66 ---- #else # include "ansi_stdlib.h" #endif /* HAVE_STDLIB_H */ #include + #ifdef HAVE_PWD_H #include + #endif /* HAVE_PWD_H */ #include "tilde.h" #if defined (TEST) || defined (STATIC_MALLOC) static void *xmalloc (), *xrealloc (); #else # include "xmalloc.h" #endif /* TEST || STATIC_MALLOC */ ! #if defined (HAVE_GETPWNAM) && !defined (HAVE_GETPW_DECLS) extern struct passwd *getpwuid PARAMS((uid_t)); extern struct passwd *getpwnam PARAMS((const char *)); ! #endif /* defined (HAVE_GETPWNAM) && !HAVE_GETPW_DECLS */ #if !defined (savestring) #define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x)) #endif /* !savestring */ *************** tilde_expand_word (filename) *** 345,354 **** --- 347,357 ---- } /* No preexpansion hook, or the preexpansion hook failed. Look in the password database. */ dirname = (char *)NULL; + #ifdef HAVE_GETPWNAM user_entry = getpwnam (username); if (user_entry == 0) { /* If the calling program has a special syntax for expanding tildes, and we couldn't find a standard expansion, then let them try. */ *************** tilde_expand_word (filename) *** 372,381 **** --- 375,385 ---- free (username); dirname = glue_prefix_and_suffix (user_entry->pw_dir, filename, user_len); } endpwent (); + #endif return (dirname); } #if defined (TEST)