1999-04-16 03:34:55 +02:00
|
|
|
/* histfile.c - functions to manipulate the history file. */
|
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
/* Copyright (C) 1989-2018 Free Software Foundation, Inc.
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
This file contains the GNU History Library (History), a set of
|
1999-04-16 03:34:55 +02:00
|
|
|
routines for managing the text of previously typed lines.
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
History is free software: you can redistribute it and/or modify
|
1999-04-16 03:34:55 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2011-05-12 01:38:44 +02:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
History is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with History. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
/* The goal is to make the implementation transparent, so that you
|
|
|
|
don't have to know what data types are used, just what functions
|
|
|
|
you can call. I think I have done that. */
|
2006-05-05 20:26:14 +02:00
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
#define READLINE_LIBRARY
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
#if defined (__TANDEM)
|
|
|
|
# include <floss.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
#if defined (HAVE_CONFIG_H)
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
#if defined (HAVE_LIMITS_H)
|
|
|
|
# include <limits.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
#include <sys/types.h>
|
2006-05-05 20:26:14 +02:00
|
|
|
#if ! defined (_MINIX) && defined (HAVE_SYS_FILE_H)
|
1999-04-16 03:34:55 +02:00
|
|
|
# include <sys/file.h>
|
|
|
|
#endif
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#include "posixstat.h"
|
1999-04-16 03:34:55 +02:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#if defined (HAVE_STDLIB_H)
|
|
|
|
# include <stdlib.h>
|
|
|
|
#else
|
|
|
|
# include "ansi_stdlib.h"
|
|
|
|
#endif /* HAVE_STDLIB_H */
|
|
|
|
|
|
|
|
#if defined (HAVE_UNISTD_H)
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#if defined (__EMX__)
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
# undef HAVE_MMAP
|
|
|
|
#endif
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifdef HISTORY_USE_MMAP
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
# include <sys/mman.h>
|
|
|
|
|
|
|
|
# ifdef MAP_FILE
|
|
|
|
# define MAP_RFLAGS (MAP_FILE|MAP_PRIVATE)
|
|
|
|
# define MAP_WFLAGS (MAP_FILE|MAP_SHARED)
|
|
|
|
# else
|
|
|
|
# define MAP_RFLAGS MAP_PRIVATE
|
|
|
|
# define MAP_WFLAGS MAP_SHARED
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# ifndef MAP_FAILED
|
|
|
|
# define MAP_FAILED ((void *)-1)
|
|
|
|
# endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
#endif /* HISTORY_USE_MMAP */
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
|
|
|
|
/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
|
|
|
|
on win 95/98/nt), we want to open files with O_BINARY mode so that there
|
|
|
|
is no \n -> \r\n conversion performed. On other systems, we don't want to
|
|
|
|
mess around with O_BINARY at all, so we ensure that it's defined to 0. */
|
|
|
|
#if defined (__EMX__) || defined (__CYGWIN__)
|
1999-04-16 03:34:55 +02:00
|
|
|
# ifndef O_BINARY
|
|
|
|
# define O_BINARY 0
|
|
|
|
# endif
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#else /* !__EMX__ && !__CYGWIN__ */
|
1999-04-16 03:34:55 +02:00
|
|
|
# undef O_BINARY
|
|
|
|
# define O_BINARY 0
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#endif /* !__EMX__ && !__CYGWIN__ */
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#if !defined (errno)
|
|
|
|
extern int errno;
|
|
|
|
#endif /* !errno */
|
|
|
|
|
|
|
|
#include "history.h"
|
|
|
|
#include "histlib.h"
|
|
|
|
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#include "rlshell.h"
|
|
|
|
#include "xmalloc.h"
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
#if !defined (PATH_MAX)
|
|
|
|
# define PATH_MAX 1024 /* default */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void _hs_append_history_line PARAMS((int, const char *));
|
|
|
|
|
|
|
|
/* history file version; currently unused */
|
|
|
|
int history_file_version = 1;
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
/* If non-zero, we write timestamps to the history file in history_do_write() */
|
|
|
|
int history_write_timestamps = 0;
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
/* If non-zero, we assume that a history file that starts with a timestamp
|
|
|
|
uses timestamp-delimited entries and can include multi-line history
|
|
|
|
entries. Used by read_history_range */
|
|
|
|
int history_multiline_entries = 0;
|
|
|
|
|
|
|
|
/* Immediately after a call to read_history() or read_history_range(), this
|
|
|
|
will return the number of lines just read from the history file in that
|
|
|
|
call. */
|
|
|
|
int history_lines_read_from_file = 0;
|
|
|
|
|
|
|
|
/* Immediately after a call to write_history() or history_do_write(), this
|
|
|
|
will return the number of lines just written to the history file in that
|
|
|
|
call. This also works with history_truncate_file. */
|
|
|
|
int history_lines_written_to_file = 0;
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
/* Does S look like the beginning of a history timestamp entry? Placeholder
|
|
|
|
for more extensive tests. */
|
2018-10-07 20:52:13 +02:00
|
|
|
#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char && isdigit ((unsigned char)(s)[1]) )
|
|
|
|
|
|
|
|
static char *history_backupfile PARAMS((const char *));
|
|
|
|
static char *history_tempfile PARAMS((const char *));
|
|
|
|
static int histfile_backup PARAMS((const char *, const char *));
|
|
|
|
static int histfile_restore PARAMS((const char *, const char *));
|
2006-05-05 20:26:14 +02:00
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
/* Return the string that should be used in the place of this
|
|
|
|
filename. This only matters when you don't specify the
|
|
|
|
filename to read_history (), or write_history (). */
|
|
|
|
static char *
|
2019-08-12 18:24:03 +02:00
|
|
|
history_filename (const char *filename)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
char *return_val;
|
|
|
|
const char *home;
|
1999-04-16 03:34:55 +02:00
|
|
|
int home_len;
|
|
|
|
|
|
|
|
return_val = filename ? savestring (filename) : (char *)NULL;
|
|
|
|
|
|
|
|
if (return_val)
|
|
|
|
return (return_val);
|
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
home = sh_get_env_value ("HOME");
|
2018-10-07 20:52:13 +02:00
|
|
|
#if defined (_WIN32)
|
|
|
|
if (home == 0)
|
2016-09-17 10:50:37 +02:00
|
|
|
home = sh_get_env_value ("APPDATA");
|
|
|
|
#endif
|
Sync readline/ to version 7.0 alpha
This patch syncs our upstream copy of readline from version 6.2 to the
latest version, 7.0 alpha (released July 10 2015).
I essentially copied what was done the last time readline was synced,
when Jan updated to readline 6.2 in 2011:
http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html
Procedure:
1. I extracted the readline-7.0-alpha tarball on top of readline/.
2. I deleted all the new files under doc/ that were deliberately omitted
before.
3. I regenerated readline/configure and readline/examples/rlfe/configure
using autoconf 2.64. No other configure files need regenerating.
4. I updated the function gdb_printable_part in completer.c with a
trivial change made to the readline function it is based off of,
printable_part in readline/complete.c. There is more work to be done in
completer.c to sync it with readline/complete.c, but it is non-trivial
and should probably be done separately anyway.
Local patches that had to be reapplied:
None. readline 7.0 alpha contains all of our local readline
patches.
New files in readline/:
colors.{c,h}
examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c
parse-colors.{c,h}
readline.pc.in
configure.ac
Deleted files in readline/:
configure.in
Regressions:
After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs. Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked. But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler. Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch). Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).
Aside from this one testsuite regression, I personally noticed no
regression in user-visible behavior. Though I only tested on x86_64
and on i686 Debian Stretch.
Getting this kind of change in at the start of the GDB 7.11 development
cycle will allow us to get a lot of passive testing from developers and
from bleeding-edge users.
readline/ChangeLog.gdb:
Import readline 7.0 alpha
* configure: Regenerate.
* examples/rlfe/configure: Regenerate.
gdb/ChangeLog:
* completer.c (gdb_printable_part): Sync with readline function
it is based off of.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (test_with_self): Update test to now
expect the GDB inferior to no longer immediately stop after
being resumed with "signal SIGINT".
2015-07-15 02:29:21 +02:00
|
|
|
|
|
|
|
if (home == 0)
|
2018-10-07 20:52:13 +02:00
|
|
|
return (NULL);
|
1999-04-16 03:34:55 +02:00
|
|
|
else
|
|
|
|
home_len = strlen (home);
|
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
|
1999-04-16 03:34:55 +02:00
|
|
|
strcpy (return_val, home);
|
|
|
|
return_val[home_len] = '/';
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#if defined (__MSDOS__)
|
|
|
|
strcpy (return_val + home_len + 1, "_history");
|
|
|
|
#else
|
1999-04-16 03:34:55 +02:00
|
|
|
strcpy (return_val + home_len + 1, ".history");
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
return (return_val);
|
|
|
|
}
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
static char *
|
2019-08-12 18:24:03 +02:00
|
|
|
history_backupfile (const char *filename)
|
2018-10-07 20:52:13 +02:00
|
|
|
{
|
|
|
|
const char *fn;
|
|
|
|
char *ret, linkbuf[PATH_MAX+1];
|
|
|
|
size_t len;
|
|
|
|
ssize_t n;
|
|
|
|
struct stat fs;
|
|
|
|
|
|
|
|
fn = filename;
|
|
|
|
#if defined (HAVE_READLINK)
|
|
|
|
/* Follow symlink to avoid backing up symlink itself; call will fail if
|
|
|
|
not a symlink */
|
|
|
|
if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
|
|
|
|
{
|
|
|
|
linkbuf[n] = '\0';
|
|
|
|
fn = linkbuf;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
len = strlen (fn);
|
|
|
|
ret = xmalloc (len + 2);
|
|
|
|
strcpy (ret, fn);
|
|
|
|
ret[len] = '-';
|
|
|
|
ret[len+1] = '\0';
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2019-08-12 18:24:03 +02:00
|
|
|
history_tempfile (const char *filename)
|
2018-10-07 20:52:13 +02:00
|
|
|
{
|
|
|
|
const char *fn;
|
|
|
|
char *ret, linkbuf[PATH_MAX+1];
|
|
|
|
size_t len;
|
|
|
|
ssize_t n;
|
|
|
|
struct stat fs;
|
|
|
|
int pid;
|
|
|
|
|
|
|
|
fn = filename;
|
|
|
|
#if defined (HAVE_READLINK)
|
|
|
|
/* Follow symlink so tempfile created in the same directory as any symlinked
|
|
|
|
history file; call will fail if not a symlink */
|
|
|
|
if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
|
|
|
|
{
|
|
|
|
linkbuf[n] = '\0';
|
|
|
|
fn = linkbuf;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
len = strlen (fn);
|
|
|
|
ret = xmalloc (len + 11);
|
|
|
|
strcpy (ret, fn);
|
|
|
|
|
|
|
|
pid = (int)getpid ();
|
|
|
|
|
|
|
|
/* filename-PID.tmp */
|
|
|
|
ret[len] = '-';
|
|
|
|
ret[len+1] = (pid / 10000 % 10) + '0';
|
|
|
|
ret[len+2] = (pid / 1000 % 10) + '0';
|
|
|
|
ret[len+3] = (pid / 100 % 10) + '0';
|
|
|
|
ret[len+4] = (pid / 10 % 10) + '0';
|
|
|
|
ret[len+5] = (pid % 10) + '0';
|
|
|
|
strcpy (ret + len + 6, ".tmp");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
/* Add the contents of FILENAME to the history list, a line at a time.
|
|
|
|
If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
|
|
|
successful, or errno if not. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
read_history (const char *filename)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
return (read_history_range (filename, 0, -1));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read a range of lines from FILENAME, adding them to the history list.
|
|
|
|
Start reading at the FROM'th line and end at the TO'th. If FROM
|
|
|
|
is zero, start at the beginning. If TO is less than FROM, read
|
|
|
|
until the end of the file. If FILENAME is NULL, then read from
|
|
|
|
~/.history. Returns 0 if successful, or errno if not. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
read_history_range (const char *filename, int from, int to)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2006-05-05 20:26:14 +02:00
|
|
|
register char *line_start, *line_end, *p;
|
|
|
|
char *input, *buffer, *bufend, *last_ts;
|
2018-10-07 20:52:13 +02:00
|
|
|
int file, current_line, chars_read, has_timestamps, reset_comment_char;
|
1999-04-16 03:34:55 +02:00
|
|
|
struct stat finfo;
|
|
|
|
size_t file_size;
|
2006-05-05 20:26:14 +02:00
|
|
|
#if defined (EFBIG)
|
|
|
|
int overflow_errno = EFBIG;
|
|
|
|
#elif defined (EOVERFLOW)
|
|
|
|
int overflow_errno = EOVERFLOW;
|
|
|
|
#else
|
|
|
|
int overflow_errno = EIO;
|
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
history_lines_read_from_file = 0;
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
buffer = last_ts = (char *)NULL;
|
1999-04-16 03:34:55 +02:00
|
|
|
input = history_filename (filename);
|
2011-05-12 01:38:44 +02:00
|
|
|
file = input ? open (input, O_RDONLY|O_BINARY, 0666) : -1;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
if ((file < 0) || (fstat (file, &finfo) == -1))
|
|
|
|
goto error_and_exit;
|
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
if (S_ISREG (finfo.st_mode) == 0)
|
|
|
|
{
|
|
|
|
#ifdef EFTYPE
|
|
|
|
errno = EFTYPE;
|
|
|
|
#else
|
|
|
|
errno = EINVAL;
|
|
|
|
#endif
|
|
|
|
goto error_and_exit;
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
file_size = (size_t)finfo.st_size;
|
|
|
|
|
|
|
|
/* check for overflow on very large files */
|
|
|
|
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
|
|
|
{
|
2006-05-05 20:26:14 +02:00
|
|
|
errno = overflow_errno;
|
1999-04-16 03:34:55 +02:00
|
|
|
goto error_and_exit;
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
if (file_size == 0)
|
|
|
|
{
|
|
|
|
free (input);
|
|
|
|
return 0; /* don't waste time if we don't have to */
|
|
|
|
}
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifdef HISTORY_USE_MMAP
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
/* We map read/write and private so we can change newlines to NULs without
|
|
|
|
affecting the underlying object. */
|
|
|
|
buffer = (char *)mmap (0, file_size, PROT_READ|PROT_WRITE, MAP_RFLAGS, file, 0);
|
|
|
|
if ((void *)buffer == MAP_FAILED)
|
2006-05-05 20:26:14 +02:00
|
|
|
{
|
|
|
|
errno = overflow_errno;
|
|
|
|
goto error_and_exit;
|
|
|
|
}
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
chars_read = file_size;
|
|
|
|
#else
|
|
|
|
buffer = (char *)malloc (file_size + 1);
|
|
|
|
if (buffer == 0)
|
2006-05-05 20:26:14 +02:00
|
|
|
{
|
|
|
|
errno = overflow_errno;
|
|
|
|
goto error_and_exit;
|
|
|
|
}
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
|
|
|
|
chars_read = read (file, buffer, file_size);
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
#endif
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
if (chars_read < 0)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
error_and_exit:
|
2006-05-05 20:26:14 +02:00
|
|
|
if (errno != 0)
|
|
|
|
chars_read = errno;
|
|
|
|
else
|
|
|
|
chars_read = EIO;
|
1999-04-16 03:34:55 +02:00
|
|
|
if (file >= 0)
|
|
|
|
close (file);
|
|
|
|
|
|
|
|
FREE (input);
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifndef HISTORY_USE_MMAP
|
1999-04-16 03:34:55 +02:00
|
|
|
FREE (buffer);
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
return (chars_read);
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
close (file);
|
|
|
|
|
|
|
|
/* Set TO to larger than end of file if negative. */
|
|
|
|
if (to < 0)
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
to = chars_read;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
/* Start at beginning of file, work to end. */
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
bufend = buffer + chars_read;
|
2019-08-12 18:24:03 +02:00
|
|
|
*bufend = '\0'; /* null-terminate buffer for timestamp checks */
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
current_line = 0;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
/* Heuristic: the history comment character rarely changes, so assume we
|
|
|
|
have timestamps if the buffer starts with `#[:digit:]' and temporarily
|
|
|
|
set history_comment_char so timestamp parsing works right */
|
|
|
|
reset_comment_char = 0;
|
|
|
|
if (history_comment_char == '\0' && buffer[0] == '#' && isdigit ((unsigned char)buffer[1]))
|
|
|
|
{
|
|
|
|
history_comment_char = '#';
|
|
|
|
reset_comment_char = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
has_timestamps = HIST_TIMESTAMP_START (buffer);
|
|
|
|
history_multiline_entries += has_timestamps && history_write_timestamps;
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
/* Skip lines until we are at FROM. */
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
|
|
|
|
if (*line_end == '\n')
|
|
|
|
{
|
2006-05-05 20:26:14 +02:00
|
|
|
p = line_end + 1;
|
|
|
|
/* If we see something we think is a timestamp, continue with this
|
|
|
|
line. We should check more extensively here... */
|
|
|
|
if (HIST_TIMESTAMP_START(p) == 0)
|
|
|
|
current_line++;
|
|
|
|
line_start = p;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
}
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
/* If there are lines left to gobble, then gobble them now. */
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
for (line_end = line_start; line_end < bufend; line_end++)
|
|
|
|
if (*line_end == '\n')
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2011-05-12 01:38:44 +02:00
|
|
|
/* Change to allow Windows-like \r\n end of line delimiter. */
|
|
|
|
if (line_end > line_start && line_end[-1] == '\r')
|
|
|
|
line_end[-1] = '\0';
|
2006-03-21 15:58:24 +01:00
|
|
|
else
|
|
|
|
*line_end = '\0';
|
1999-04-16 03:34:55 +02:00
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
if (*line_start)
|
2006-05-05 20:26:14 +02:00
|
|
|
{
|
|
|
|
if (HIST_TIMESTAMP_START(line_start) == 0)
|
|
|
|
{
|
2019-08-12 18:24:03 +02:00
|
|
|
if (last_ts == NULL && history_length > 0 && history_multiline_entries)
|
2018-10-07 20:52:13 +02:00
|
|
|
_hs_append_history_line (history_length - 1, line_start);
|
|
|
|
else
|
|
|
|
add_history (line_start);
|
2006-05-05 20:26:14 +02:00
|
|
|
if (last_ts)
|
|
|
|
{
|
|
|
|
add_history_time (last_ts);
|
|
|
|
last_ts = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
last_ts = line_start;
|
|
|
|
current_line--;
|
|
|
|
}
|
|
|
|
}
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
current_line++;
|
|
|
|
|
|
|
|
if (current_line >= to)
|
|
|
|
break;
|
|
|
|
|
|
|
|
line_start = line_end + 1;
|
|
|
|
}
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
history_lines_read_from_file = current_line;
|
|
|
|
if (reset_comment_char)
|
|
|
|
history_comment_char = '\0';
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
FREE (input);
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifndef HISTORY_USE_MMAP
|
1999-04-16 03:34:55 +02:00
|
|
|
FREE (buffer);
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
#else
|
|
|
|
munmap (buffer, file_size);
|
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
/* Save FILENAME to BACK, handling case where FILENAME is a symlink
|
|
|
|
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
|
|
|
|
static int
|
2019-08-12 18:24:03 +02:00
|
|
|
histfile_backup (const char *filename, const char *back)
|
2018-10-07 20:52:13 +02:00
|
|
|
{
|
|
|
|
#if defined (HAVE_READLINK)
|
|
|
|
char linkbuf[PATH_MAX+1];
|
|
|
|
ssize_t n;
|
|
|
|
|
|
|
|
/* Follow to target of symlink to avoid renaming symlink itself */
|
|
|
|
if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
|
|
|
|
{
|
|
|
|
linkbuf[n] = '\0';
|
|
|
|
return (rename (linkbuf, back));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return (rename (filename, back));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore ORIG from BACKUP handling case where ORIG is a symlink
|
|
|
|
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
|
|
|
|
static int
|
2019-08-12 18:24:03 +02:00
|
|
|
histfile_restore (const char *backup, const char *orig)
|
2018-10-07 20:52:13 +02:00
|
|
|
{
|
|
|
|
#if defined (HAVE_READLINK)
|
|
|
|
char linkbuf[PATH_MAX+1];
|
|
|
|
ssize_t n;
|
|
|
|
|
|
|
|
/* Follow to target of symlink to avoid renaming symlink itself */
|
|
|
|
if ((n = readlink (orig, linkbuf, sizeof (linkbuf) - 1)) > 0)
|
|
|
|
{
|
|
|
|
linkbuf[n] = '\0';
|
|
|
|
return (rename (backup, linkbuf));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return (rename (backup, orig));
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
/* Truncate the history file FNAME, leaving only LINES trailing lines.
|
2018-10-07 20:52:13 +02:00
|
|
|
If FNAME is NULL, then use ~/.history. Writes a new file and renames
|
|
|
|
it to the original name. Returns 0 on success, errno on failure. */
|
1999-04-16 03:34:55 +02:00
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
history_truncate_file (const char *fname, int lines)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2018-10-07 20:52:13 +02:00
|
|
|
char *buffer, *filename, *tempname, *bp, *bp1; /* bp1 == bp+1 */
|
|
|
|
int file, chars_read, rv, orig_lines, exists, r;
|
1999-04-16 03:34:55 +02:00
|
|
|
struct stat finfo;
|
|
|
|
size_t file_size;
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
history_lines_written_to_file = 0;
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
buffer = (char *)NULL;
|
|
|
|
filename = history_filename (fname);
|
2018-10-07 20:52:13 +02:00
|
|
|
tempname = 0;
|
2011-05-12 01:38:44 +02:00
|
|
|
file = filename ? open (filename, O_RDONLY|O_BINARY, 0666) : -1;
|
2018-10-07 20:52:13 +02:00
|
|
|
rv = exists = 0;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
/* Don't try to truncate non-regular files. */
|
1999-04-16 03:34:55 +02:00
|
|
|
if (file == -1 || fstat (file, &finfo) == -1)
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
{
|
|
|
|
rv = errno;
|
|
|
|
if (file != -1)
|
|
|
|
close (file);
|
|
|
|
goto truncate_exit;
|
|
|
|
}
|
2018-10-07 20:52:13 +02:00
|
|
|
exists = 1;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
if (S_ISREG (finfo.st_mode) == 0)
|
|
|
|
{
|
|
|
|
close (file);
|
|
|
|
#ifdef EFTYPE
|
|
|
|
rv = EFTYPE;
|
|
|
|
#else
|
|
|
|
rv = EINVAL;
|
|
|
|
#endif
|
|
|
|
goto truncate_exit;
|
|
|
|
}
|
readline:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Locally modified files: Makefile.in, configure.in, configure
(regenerated), config.h.in (regenerated), readline.h, rltty.c,
shell.c signals.c.
Locally added files: acconfig.h, config/*, config.h.bot,
cross-build/*, doc/inc-hit.texinfo.
New files: USAGE, rlprivate.h, rlshell.h, xmalloc.h.
examples:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
New files: excallback.c, rlfe.c.
doc:
2000-07-09 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
* Import of readline 4.1.
Regenerated inc-hist.texinfo as copy of hsuser.texinfo, for
inclusion in the gdb manual.
New file: rluserman.texinfo
2000-07-09 19:20:00 +02:00
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
file_size = (size_t)finfo.st_size;
|
|
|
|
|
|
|
|
/* check for overflow on very large files */
|
|
|
|
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
|
|
|
{
|
|
|
|
close (file);
|
|
|
|
#if defined (EFBIG)
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
rv = errno = EFBIG;
|
|
|
|
#elif defined (EOVERFLOW)
|
|
|
|
rv = errno = EOVERFLOW;
|
|
|
|
#else
|
|
|
|
rv = errno = EINVAL;
|
1999-04-16 03:34:55 +02:00
|
|
|
#endif
|
|
|
|
goto truncate_exit;
|
|
|
|
}
|
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
buffer = (char *)malloc (file_size + 1);
|
|
|
|
if (buffer == 0)
|
|
|
|
{
|
2018-10-07 20:52:13 +02:00
|
|
|
rv = errno;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
close (file);
|
|
|
|
goto truncate_exit;
|
|
|
|
}
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
chars_read = read (file, buffer, file_size);
|
|
|
|
close (file);
|
|
|
|
|
|
|
|
if (chars_read <= 0)
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
{
|
|
|
|
rv = (chars_read < 0) ? errno : 0;
|
|
|
|
goto truncate_exit;
|
|
|
|
}
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
orig_lines = lines;
|
1999-04-16 03:34:55 +02:00
|
|
|
/* Count backwards from the end of buffer until we have passed
|
2006-05-05 20:26:14 +02:00
|
|
|
LINES lines. bp1 is set funny initially. But since bp[1] can't
|
|
|
|
be a comment character (since it's off the end) and *bp can't be
|
|
|
|
both a newline and the history comment character, it should be OK. */
|
|
|
|
for (bp1 = bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2006-05-05 20:26:14 +02:00
|
|
|
if (*bp == '\n' && HIST_TIMESTAMP_START(bp1) == 0)
|
1999-04-16 03:34:55 +02:00
|
|
|
lines--;
|
2006-05-05 20:26:14 +02:00
|
|
|
bp1 = bp;
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If this is the first line, then the file contains exactly the
|
|
|
|
number of lines we want to truncate to, so we don't need to do
|
|
|
|
anything. It's the first line if we don't find a newline between
|
|
|
|
the current value of i and 0. Otherwise, write from the start of
|
|
|
|
this line until the end of the buffer. */
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
for ( ; bp > buffer; bp--)
|
2006-05-05 20:26:14 +02:00
|
|
|
{
|
|
|
|
if (*bp == '\n' && HIST_TIMESTAMP_START(bp1) == 0)
|
|
|
|
{
|
|
|
|
bp++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bp1 = bp;
|
|
|
|
}
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
/* Write only if there are more lines in the file than we want to
|
|
|
|
truncate to. */
|
2018-10-07 20:52:13 +02:00
|
|
|
if (bp <= buffer)
|
|
|
|
{
|
|
|
|
rv = 0;
|
|
|
|
/* No-op if LINES == 0 at this point */
|
|
|
|
history_lines_written_to_file = orig_lines - lines;
|
|
|
|
goto truncate_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
tempname = history_tempfile (filename);
|
|
|
|
|
|
|
|
if ((file = open (tempname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600)) != -1)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2019-01-31 10:48:39 +01:00
|
|
|
if (write (file, bp, chars_read - (bp - buffer)) < 0)
|
|
|
|
rv = errno;
|
1999-08-03 01:48:02 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
if (close (file) < 0 && rv == 0)
|
|
|
|
rv = errno;
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
2018-10-07 20:52:13 +02:00
|
|
|
else
|
|
|
|
rv = errno;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
truncate_exit:
|
2015-07-25 21:41:05 +02:00
|
|
|
FREE (buffer);
|
Sync readline/ to version 7.0 alpha
This patch syncs our upstream copy of readline from version 6.2 to the
latest version, 7.0 alpha (released July 10 2015).
I essentially copied what was done the last time readline was synced,
when Jan updated to readline 6.2 in 2011:
http://sourceware.org/ml/gdb-patches/2011-05/msg00003.html
Procedure:
1. I extracted the readline-7.0-alpha tarball on top of readline/.
2. I deleted all the new files under doc/ that were deliberately omitted
before.
3. I regenerated readline/configure and readline/examples/rlfe/configure
using autoconf 2.64. No other configure files need regenerating.
4. I updated the function gdb_printable_part in completer.c with a
trivial change made to the readline function it is based off of,
printable_part in readline/complete.c. There is more work to be done in
completer.c to sync it with readline/complete.c, but it is non-trivial
and should probably be done separately anyway.
Local patches that had to be reapplied:
None. readline 7.0 alpha contains all of our local readline
patches.
New files in readline/:
colors.{c,h}
examples/{hist_erasedups,hist_purgecmd,rl-callbacktest,rlbasic}.c
parse-colors.{c,h}
readline.pc.in
configure.ac
Deleted files in readline/:
configure.in
Regressions:
After the sync there is one testsuite regression, the test
"signal SIGINT" in gdb.gdb/selftest.exp which now FAILs. Previously,
the readline 6.2 SIGINT handler would temporarily reinstall the
underlying application's SIGINT handler and immediately re-raise SIGINT
so that the orginal handler gets invoked. But now (since readline 6.3)
its SIGINT handler does not re-raise SIGINT or directly invoke the
original handler; it now sets a flag marking that SIGINT was raised, and
waits until readline explicitly has control to call the application's
SIGINT handler. Anyway, because SIGINT is no longer re-raised from
within readline's SIGINT handler, doing "signal SIGINT" with a stopped
inferior gdb process will no longer resume and then immediately stop the
process (since there is no 2nd SIGINT to immediately catch). Instead,
the inferior gdb process will now just print "Quit" and continue to run.
So with this commit, this particular test case is adjusted to reflect
this change in behavior (we now have to send a 2nd SIGINT manually to
stop it).
Aside from this one testsuite regression, I personally noticed no
regression in user-visible behavior. Though I only tested on x86_64
and on i686 Debian Stretch.
Getting this kind of change in at the start of the GDB 7.11 development
cycle will allow us to get a lot of passive testing from developers and
from bleeding-edge users.
readline/ChangeLog.gdb:
Import readline 7.0 alpha
* configure: Regenerate.
* examples/rlfe/configure: Regenerate.
gdb/ChangeLog:
* completer.c (gdb_printable_part): Sync with readline function
it is based off of.
gdb/testsuite/ChangeLog:
* gdb.gdb/selftest.exp (test_with_self): Update test to now
expect the GDB inferior to no longer immediately stop after
being resumed with "signal SIGINT".
2015-07-15 02:29:21 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
history_lines_written_to_file = orig_lines - lines;
|
|
|
|
|
|
|
|
if (rv == 0 && filename && tempname)
|
|
|
|
rv = histfile_restore (tempname, filename);
|
|
|
|
|
|
|
|
if (rv != 0)
|
|
|
|
{
|
|
|
|
if (tempname)
|
|
|
|
unlink (tempname);
|
|
|
|
history_lines_written_to_file = 0;
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
#if defined (HAVE_CHOWN)
|
2018-10-07 20:52:13 +02:00
|
|
|
/* Make sure the new filename is owned by the same user as the old. If one
|
|
|
|
user is running this, it's a no-op. If the shell is running after sudo
|
|
|
|
with a shared history file, we don't want to leave the history file
|
|
|
|
owned by root. */
|
|
|
|
if (rv == 0 && exists)
|
|
|
|
r = chown (filename, finfo.st_uid, finfo.st_gid);
|
2019-08-12 18:24:03 +02:00
|
|
|
#endif
|
2018-10-07 20:52:13 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
xfree (filename);
|
2018-10-07 20:52:13 +02:00
|
|
|
FREE (tempname);
|
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
return rv;
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
/* Workhorse function for writing history. Writes the last NELEMENT entries
|
1999-04-16 03:34:55 +02:00
|
|
|
from the history list to FILENAME. OVERWRITE is non-zero if you
|
|
|
|
wish to replace FILENAME with the entries. */
|
|
|
|
static int
|
2019-08-12 18:24:03 +02:00
|
|
|
history_do_write (const char *filename, int nelements, int overwrite)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
register int i;
|
2018-10-07 20:52:13 +02:00
|
|
|
char *output, *tempname, *histname;
|
|
|
|
int file, mode, rv, exists;
|
|
|
|
struct stat finfo;
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifdef HISTORY_USE_MMAP
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
size_t cursize;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
history_lines_written_to_file = 0;
|
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY;
|
|
|
|
#else
|
1999-04-16 03:34:55 +02:00
|
|
|
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
#endif
|
2018-10-07 20:52:13 +02:00
|
|
|
histname = history_filename (filename);
|
|
|
|
exists = histname ? (stat (histname, &finfo) == 0) : 0;
|
|
|
|
|
|
|
|
tempname = (overwrite && exists && S_ISREG (finfo.st_mode)) ? history_tempfile (histname) : 0;
|
|
|
|
output = tempname ? tempname : histname;
|
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
file = output ? open (output, mode, 0600) : -1;
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
rv = 0;
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2011-05-12 01:38:44 +02:00
|
|
|
if (file == -1)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
2018-10-07 20:52:13 +02:00
|
|
|
rv = errno;
|
|
|
|
FREE (histname);
|
|
|
|
FREE (tempname);
|
|
|
|
return (rv);
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifdef HISTORY_USE_MMAP
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
|
|
|
|
#endif
|
|
|
|
|
1999-04-16 03:34:55 +02:00
|
|
|
if (nelements > history_length)
|
|
|
|
nelements = history_length;
|
|
|
|
|
|
|
|
/* Build a buffer of all the lines to write, and write them in one syscall.
|
|
|
|
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
|
|
|
|
{
|
|
|
|
HIST_ENTRY **the_history; /* local */
|
|
|
|
register int j;
|
|
|
|
int buffer_size;
|
|
|
|
char *buffer;
|
|
|
|
|
|
|
|
the_history = history_list ();
|
|
|
|
/* Calculate the total number of bytes to write. */
|
|
|
|
for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
|
2006-05-05 20:26:14 +02:00
|
|
|
#if 0
|
|
|
|
buffer_size += 2 + HISTENT_BYTES (the_history[i]);
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
|
|
|
buffer_size += strlen (the_history[i]->timestamp) + 1;
|
|
|
|
buffer_size += strlen (the_history[i]->line) + 1;
|
|
|
|
}
|
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
/* Allocate the buffer, and fill it. */
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifdef HISTORY_USE_MMAP
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
if (ftruncate (file, buffer_size+cursize) == -1)
|
|
|
|
goto mmap_error;
|
|
|
|
buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize);
|
|
|
|
if ((void *)buffer == MAP_FAILED)
|
|
|
|
{
|
|
|
|
mmap_error:
|
|
|
|
rv = errno;
|
|
|
|
close (file);
|
2018-10-07 20:52:13 +02:00
|
|
|
if (tempname)
|
|
|
|
unlink (tempname);
|
|
|
|
FREE (histname);
|
|
|
|
FREE (tempname);
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
buffer = (char *)malloc (buffer_size);
|
|
|
|
if (buffer == 0)
|
|
|
|
{
|
|
|
|
rv = errno;
|
|
|
|
close (file);
|
2018-10-07 20:52:13 +02:00
|
|
|
if (tempname)
|
|
|
|
unlink (tempname);
|
|
|
|
FREE (histname);
|
|
|
|
FREE (tempname);
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
|
|
|
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
|
|
|
{
|
2006-05-05 20:26:14 +02:00
|
|
|
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
|
|
|
{
|
|
|
|
strcpy (buffer + j, the_history[i]->timestamp);
|
|
|
|
j += strlen (the_history[i]->timestamp);
|
|
|
|
buffer[j++] = '\n';
|
|
|
|
}
|
1999-04-16 03:34:55 +02:00
|
|
|
strcpy (buffer + j, the_history[i]->line);
|
|
|
|
j += strlen (the_history[i]->line);
|
|
|
|
buffer[j++] = '\n';
|
|
|
|
}
|
|
|
|
|
2006-05-05 20:26:14 +02:00
|
|
|
#ifdef HISTORY_USE_MMAP
|
2018-10-07 20:52:13 +02:00
|
|
|
if (msync (buffer, buffer_size, MS_ASYNC) != 0 || munmap (buffer, buffer_size) != 0)
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
rv = errno;
|
|
|
|
#else
|
|
|
|
if (write (file, buffer, buffer_size) < 0)
|
|
|
|
rv = errno;
|
2011-05-12 01:38:44 +02:00
|
|
|
xfree (buffer);
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
history_lines_written_to_file = nelements;
|
|
|
|
|
|
|
|
if (close (file) < 0 && rv == 0)
|
|
|
|
rv = errno;
|
|
|
|
|
|
|
|
if (rv == 0 && histname && tempname)
|
|
|
|
rv = histfile_restore (tempname, histname);
|
|
|
|
|
|
|
|
if (rv != 0)
|
|
|
|
{
|
|
|
|
if (tempname)
|
|
|
|
unlink (tempname);
|
|
|
|
history_lines_written_to_file = 0;
|
|
|
|
}
|
|
|
|
|
2019-08-12 18:24:03 +02:00
|
|
|
#if defined (HAVE_CHOWN)
|
2018-10-07 20:52:13 +02:00
|
|
|
/* Make sure the new filename is owned by the same user as the old. If one
|
|
|
|
user is running this, it's a no-op. If the shell is running after sudo
|
|
|
|
with a shared history file, we don't want to leave the history file
|
|
|
|
owned by root. */
|
|
|
|
if (rv == 0 && exists)
|
|
|
|
mode = chown (histname, finfo.st_uid, finfo.st_gid);
|
2019-08-12 18:24:03 +02:00
|
|
|
#endif
|
1999-04-16 03:34:55 +02:00
|
|
|
|
2018-10-07 20:52:13 +02:00
|
|
|
FREE (histname);
|
|
|
|
FREE (tempname);
|
1999-04-16 03:34:55 +02:00
|
|
|
|
Import of readline 4.3.
Non-readline modified files:
src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c
In readline directory:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-12-08 23:31:39 +01:00
|
|
|
return (rv);
|
1999-04-16 03:34:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
|
|
|
the end of the list minus NELEMENTs up to the end of the list. */
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
append_history (int nelements, const char *filename)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
return (history_do_write (filename, nelements, HISTORY_APPEND));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Overwrite FILENAME with the current history. If FILENAME is NULL,
|
|
|
|
then write the history list to ~/.history. Values returned
|
|
|
|
are as in read_history ().*/
|
|
|
|
int
|
2019-08-12 18:24:03 +02:00
|
|
|
write_history (const char *filename)
|
1999-04-16 03:34:55 +02:00
|
|
|
{
|
|
|
|
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
|
|
|
|
}
|