mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01: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:
parent
87e3264f77
commit
bfc45cc8bc
@ -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>
|
2004-07-27 Werner Koch <wk@g10code.de>
|
||||||
|
|
||||||
* configure.ac (AM_GNU_GETTEXT_VERSION): New.
|
* configure.ac (AM_GNU_GETTEXT_VERSION): New.
|
||||||
|
3
NEWS
3
NEWS
@ -1,6 +1,9 @@
|
|||||||
Noteworthy changes in version 1.3.6 (2004-05-22)
|
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
|
* New --keyid-format option that selects short (99242560), long
|
||||||
(DB698D7199242560), 0xshort (0x99242560), or 0xlong
|
(DB698D7199242560), 0xshort (0x99242560), or 0xlong
|
||||||
(0xDB698D7199242560) keyid displays. This lets users tune the
|
(0xDB698D7199242560) keyid displays. This lets users tune the
|
||||||
|
@ -706,6 +706,7 @@ dnl Checks for header files.
|
|||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS(unistd.h langinfo.h termio.h locale.h getopt.h)
|
AC_CHECK_HEADERS(unistd.h langinfo.h termio.h locale.h getopt.h)
|
||||||
|
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AC_C_INLINE
|
AC_C_INLINE
|
||||||
@ -1083,6 +1084,11 @@ if test "$card_support" = yes; then
|
|||||||
fi
|
fi
|
||||||
AC_SUBST(LIBUSB_LIBS)
|
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
|
# Allow users to append something to the version string without
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2004-09-09 Werner Koch <wk@g10code.com>
|
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.
|
* photoid.c: Include ttyio.h.
|
||||||
|
|
||||||
* parse-packet.c (skip_rest): Removed. Changed all callers to use
|
* parse-packet.c (skip_rest): Removed. Changed all callers to use
|
||||||
|
43
g10/signal.c
43
g10/signal.c
@ -1,5 +1,6 @@
|
|||||||
/* signal.c - signal handling
|
/* 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.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -26,6 +27,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#ifdef HAVE_READLINE_READLINE_H
|
||||||
|
#include <readline/readline.h>
|
||||||
|
#include <readline/history.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
@ -67,17 +72,6 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
|
|||||||
#endif /*!HAVE_DOSISH_SYSTEM*/
|
#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
|
static RETSIGTYPE
|
||||||
got_fatal_signal( int sig )
|
got_fatal_signal( int sig )
|
||||||
{
|
{
|
||||||
@ -88,14 +82,33 @@ got_fatal_signal( int sig )
|
|||||||
caught_fatal_sig = 1;
|
caught_fatal_sig = 1;
|
||||||
|
|
||||||
secmem_term();
|
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 );
|
write(2, "\n", 1 );
|
||||||
s = log_get_name(); if( s ) write(2, s, strlen(s) );
|
s = log_get_name(); if( s ) write(2, s, strlen(s) );
|
||||||
write(2, ": ", 2 );
|
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 );
|
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);
|
init_one_signal (sig, SIG_DFL, 0);
|
||||||
remove_lockfiles ();
|
remove_lockfiles ();
|
||||||
#ifdef __riscos__
|
#ifdef __riscos__
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
2004-09-09 Werner Koch <wk@g10code.com>
|
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
|
* iobuf.c (iobuf_skip_rest): New. Orginal patch by Florian
|
||||||
Weimer. Added new argument PARTIAL.
|
Weimer. Added new argument PARTIAL.
|
||||||
|
|
||||||
|
47
util/ttyio.c
47
util/ttyio.c
@ -1,5 +1,6 @@
|
|||||||
/* ttyio.c - tty i/O functions
|
/* 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.
|
* This file is part of GnuPG.
|
||||||
*
|
*
|
||||||
@ -45,6 +46,11 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#ifdef HAVE_READLINE_READLINE_H
|
||||||
|
#include <readline/readline.h>
|
||||||
|
#include <readline/history.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "ttyio.h"
|
#include "ttyio.h"
|
||||||
@ -156,6 +162,10 @@ init_ttyfp(void)
|
|||||||
tty_get_ttyname (), strerror(errno) );
|
tty_get_ttyname (), strerror(errno) );
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
#if defined(HAVE_READLINE_READLINE_H) && defined(HAVE_LIBREADLINE)
|
||||||
|
rl_catch_signals = 0;
|
||||||
|
rl_instream = rl_outstream = ttyfp;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_TCGETATTR
|
#ifdef HAVE_TCGETATTR
|
||||||
atexit( cleanup );
|
atexit( cleanup );
|
||||||
@ -502,7 +512,40 @@ do_get( const char *prompt, int hidden )
|
|||||||
char *
|
char *
|
||||||
tty_get( const char *prompt )
|
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 *
|
char *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user