* PATCH: Readline on MinGW
@ 2005-04-28 6:53 Mark Mitchell
2005-04-28 20:09 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Mark Mitchell @ 2005-04-28 6:53 UTC (permalink / raw)
To: bug-readline, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]
Chet --
This patch begins adding support for MinGW to readline. There is one
other patche required, which is *much* smaller, but somewhat more
complex; this patch is the large, mechanical patch. In general, this
patch checks for the availability of more things in autoconf, and then
disables uses of those things when they are not present. There are no
actual changes to the code itself, just additional conditionals, with
the exception that a call to "kill" is turned into a call to the POSIX
"raise", which, unlike "kill", is also available on Windows.
The GDB maintainers have asked that I post this patch both to the GDB
patches list, and also to the readline patches list. The hope is that
you (Chet) will accept this patch -- or some variant thereof -- into the
upstream readline so that there will not be divergence between GDB's
readline and the official version.
The overall purpose of this work is to get the FSF version of GDB
working on MinGW. The necessary patches are already in GDB itself; all
that remains is the readline bits.
Thanks in advance for your consideration.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
[-- Attachment #2: readline.patch --]
[-- Type: text/plain, Size: 19698 bytes --]
2005-03-28 Mark Mitchell <mark@codesourcery.com>
* 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 <wchar.h>
! 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 <wchar.h>],
! [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 <errno.h>
#if !defined (errno)
extern int errno;
#endif /* !errno */
+ #ifdef HAVE_PWD_H
#include <pwd.h>
+ #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 <pwd.h> 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 <pwd.h> 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 <sys/stat.h> 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 <ndir.h> header file. */
#undef HAVE_NDIR_H
+ /* Define if you have the <pwd.h> header file. */
+ #undef HAVE_PWD_H
+
/* Define if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define if you have the <stdlib.h> 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 <limits.h>
#endif
#include <fcntl.h>
+ #ifdef HAVE_PWD_H
#include <pwd.h>
+ #endif
#include <stdio.h>
#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 <sys/types.h>
#include <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_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 <sys/types.h>
+ #ifdef HAVE_PWD_H
#include <pwd.h>
+ #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);
}
\f
#if defined (TEST)
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: PATCH: Readline on MinGW
2005-04-28 6:53 PATCH: Readline on MinGW Mark Mitchell
@ 2005-04-28 20:09 ` Eli Zaretskii
2005-04-28 20:12 ` Daniel Jacobowitz
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2005-04-28 20:09 UTC (permalink / raw)
To: Mark Mitchell; +Cc: bug-readline, gdb-patches
> Date: Wed, 27 Apr 2005 23:53:31 -0700
> From: Mark Mitchell <mark@codesourcery.com>
>
> This patch begins adding support for MinGW to readline. There is one
> other patche required, which is *much* smaller, but somewhat more
> complex; this patch is the large, mechanical patch. In general, this
> patch checks for the availability of more things in autoconf, and then
> disables uses of those things when they are not present. There are no
> actual changes to the code itself, just additional conditionals, with
> the exception that a call to "kill" is turned into a call to the POSIX
> "raise", which, unlike "kill", is also available on Windows.
I support all the patches suggested by Mark, except the one which
calls `raise' instead of `kill'. Here's the relevant hunk:
> *************** 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 */
I am not sure `raise' is a 100% compatible replacement for `kill',
since the latter really delivers a signal, and so is subject to rules
regarding blocked signals, while `raise' simlpy calls the signal
handler and AFAIK is not specified to observe blocked signals.
So I suggest to use `raise' only on systems, such as MinGW, which lack
`kill', not everywhere.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 20:09 ` Eli Zaretskii
@ 2005-04-28 20:12 ` Daniel Jacobowitz
2005-04-28 20:45 ` Mark Mitchell
2005-04-28 20:50 ` Eli Zaretskii
0 siblings, 2 replies; 14+ messages in thread
From: Daniel Jacobowitz @ 2005-04-28 20:12 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Mark Mitchell, bug-readline, gdb-patches
On Thu, Apr 28, 2005 at 11:06:45PM +0300, Eli Zaretskii wrote:
> I am not sure `raise' is a 100% compatible replacement for `kill',
> since the latter really delivers a signal, and so is subject to rules
> regarding blocked signals, while `raise' simlpy calls the signal
> handler and AFAIK is not specified to observe blocked signals.
>
> So I suggest to use `raise' only on systems, such as MinGW, which lack
> `kill', not everywhere.
Could you give me a reference for this? POSIX disagrees:
http://www.opengroup.org/onlinepubs/009695399/functions/raise.html
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 20:12 ` Daniel Jacobowitz
@ 2005-04-28 20:45 ` Mark Mitchell
2005-04-28 21:02 ` Chet Ramey
2005-04-28 21:02 ` Eli Zaretskii
2005-04-28 20:50 ` Eli Zaretskii
1 sibling, 2 replies; 14+ messages in thread
From: Mark Mitchell @ 2005-04-28 20:45 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Eli Zaretskii, bug-readline, gdb-patches
Daniel Jacobowitz wrote:
> On Thu, Apr 28, 2005 at 11:06:45PM +0300, Eli Zaretskii wrote:
>
>>I am not sure `raise' is a 100% compatible replacement for `kill',
>>since the latter really delivers a signal, and so is subject to rules
>>regarding blocked signals, while `raise' simlpy calls the signal
>>handler and AFAIK is not specified to observe blocked signals.
>>
>>So I suggest to use `raise' only on systems, such as MinGW, which lack
>>`kill', not everywhere.
>
>
> Could you give me a reference for this? POSIX disagrees:
>
> http://www.opengroup.org/onlinepubs/009695399/functions/raise.html
Yes, I looked at that (and the GNU/Linux, and Solaris manual pages)
before making that change. But, I'm happy to change the code to check
for "kill", and use "raise" only if unavailable, as Eli suggests, if
that's necessary.
Eli, just to be clear, you said you "support" the patches I posted (with
this exception). I'm interpreting that as "I hope they go into upstream
readline", rather than as "it's OK to check these patches into the GDB
repository." If you actually meant the latter, let me know. :-)
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 20:45 ` Mark Mitchell
@ 2005-04-28 21:02 ` Chet Ramey
2005-04-29 0:44 ` Mark Mitchell
2005-04-29 1:51 ` Mark Mitchell
2005-04-28 21:02 ` Eli Zaretskii
1 sibling, 2 replies; 14+ messages in thread
From: Chet Ramey @ 2005-04-28 21:02 UTC (permalink / raw)
To: Mark Mitchell; +Cc: Daniel Jacobowitz, Eli Zaretskii, bug-readline, gdb-patches
> Eli, just to be clear, you said you "support" the patches I posted (with
> this exception). I'm interpreting that as "I hope they go into upstream
> readline", rather than as "it's OK to check these patches into the GDB
> repository." If you actually meant the latter, let me know. :-)
I only looked at the changes briefly, but they looked fine. I would
not, in any case, replace `kill' with `raise' without an autoconf test.
Unless there's something fatally wrong with the patch, I don't have a
problem incorporating it into the readline distribution.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
Live...Laugh...Love
Chet Ramey, ITS, CWRU chet@case.edu http://tiswww.tis.cwru.edu/~chet/
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 21:02 ` Chet Ramey
@ 2005-04-29 0:44 ` Mark Mitchell
2005-04-29 7:31 ` Eli Zaretskii
2005-04-29 1:51 ` Mark Mitchell
1 sibling, 1 reply; 14+ messages in thread
From: Mark Mitchell @ 2005-04-29 0:44 UTC (permalink / raw)
To: chet.ramey; +Cc: Daniel Jacobowitz, Eli Zaretskii, bug-readline, gdb-patches
Chet Ramey wrote:
>>Eli, just to be clear, you said you "support" the patches I posted (with
>>this exception). I'm interpreting that as "I hope they go into upstream
>>readline", rather than as "it's OK to check these patches into the GDB
>>repository." If you actually meant the latter, let me know. :-)
>
>
> I only looked at the changes briefly, but they looked fine. I would
> not, in any case, replace `kill' with `raise' without an autoconf test.
OK. I'll add an autoconf test for "kill" and then use "raise" only if
"kill" is unavailable. I'll repost with that change soon.
> Unless there's something fatally wrong with the patch, I don't have a
> problem incorporating it into the readline distribution.
Great, thank you!
Eli, et. al., does that mean that it's OK to check the patch into GDB
now? What procedure do we use from here?
Thanks,
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-29 0:44 ` Mark Mitchell
@ 2005-04-29 7:31 ` Eli Zaretskii
2005-04-29 16:10 ` Christopher Faylor
0 siblings, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2005-04-29 7:31 UTC (permalink / raw)
To: Mark Mitchell, ezannoni; +Cc: chet.ramey, drow, bug-readline, gdb-patches
> Date: Thu, 28 Apr 2005 17:44:24 -0700
> From: Mark Mitchell <mark@codesourcery.com>
> CC: Daniel Jacobowitz <drow@false.org>, Eli Zaretskii <eliz@gnu.org>,
> bug-readline@gnu.org, gdb-patches@sources.redhat.com
>
> Eli, et. al., does that mean that it's OK to check the patch into GDB
> now?
It's fine with me. MAINTAINERS lists Elena Zannoni (CC'ed) as the
responsible maintainer for Readline, with ``host maintainers'' being
responsible for host-dependent parts. I guess Chris Faylor could
count as such a host maintainer for Windows; my humble knowledge of
Windows says your changes are okay, FWIW.
Elena, could you please look at Mark's patches and comment on them?
Thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-29 7:31 ` Eli Zaretskii
@ 2005-04-29 16:10 ` Christopher Faylor
0 siblings, 0 replies; 14+ messages in thread
From: Christopher Faylor @ 2005-04-29 16:10 UTC (permalink / raw)
To: Mark Mitchell, gdb-patches, bug-readline, drow, ezannoni,
chet.ramey, Eli Zaretskii
On Fri, Apr 29, 2005 at 10:26:52AM +0300, Eli Zaretskii wrote:
>> Date: Thu, 28 Apr 2005 17:44:24 -0700
>> From: Mark Mitchell <mark@codesourcery.com>
>> CC: Daniel Jacobowitz <drow@false.org>, Eli Zaretskii <eliz@gnu.org>,
>> bug-readline@gnu.org, gdb-patches@sources.redhat.com
>>
>> Eli, et. al., does that mean that it's OK to check the patch into GDB
>> now?
>
>It's fine with me. MAINTAINERS lists Elena Zannoni (CC'ed) as the
>responsible maintainer for Readline, with ``host maintainers'' being
>responsible for host-dependent parts. I guess Chris Faylor could
>count as such a host maintainer for Windows; my humble knowledge of
>Windows says your changes are okay, FWIW.
I have no problems with the patch. I didn't comment because I didn't
think my maintainership reached into readline.
>Elena, could you please look at Mark's patches and comment on them?
I thought that Elena really only maintained readline insofar as getting
readline to work nicely in the gdb build environment. All of these
patches seem to be Chet's call, to me.
cgf
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 21:02 ` Chet Ramey
2005-04-29 0:44 ` Mark Mitchell
@ 2005-04-29 1:51 ` Mark Mitchell
1 sibling, 0 replies; 14+ messages in thread
From: Mark Mitchell @ 2005-04-29 1:51 UTC (permalink / raw)
To: chet.ramey; +Cc: Daniel Jacobowitz, Eli Zaretskii, bug-readline, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 815 bytes --]
Chet Ramey wrote:
>>Eli, just to be clear, you said you "support" the patches I posted (with
>>this exception). I'm interpreting that as "I hope they go into upstream
>>readline", rather than as "it's OK to check these patches into the GDB
>>repository." If you actually meant the latter, let me know. :-)
>
>
> I only looked at the changes briefly, but they looked fine. I would
> not, in any case, replace `kill' with `raise' without an autoconf test.
>
> Unless there's something fatally wrong with the patch, I don't have a
> problem incorporating it into the readline distribution.
Here's a revised version that does not use raise, unless kill is
unavailable.
Please let me know if there's anything else I need to do.
Thanks,
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304
[-- Attachment #2: readline.patch --]
[-- Type: text/plain, Size: 19608 bytes --]
2005-03-28 Mark Mitchell <mark@codesourcery.com>
* 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_KILL): Likewise.
(HAVE_PWD_H): Likewise.
* readline/configure: Regenerated.
* readline/configure.in: Handle MinGW when cross compiling. Check for
getpwnam, getpwent, getpwuid, kill, 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" if "kill" is not available.
(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
diff -c -5 -p -r1.7 aclocal.m4
*** aclocal.m4 27 May 2003 23:29:47 -0000 1.7
--- aclocal.m4 29 Apr 2005 01:30:24 -0000
*************** 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 <wchar.h>
! 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 <wchar.h>],
! [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
diff -c -5 -p -r1.5 complete.c
*** complete.c 8 Dec 2002 22:31:37 -0000 1.5
--- complete.c 29 Apr 2005 01:30:24 -0000
***************
*** 46,56 ****
--- 46,58 ----
#include <errno.h>
#if !defined (errno)
extern int errno;
#endif /* !errno */
+ #ifdef HAVE_PWD_H
#include <pwd.h>
+ #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 <pwd.h> 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 <pwd.h> 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
diff -c -5 -p -r1.5 config.h.in
*** config.h.in 3 Mar 2003 18:52:27 -0000 1.5
--- config.h.in 29 Apr 2005 01:30:24 -0000
***************
*** 20,35 ****
--- 20,41 ----
/* Define if the `S_IS*' macros in <sys/stat.h> 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
+ /* Define if you have the kill function. */
+ #undef HAVE_KILL
+
/* Define if you have the lstat function. */
#undef HAVE_LSTAT
/* Define if you have the mbrtowc function. */
#undef HAVE_MBRTOWC
***************
*** 41,50 ****
--- 47,65 ----
#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 ****
--- 103,115 ----
#undef HAVE_MEMORY_H
/* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H
+ /* Define if you have the <pwd.h> header file. */
+ #undef HAVE_PWD_H
+
/* Define if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
Index: configure.in
===================================================================
RCS file: /cvs/src/src/readline/configure.in,v
retrieving revision 1.6
diff -c -5 -p -r1.6 configure.in
*** configure.in 17 Dec 2002 02:52:32 -0000 1.6
--- configure.in 29 Apr 2005 01:30:24 -0000
*************** 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 kill 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
diff -c -5 -p -r1.8 display.c
*** display.c 30 Dec 2003 07:25:18 -0000 1.8
--- display.c 29 Apr 2005 01:30:24 -0000
*************** _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
diff -c -5 -p -r1.4 shell.c
*** shell.c 8 Dec 2002 22:31:37 -0000 1.4
--- shell.c 29 Apr 2005 01:30:24 -0000
***************
*** 48,58 ****
--- 48,60 ----
#if defined (HAVE_LIMITS_H)
# include <limits.h>
#endif
#include <fcntl.h>
+ #ifdef HAVE_PWD_H
#include <pwd.h>
+ #endif
#include <stdio.h>
#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
diff -c -5 -p -r1.5 signals.c
*** signals.c 8 Dec 2002 22:31:37 -0000 1.5
--- signals.c 29 Apr 2005 01:30:24 -0000
*************** 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 ****
--- 166,183 ----
#if defined (__EMX__)
signal (sig, SIG_ACK);
#endif
+ /* If we have the POSIX kill function, use it; otherwise, fall
+ back to the ISO C raise function. (Windows is an example of
+ a platform that has raise, but not kill.) */
+ #ifdef HAVE_KILL
kill (getpid (), sig);
+ #else
+ raise (sig);
+ #endif
/* 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 ****
--- 290,304 ----
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 ****
--- 306,316 ----
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 ****
--- 345,360 ----
{
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
diff -c -5 -p -r1.4 tilde.c
*** tilde.c 8 Dec 2002 22:31:37 -0000 1.4
--- tilde.c 29 Apr 2005 01:30:24 -0000
***************
*** 41,64 ****
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <sys/types.h>
#include <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_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 <sys/types.h>
+ #ifdef HAVE_PWD_H
#include <pwd.h>
+ #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);
}
\f
#if defined (TEST)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 20:45 ` Mark Mitchell
2005-04-28 21:02 ` Chet Ramey
@ 2005-04-28 21:02 ` Eli Zaretskii
1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2005-04-28 21:02 UTC (permalink / raw)
To: Mark Mitchell; +Cc: bug-readline, gdb-patches
> Date: Thu, 28 Apr 2005 13:45:35 -0700
> From: Mark Mitchell <mark@codesourcery.com>
> CC: Eli Zaretskii <eliz@gnu.org>, bug-readline@gnu.org,
> gdb-patches@sources.redhat.com
>
> Eli, just to be clear, you said you "support" the patches I posted (with
> this exception). I'm interpreting that as "I hope they go into upstream
> readline", rather than as "it's OK to check these patches into the GDB
> repository."
Yes, I was suggesting that Readline maintainers include your changes
in the upstream code base.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 20:12 ` Daniel Jacobowitz
2005-04-28 20:45 ` Mark Mitchell
@ 2005-04-28 20:50 ` Eli Zaretskii
2005-04-28 21:17 ` Daniel Jacobowitz
1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2005-04-28 20:50 UTC (permalink / raw)
To: bug-readline, gdb-patches
> Date: Thu, 28 Apr 2005 16:12:15 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Mark Mitchell <mark@codesourcery.com>, bug-readline@gnu.org,
> gdb-patches@sources.redhat.com
>
> Could you give me a reference for this? POSIX disagrees:
>
> http://www.opengroup.org/onlinepubs/009695399/functions/raise.html
Well, perhaps I misunderstand the language of Posix, but in this text:
Otherwise, the effect of the raise() function shall be equivalent to calling:
kill(getpid(), sig);
why did they use "Otherwise"? To me, this says that `raise' is not
always the equivalent of `kill''.
In any case, it is traditional on Posix platforms to use `kill', not
`raise'. I think the latter was introduced by ANSI/ISO C; if Readline
does not mandate an ISO C compiler like GDB does, it would make more
sense to use `raise' only if `kill' is unavailable.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 20:50 ` Eli Zaretskii
@ 2005-04-28 21:17 ` Daniel Jacobowitz
2005-04-28 22:13 ` Andreas Schwab
2005-04-29 6:59 ` Eli Zaretskii
0 siblings, 2 replies; 14+ messages in thread
From: Daniel Jacobowitz @ 2005-04-28 21:17 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: bug-readline, gdb-patches
On Thu, Apr 28, 2005 at 11:48:17PM +0300, Eli Zaretskii wrote:
> > Date: Thu, 28 Apr 2005 16:12:15 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: Mark Mitchell <mark@codesourcery.com>, bug-readline@gnu.org,
> > gdb-patches@sources.redhat.com
> >
> > Could you give me a reference for this? POSIX disagrees:
> >
> > http://www.opengroup.org/onlinepubs/009695399/functions/raise.html
>
> Well, perhaps I misunderstand the language of Posix, but in this text:
>
> Otherwise, the effect of the raise() function shall be equivalent to calling:
>
> kill(getpid(), sig);
>
> why did they use "Otherwise"? To me, this says that `raise' is not
> always the equivalent of `kill''.
Because in an environment which supports multiple threads, it behaves
as pthread_kill (pthread_self(), sig) as described above. Which does:
The pthread_kill() function shall request that a signal be delivered to
the specified thread.
As in kill(), if sig is zero, error checking shall be performed but
no signal shall actually be sent.
> In any case, it is traditional on Posix platforms to use `kill', not
> `raise'. I think the latter was introduced by ANSI/ISO C; if Readline
> does not mandate an ISO C compiler like GDB does, it would make more
> sense to use `raise' only if `kill' is unavailable.
This isn't right. POSIX mandates the existence of raise; ANSI/ISO C
does not specify anything having to do with signals.
Anyway, I've got no problem with using autoconf for this, but I can't
think of any case where it would make a difference.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 21:17 ` Daniel Jacobowitz
@ 2005-04-28 22:13 ` Andreas Schwab
2005-04-29 6:59 ` Eli Zaretskii
1 sibling, 0 replies; 14+ messages in thread
From: Andreas Schwab @ 2005-04-28 22:13 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: bug-readline, gdb-patches
Daniel Jacobowitz <drow@false.org> writes:
>> In any case, it is traditional on Posix platforms to use `kill', not
>> `raise'. I think the latter was introduced by ANSI/ISO C; if Readline
>> does not mandate an ISO C compiler like GDB does, it would make more
>> sense to use `raise' only if `kill' is unavailable.
>
> This isn't right. POSIX mandates the existence of raise; ANSI/ISO C
> does not specify anything having to do with signals.
Both signal and raise together with a few signal numbers are part of ISO
C. But the effect of signals is almost completely implementation-defined.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: PATCH: Readline on MinGW
2005-04-28 21:17 ` Daniel Jacobowitz
2005-04-28 22:13 ` Andreas Schwab
@ 2005-04-29 6:59 ` Eli Zaretskii
1 sibling, 0 replies; 14+ messages in thread
From: Eli Zaretskii @ 2005-04-29 6:59 UTC (permalink / raw)
To: bug-readline, gdb-patches
> Date: Thu, 28 Apr 2005 17:17:35 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: bug-readline@gnu.org, gdb-patches@sources.redhat.com
>
> > why did they use "Otherwise"? To me, this says that `raise' is not
> > always the equivalent of `kill''.
>
> Because in an environment which supports multiple threads, it behaves
> as pthread_kill (pthread_self(), sig) as described above.
I'm sorry for misinterpreting the text. But I think the bottom line
still holds: `raise' and `kill' are subtly different in some
situations.
> > In any case, it is traditional on Posix platforms to use `kill', not
> > `raise'. I think the latter was introduced by ANSI/ISO C; if Readline
> > does not mandate an ISO C compiler like GDB does, it would make more
> > sense to use `raise' only if `kill' is unavailable.
>
> This isn't right. POSIX mandates the existence of raise; ANSI/ISO C
> does not specify anything having to do with signals.
This is a misunderstanding: I didn't mean to say that Posix doesn't
include `raise'. I wanted to say that `kill' existed on Unix
platforms long before the introduction of `raise' by ANSI C.
> Anyway, I've got no problem with using autoconf for this
Neither have I.
> but I can't think of any case where it would make a difference.
In a multithreaded application? Or on an old platform that doesn't
have `raise'?
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2005-04-29 16:10 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-28 6:53 PATCH: Readline on MinGW Mark Mitchell
2005-04-28 20:09 ` Eli Zaretskii
2005-04-28 20:12 ` Daniel Jacobowitz
2005-04-28 20:45 ` Mark Mitchell
2005-04-28 21:02 ` Chet Ramey
2005-04-29 0:44 ` Mark Mitchell
2005-04-29 7:31 ` Eli Zaretskii
2005-04-29 16:10 ` Christopher Faylor
2005-04-29 1:51 ` Mark Mitchell
2005-04-28 21:02 ` Eli Zaretskii
2005-04-28 20:50 ` Eli Zaretskii
2005-04-28 21:17 ` Daniel Jacobowitz
2005-04-28 22:13 ` Andreas Schwab
2005-04-29 6:59 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox