1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-07 23:27:48 +02:00

* configure.ac: Check for readline.

* signal.c (got_fatal_signal): Do readline cleanup.  Print signal
number if we can't print the name. Use new autoconf macro
HAVE_DECL_SYS_SIGLIST.
(get_signal_name): Removed.

* ttyio.c (tty_get): Add readline support.
This commit is contained in:
Werner Koch 2004-09-09 17:04:44 +00:00
parent 87e3264f77
commit bfc45cc8bc
7 changed files with 93 additions and 17 deletions

View File

@ -1,3 +1,7 @@
2004-09-09 Werner Koch <wk@g10code.com>
* configure.ac: Check for readline.
2004-07-27 Werner Koch <wk@g10code.de>
* configure.ac (AM_GNU_GETTEXT_VERSION): New.

3
NEWS
View File

@ -1,6 +1,9 @@
Noteworthy changes in version 1.3.6 (2004-05-22)
------------------------------------------------
* Readline support at all prompt if the systems provides a
readline library.
* New --keyid-format option that selects short (99242560), long
(DB698D7199242560), 0xshort (0x99242560), or 0xlong
(0xDB698D7199242560) keyid displays. This lets users tune the

View File

@ -706,6 +706,7 @@ dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h langinfo.h termio.h locale.h getopt.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
@ -1083,6 +1084,11 @@ if test "$card_support" = yes; then
fi
AC_SUBST(LIBUSB_LIBS)
#
# Check for readline support
#
AC_CHECK_LIB(readline, add_history)
AC_CHECK_HEADERS([readline/readline.h])
# Allow users to append something to the version string without

View File

@ -1,5 +1,10 @@
2004-09-09 Werner Koch <wk@g10code.com>
* signal.c (got_fatal_signal): Do readline cleanup. Print signal
number if we can't print the name. Use new autoconf macro
HAVE_DECL_SYS_SIGLIST.
(get_signal_name): Removed.
* photoid.c: Include ttyio.h.
* parse-packet.c (skip_rest): Removed. Changed all callers to use

View File

@ -1,5 +1,6 @@
/* signal.c - signal handling
* Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
* 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -26,6 +27,10 @@
#include <string.h>
#include <errno.h>
#include <assert.h>
#ifdef HAVE_READLINE_READLINE_H
#include <readline/readline.h>
#include <readline/history.h>
#endif
#include "options.h"
#include "errors.h"
@ -67,17 +72,6 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
#endif /*!HAVE_DOSISH_SYSTEM*/
}
static const char *
get_signal_name( int signum )
{
#if defined(SYS_SIGLIST_DECLARED) && defined(NSIG)
return (signum >= 0 && signum < NSIG) ? sys_siglist[signum] : "?";
#else
return "some signal";
#endif
}
static RETSIGTYPE
got_fatal_signal( int sig )
{
@ -88,14 +82,33 @@ got_fatal_signal( int sig )
caught_fatal_sig = 1;
secmem_term();
/* better don't transtale these messages */
#if defined(HAVE_READLINE_READLINE_H) && defined(HAVE_LIBREADLINE)
rl_free_line_state ();
rl_cleanup_after_signal ();
#endif
/* Better don't translate these messages. */
write(2, "\n", 1 );
s = log_get_name(); if( s ) write(2, s, strlen(s) );
write(2, ": ", 2 );
s = get_signal_name(sig); write(2, s, strlen(s) );
#if defined(HAVE_DECL_SYS_SIGLIST) && defined(NSIG)
s = (sig >= 0 && sig < NSIG) ? sys_siglist[sig] : "?";
write (2, s, strlen(s) );
#else
write (2, "signal ", 7 );
if (sig < 0 || sig >=100)
write (2, "?", 1);
else {
if (sig >= 10)
write (2, "0123456789"+(sig/10), 1 );
write (2, "0123456789"+(sig%10), 1 );
}
#endif
write(2, " caught ... exiting\n", 20 );
/* reset action to default action and raise signal again */
/* Reset action to default action and raise signal again. */
init_one_signal (sig, SIG_DFL, 0);
remove_lockfiles ();
#ifdef __riscos__

View File

@ -1,5 +1,7 @@
2004-09-09 Werner Koch <wk@g10code.com>
* ttyio.c (tty_get): Add readline support.
* iobuf.c (iobuf_skip_rest): New. Orginal patch by Florian
Weimer. Added new argument PARTIAL.

View File

@ -1,5 +1,6 @@
/* ttyio.c - tty i/O functions
* Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
* 2004 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -45,6 +46,11 @@
#endif
#include <errno.h>
#include <ctype.h>
#ifdef HAVE_READLINE_READLINE_H
#include <readline/readline.h>
#include <readline/history.h>
#endif
#include "util.h"
#include "memory.h"
#include "ttyio.h"
@ -156,6 +162,10 @@ init_ttyfp(void)
tty_get_ttyname (), strerror(errno) );
exit(2);
}
#if defined(HAVE_READLINE_READLINE_H) && defined(HAVE_LIBREADLINE)
rl_catch_signals = 0;
rl_instream = rl_outstream = ttyfp;
#endif
#endif
#ifdef HAVE_TCGETATTR
atexit( cleanup );
@ -502,7 +512,40 @@ do_get( const char *prompt, int hidden )
char *
tty_get( const char *prompt )
{
return do_get( prompt, 0 );
#if defined(HAVE_READLINE_READLINE_H) && defined(HAVE_LIBREADLINE)
if (!batchmode && !no_terminal) {
char *line;
char *buf;
if( !initialized )
init_ttyfp();
last_prompt_len = 0;
line = readline (prompt?prompt:"");
/* We need to copy it to memory controlled by our malloc
implementations; further we need to convert an EOF to our
convention. */
buf = m_alloc(line? strlen(line)+1:2);
if (line)
{
strcpy (buf, line);
trim_spaces (buf);
if (strlen (buf) > 2 )
add_history (line); /* Note that we test BUF but add LINE. */
free (line);
}
else
{
buf[0] = CONTROL_D;
buf[1] = 0;
}
return buf;
}
else
#endif /* HAVE_READLINE_READLINE_H && HAVE_LIBREADLINE */
return do_get( prompt, 0 );
}
char *