This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: Patch to build gdb-5.0 with readline-4.1
- To: Eli Zaretskii <eliz at is dot elta dot co dot il>
- Subject: Re: Patch to build gdb-5.0 with readline-4.1
- From: Andrew Gaylard <andrew dot gaylard at za dot didata dot com>
- Date: Mon, 29 May 2000 09:59:39 +0200
- CC: andrew dot gaylard at bsw dot co dot za, gdb-patches at sourceware dot cygnus dot com, "Mark E." <snowball3 at bigfoot dot com>
- References: <39316D76.EAB1DAD8@bsw.co.za> <200005290738.DAA06104@indy.delorie.com>
Eli Zaretskii wrote:
>
> > Date: Sun, 28 May 2000 21:03:18 +0200
> > From: Andrew Gaylard <andrew.gaylard@bsw.co.za>
> >
> > /* readline include files */
> > +/* This is needed to prevent readline-4.1 (re-)defining it. */
> > +#define savestring
> > #include <readline/readline.h>
> > #include <readline/history.h>
> >
> > #include <signal.h>
> >
> > -/* readline defines this. */
> > +/* readline needed this. */
> > #undef savestring
>
> What's the story behind this savestring gork? Is it possible to take
> care of the problem in a cleaner way?
From what I can see, readline used to use this, but doesn't any more.
But its headers keep it around, presumably for backward-compatibility:
from readline.h:
#if !defined (savestring)
extern char *savestring __P((char *)); /* XXX backwards compatibility */
#endif
and from histlib.h:
#ifndef savestring
# ifndef strcpy
extern char *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif
and from rldefs.h:
#ifndef savestring
extern char *xmalloc ();
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif
This definition clashes with the one in gdb/defs.h:
extern char *savestring (const char *, int);
So it seemed simpler to me to simply #define savestring
before #include <readline/...> and #undef savestring
afterwards. But there's probably a better way. Hopefully
when readline-4.2 appears, this sort of stuff won't be
necessary any longer.
> > rl_completer_quote_characters = gdb_completer_quote_characters;
> > rl_readline_name = "gdb";
> > + rl_terminal_name=getenv("TERM");
>
> What does readline do with rl_terminal_name? What if getenv returns a
> NULL pointer? (Non-Unix ports of GDB are likely to have $TERM
> undefined.)
Realine uses the terminal name to parse ~/.inputrc (or $INPUTRC).
I use it to do terminal-specific things like this (from my .inputrc):
$if TERM=xterm
# Home, End, Ctrl-backspace, Ctrl-Delete, Ctrl-left, Ctrl-Right
"\e[1~": beginning-of-line
"\e[2~": yank
"\e[4~": end-of-line
"\e[H": beginning-of-line
"\e[F": end-of-line
"\eOw": beginning-of-line
"\eOq": end-of-line
"\C-?": delete-char
"\C-w": backward-kill-word
"\e[KC4~": backward-word
"\e[KC6~": forward-word
$endif
I've tested the line I added to gdb with:
+ TERM=xterm
+ TERM= (that is "export TERM=")
+ TERM not set (that is, "unset TERM")
None of these gave any problems.
--
Andrew Gaylard
andrewg @ bsw . co . za