This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: GDB-5 2000-03-03
> Andrew Cagney writes:
> > Eli Zaretskii wrote:
> >
> > > But there's a similar issue with Readline. The current version in the
> > > GDB CVS tree has bugs in the DJGPP-specific code, one of which simply
> > > prevents GDB from linking. I see that most of these problems are
> > > solved in the current beta version of Readline, but will you be
> > > synchronizing the GDB tree with that version before release? If not,
> > > I don't see any solution but a local patch. Please advise.
> >
> > Consider yourself the maintainer of the DJGPP specific readline stuff
> > (like mmalloc). (I'll add a note to MAINTAINERS.)
> >
> > The main thing is to make certain that the true readline sources have
> > the fix as well. I wasn't planning on importing readline (I'll add a
> > note stateing that this is something that won't make it).
> >
> > Andrew
>
> Eli, yes, please check in you fix to readline, I have no time this
> week to do another import.
I just committed the changes below.
(It seems the readline directory doesn't have a ChangeLog file, 'cause
CVS won't check it out for me. Am I missing something?)
--- readline/support/shobj-conf.~ Tue Aug 3 02:08:42 1999
+++ readline/support/shobj-conf Sat Feb 26 15:07:52 2000
@@ -305,6 +305,12 @@
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
+
+msdosdjgpp*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+ ;;
+
#
# Rely on correct gcc configuration for everything else
#
--- readline/bind.c~ Tue Aug 3 02:08:36 1999
+++ readline/bind.c Wed Feb 23 16:05:52 2000
@@ -62,6 +62,10 @@ extern int errno;
extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
extern int _rl_horizontal_scroll_mode;
extern int _rl_mark_modified_lines;
extern int _rl_bell_preference;
@@ -646,7 +650,7 @@ _rl_read_file (filename, sizep)
char *buffer;
int i, file;
- if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY, 0666)) < 0)
+ if ((stat (filename, &finfo) < 0) || (file = open (filename, O_RDONLY | O_BINARY, 0666)) < 0)
return ((char *)NULL);
file_size = (size_t)finfo.st_size;
@@ -667,7 +671,7 @@ _rl_read_file (filename, sizep)
i = read (file, buffer, file_size);
close (file);
-#if 0
+#if 1
if (i < file_size)
#else
if (i < 0)
@@ -678,6 +682,30 @@ _rl_read_file (filename, sizep)
}
buffer[file_size] = '\0';
+
+#if O_BINARY
+ {
+ /* Systems which distinguish between text and binary files need
+ to strip the CR characters before each Newline, otherwise the
+ parsing functions won't work. */
+ char *s, *d;
+ size_t removed = 0;
+
+ for (s = buffer, d = buffer; s < buffer + file_size; s++)
+ {
+ if (removed)
+ *d = *s;
+ if (*s != '\r' || s[1] != '\n')
+ d++;
+ else
+ removed++;
+ }
+
+ file_size -= removed;
+ buffer[file_size] = '\0';
+ }
+#endif
+
if (sizep)
*sizep = file_size;
return (buffer);
@@ -699,6 +728,7 @@ rl_re_read_init_file (count, ignore)
1. the filename used for the previous call
2. the value of the shell variable `INPUTRC'
3. ~/.inputrc
+ 4. (for __MSDOS__ only) ~/_inputrc
If the file existed and could be opened and read, 0 is returned,
otherwise errno is returned. */
int
@@ -718,6 +748,20 @@ rl_read_init_file (filename)
if (*filename == 0)
filename = DEFAULT_INPUTRC;
+#ifdef __MSDOS__
+ {
+ /* DOS doesn't allow leading dots in file names. If the original
+ name fails (it could work if we are on Windows), fall back to
+ ~/_inputrc. */
+ int retval = _rl_read_init_file (filename, 0);
+
+ if (retval == 0)
+ return retval;
+ else if (strcmp (filename, "~/.inputrc") == 0)
+ filename = "~/_inputrc";
+ }
+#endif
+
return (_rl_read_init_file (filename, 0));
}
--- readline/complete.c~ Tue Aug 3 02:08:36 1999
+++ readline/complete.c Wed Feb 23 18:02:32 2000
@@ -1407,9 +1410,9 @@ username_completion_function (text, stat
char *text;
int state;
{
-#if defined (__GO32__) || defined (__WIN32__) || defined (__OPENNT)
+#if defined (__WIN32__) || defined (__OPENNT)
return (char *)NULL;
-#else /* !__GO32__ */
+#else /* !__WIN32__ && !__OPENNT */
static char *username = (char *)NULL;
static struct passwd *entry;
static int namelen, first_char, first_char_loc;
@@ -1499,6 +1502,14 @@ filename_completion_function (text, stat
strcpy (filename, ++temp);
*temp = '\0';
}
+#if defined (__WIN32__) || defined (__OPENNT) || defined (__MSDOS__)
+ /* Handle the drive-relative names "d:foo/bar". */
+ else if (dirname[1] == ':')
+ {
+ strcpy (filename, dirname + 2);
+ dirname[2] = '\0';
+ }
+#endif
else
{
dirname[0] = '.';
--- readline/display.c~ Tue Aug 3 02:08:36 1999
+++ readline/display.c Wed Feb 23 16:13:52 2000
@@ -1126,8 +1126,10 @@ _rl_move_vert (to)
{
int row, col;
+ i = fflush (rl_outstream); /* make sure the cursor pos is current! */
ScreenGetCursor (&row, &col);
ScreenSetCursor ((row + to - _rl_last_v_pos), col);
+ delta = i;
}
#else /* !__GO32__ */
@@ -1377,7 +1379,10 @@ space_to_eol (count)
void
_rl_clear_screen ()
{
-#if !defined (__GO32__)
+#if defined (__GO32__)
+ ScreenClear (); /* FIXME: only works in text modes */
+ ScreenSetCursor (0, 0); /* term_clrpag is "cl" which homes the cursor */
+#else
if (term_clrpag)
tputs (term_clrpag, 1, _rl_output_character_function);
else
@@ -1392,6 +1397,7 @@ insert_some_chars (string, count)
int count;
{
#if defined (__GO32__)
+#ifndef __DJGPP__
int row, col, width;
char *row_start;
@@ -1400,7 +1406,7 @@ insert_some_chars (string, count)
row_start = ScreenPrimary + (row * width);
memcpy (row_start + col + count, row_start + col, width - col - count);
-
+#endif /* !__DJGPP__ */
/* Place the text on the screen. */
_rl_output_some_chars (string, count);
#else /* !_GO32 */
@@ -1445,6 +1451,7 @@ static void
delete_chars (count)
int count;
{
+#if !defined (__DJGPP__)
#if defined (__GO32__)
int row, col, width;
char *row_start;
@@ -1473,6 +1480,7 @@ delete_chars (count)
tputs (term_dc, 1, _rl_output_character_function);
}
#endif /* !__GO32__ */
+#endif /* !__DJGPP__ */
}
void
--- readline/histfile.c~ Tue Aug 3 02:08:38 1999
+++ readline/histfile.c Wed Feb 23 18:11:46 2000
@@ -140,6 +140,16 @@ read_history_range (filename, from, to)
input = history_filename (filename);
file = open (input, O_RDONLY|O_BINARY, 0666);
+
+#ifdef __MSDOS__
+ /* MSDOS doesn't allow leading dots in file names. Try again
+ with the dot replaced by an underscore. */
+ if (file < 0 && !filename)
+ {
+ input[strlen (input) - 8] = '_';
+ file = open (input, O_RDONLY|O_BINARY, 0666);
+ }
+#endif
if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit;
@@ -233,6 +243,16 @@ history_truncate_file (fname, lines)
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
+#ifdef __MSDOS__
+ /* MSDOS doesn't allow leading dots in file names. Try again
+ with the dot replaced by an underscore. */
+ if (file < 0 && !fname)
+ {
+ filename[strlen (filename) - 8] = '_';
+ file = open (filename, O_RDONLY|O_BINARY, 0666);
+ }
+#endif
+
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
@@ -314,8 +334,23 @@ history_do_write (filename, nelements, o
if ((file = open (output, mode, 0600)) == -1)
{
+#ifdef __MSDOS__
+ /* MSDOS doesn't allow leading dots in file names. If this is
+ the default file name, try again with the dot replaced by an
+ underscore. */
+ if (!filename)
+ {
+ output[strlen (output) - 8] = '_';
+ if ((file = open (output, mode, 0600)) == -1)
+ {
+ FREE (output);
+ return (errno);
+ }
+ }
+#else
FREE (output);
return (errno);
+#endif
}
if (nelements > history_length)
--- readline/input.c~ Tue Aug 3 02:08:38 1999
+++ readline/input.c Wed Feb 23 16:25:20 2000
@@ -96,7 +96,7 @@ extern Keymap _rl_keymap;
extern int _rl_convert_meta_chars_to_ascii;
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (HAVE_SELECT)
# include <pc.h>
#endif /* __GO32__ */
@@ -176,7 +176,7 @@ rl_unget_char (key)
static void
rl_gather_tyi ()
{
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (HAVE_SELECT)
char input;
if (isatty (0) && kbhit () && ibuffer_space ())
@@ -397,7 +397,7 @@ rl_getc (stream)
int result, flags;
unsigned char c;
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (HAVE_TERMIOS_H)
if (isatty (0))
return (getkey () & 0x7F);
#endif /* __GO32__ */
@@ -448,7 +448,7 @@ rl_getc (stream)
}
#endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
/* If the error that we received was SIGINT, then try again,
this is simply an interrupted system call to read ().
Otherwise, some error ocurred, also signifying EOF. */
--- readline/readline.c~ Tue Aug 3 02:08:38 1999
+++ readline/readline.c Wed Feb 23 17:58:46 2000
@@ -163,14 +163,16 @@ static void readline_initialize_everythi
static void start_using_history ();
static void bind_arrow_keys ();
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
static void readline_default_bindings ();
#endif /* !__GO32__ */
#if defined (__GO32__)
# include <go32.h>
# include <pc.h>
-# undef HANDLE_SIGNALS
+# if !defined (__DJGPP__)
+# undef HANDLE_SIGNALS
+# endif /* !__DJGPP__ */
#endif /* __GO32__ */
extern char *xmalloc (), *xrealloc ();
@@ -745,10 +747,10 @@ readline_initialize_everything ()
/* Initialize the terminal interface. */
_rl_init_terminal_io ((char *)NULL);
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
/* Bind tty characters to readline functions. */
readline_default_bindings ();
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || HAVE_TERMIOS_H */
/* Initialize the function names. */
rl_initialize_funmap ();
@@ -1272,7 +1279,7 @@ rl_refresh_line (ignore1, ignore2)
_rl_move_vert (curr_line);
_rl_move_cursor_relative (0, the_line); /* XXX is this right */
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined (__DJGPP__)
{
int row, col, width, row_start;
@@ -1281,9 +1288,9 @@ rl_refresh_line (ignore1, ignore2)
row_start = ScreenPrimary + (row * width);
memset (row_start + col, 0, (width - col) * 2);
}
-#else /* !__GO32__ */
+#else /* !__GO32__ || __DJGPP__ */
_rl_clear_to_eol (0); /* arg of 0 means to not use spaces */
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || __DJGPP__ */
rl_forced_update_display ();
rl_display_fixed = 1;
--- readline/rltty.c~ Mon Aug 16 22:17:56 1999
+++ readline/rltty.c Wed Feb 23 15:56:42 2000
@@ -57,7 +57,9 @@ extern void _rl_control_keypad ();
#if defined (__GO32__)
# include <pc.h>
-# undef HANDLE_SIGNALS
+# if !defined (__DJGPP__)
+# undef HANDLE_SIGNALS
+# endif /* !__DJGPP__ */
#endif /* __GO32__ */
/* Indirect functions to allow apps control over terminal management. */
@@ -260,7 +262,7 @@ prepare_terminal_settings (meta_flag, ot
int meta_flag;
TIOTYPE otio, *tiop;
{
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
/* Copy the original settings to the structure we're going to use for
@@ -326,7 +328,7 @@ prepare_terminal_settings (meta_flag, ot
tiop->ltchars.t_dsuspc = -1; /* C-y */
tiop->ltchars.t_lnextc = -1; /* C-v */
#endif /* TIOCGLTC */
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || HAVE_TERMIOS_H */
}
#else /* !defined (NEW_TTY_DRIVER) */
@@ -524,7 +526,7 @@ void
rl_prep_terminal (meta_flag)
int meta_flag;
{
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
int tty;
TIOTYPE tio;
@@ -559,14 +561,14 @@ rl_prep_terminal (meta_flag)
terminal_prepped = 1;
release_sigint ();
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || HAVE_TERMIOS_H */
}
/* Restore the terminal's normal settings and modes. */
void
rl_deprep_terminal ()
{
-#if !defined (__GO32__)
+#if !defined (__GO32__) || defined (HAVE_TERMIOS_H)
int tty;
if (!terminal_prepped)
@@ -591,7 +593,7 @@ rl_deprep_terminal ()
terminal_prepped = 0;
release_sigint ();
-#endif /* !__GO32__ */
+#endif /* !__GO32__ || HAVE_TERMIOS_H */
}
/* **************************************************************** */
--- readline/signals.c~ Tue Aug 3 02:08:38 1999
+++ readline/signals.c Wed Feb 23 18:04:20 2000
@@ -40,9 +40,9 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL */
-#if defined (__GO32__)
+#if defined (__GO32__) && !defined(__DJGPP__)
# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
+#endif /* __GO32__ && !__DJGPP__ */
#if defined (HANDLE_SIGNALS)
/* Some standard library routines. */
@@ -93,7 +93,9 @@ int rl_catch_sigwinch = 1;
#endif
static int signals_set_flag;
+#ifdef SIGWINCH
static int sigwinch_set_flag;
+#endif
/* **************************************************************** */
/* */
--- readline/terminal.c~ Tue Aug 3 02:08:38 1999
+++ readline/terminal.c Wed Feb 23 18:07:12 2000
@@ -57,6 +57,10 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
+#if defined (__GO32__)
+# include <pc.h>
+#endif
+
#include "rltty.h"
#include "tcap.h"
@@ -77,19 +81,24 @@ extern void _rl_bind_if_unbound ();
extern void set_lines_and_columns ();
extern char *get_env_value ();
+/* Functions imported from display.c */
+extern void _rl_redisplay_after_sigwinch ();
+
/* **************************************************************** */
/* */
/* Terminal and Termcap */
/* */
/* **************************************************************** */
+#ifndef __DJGPP__
static char *term_buffer = (char *)NULL;
static char *term_string_buffer = (char *)NULL;
-static int tcap_initialized;
-
/* Non-zero means this terminal can't really do anything. */
static int dumb_term;
+#endif
+
+static int tcap_initialized;
#if !defined (__linux__)
# if defined (__EMX__) || defined (NEED_EXTERN_PC)
@@ -186,7 +195,11 @@ _rl_get_screen_size (tty, ignore_env)
if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
screenwidth = atoi (ss);
-#if !defined(__DJGPP__)
+#if defined(__DJGPP__)
+ tty = tty;
+ if (screenwidth <= 0)
+ screenwidth = ScreenCols ();
+#else
if (screenwidth <= 0 && term_string_buffer)
screenwidth = tgetnum ("co");
#endif
@@ -199,7 +212,10 @@ _rl_get_screen_size (tty, ignore_env)
if (ignore_env == 0 && (ss = get_env_value ("LINES")))
screenheight = atoi (ss);
-#if !defined(__DJGPP__)
+#if defined(__DJGPP__)
+ if (screenheight <= 0)
+ screenheight = ScreenRows ();
+#else
if (screenheight <= 0 && term_string_buffer)
screenheight = tgetnum ("li");
#endif
@@ -291,7 +307,9 @@ static void
get_term_capabilities (bp)
char **bp;
{
-#if !defined(__DJGPP__)
+#if defined(__DJGPP__)
+ bp = bp;
+#else
register int i;
for (i = 0; i < NUM_TC_STRINGS; i++)
@@ -305,9 +323,10 @@ _rl_init_terminal_io (terminal_name)
char *terminal_name;
{
#if defined (__GO32__)
- screenwidth = ScreenCols ();
- screenheight = ScreenRows ();
- screenchars = screenwidth * screenheight;
+ terminal_name = terminal_name;
+ screenwidth = screenheight = 0;
+ _rl_get_screen_size (rl_instream ? fileno (rl_instream) : 0, 0);
+
term_cr = "\r";
term_im = term_ei = term_ic = term_IC = (char *)NULL;
term_up = term_dc = term_DC = visible_bell = (char *)NULL;
@@ -323,7 +342,7 @@ _rl_init_terminal_io (terminal_name)
term_forward_char = (char *)NULL;
#endif /* HACK_TERMCAP_MOTION */
terminal_can_insert = _rl_term_autowrap = 0;
- return;
+ return 0;
#else /* !__GO32__ */
char *term, *buffer;
@@ -510,28 +529,28 @@ ding ()
{
if (readline_echoing_p)
{
-#if !defined (__GO32__)
switch (_rl_bell_preference)
{
case NO_BELL:
default:
break;
case VISIBLE_BELL:
+#if defined (__GO32__)
+ ScreenVisualBell ();
+ break;
+#else
if (visible_bell)
{
tputs (visible_bell, 1, _rl_output_character_function);
break;
}
+#endif
/* FALLTHROUGH */
case AUDIBLE_BELL:
fprintf (stderr, "\007");
fflush (stderr);
break;
}
-#else /* __GO32__ */
- fprintf (stderr, "\007");
- fflush (stderr);
-#endif /* __GO32__ */
return (0);
}
return (-1);
@@ -556,7 +575,9 @@ void
_rl_control_keypad (on)
int on;
{
-#if !defined(__DJGPP__)
+#if defined(__DJGPP__)
+ on = on;
+#else
if (on && term_ks)
tputs (term_ks, 1, _rl_output_character_function);
else if (!on && term_ke)