mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-31 23:43:37 +02:00
commit bash-20151230 snapshot
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* histexpand.c -- history expansion. */
|
||||
|
||||
/* Copyright (C) 1989-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
||||
+30
-2
@@ -107,9 +107,19 @@ extern int errno;
|
||||
# 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;
|
||||
|
||||
/* If non-zero, we write timestamps to the history file in history_do_write() */
|
||||
int history_write_timestamps = 0;
|
||||
|
||||
/* 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. */
|
||||
@@ -259,7 +269,7 @@ read_history_range (filename, from, to)
|
||||
{
|
||||
register char *line_start, *line_end, *p;
|
||||
char *input, *buffer, *bufend, *last_ts;
|
||||
int file, current_line, chars_read;
|
||||
int file, current_line, chars_read, has_timestamps, reset_comment_char;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
#if defined (EFBIG)
|
||||
@@ -336,6 +346,19 @@ read_history_range (filename, from, to)
|
||||
bufend = buffer + chars_read;
|
||||
current_line = 0;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Skip lines until we are at FROM. */
|
||||
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
|
||||
if (*line_end == '\n')
|
||||
@@ -362,7 +385,10 @@ read_history_range (filename, from, to)
|
||||
{
|
||||
if (HIST_TIMESTAMP_START(line_start) == 0)
|
||||
{
|
||||
add_history (line_start);
|
||||
if (last_ts == NULL && history_multiline_entries)
|
||||
_hs_append_history_line (history_length - 1, line_start);
|
||||
else
|
||||
add_history (line_start);
|
||||
if (last_ts)
|
||||
{
|
||||
add_history_time (last_ts);
|
||||
@@ -385,6 +411,8 @@ read_history_range (filename, from, to)
|
||||
}
|
||||
|
||||
history_lines_read_from_file = current_line;
|
||||
if (reset_comment_char)
|
||||
history_comment_char = '\0';
|
||||
|
||||
FREE (input);
|
||||
#ifndef HISTORY_USE_MMAP
|
||||
|
||||
+25
-1
@@ -1,6 +1,6 @@
|
||||
/* history.c -- standalone history library */
|
||||
|
||||
/* Copyright (C) 1989-2011 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
@@ -407,6 +407,30 @@ replace_history_entry (which, line, data)
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
/* Append LINE to the history line at offset WHICH, adding a newline to the
|
||||
end of the current line first. This can be used to construct multi-line
|
||||
history entries while reading lines from the history file. */
|
||||
void
|
||||
_hs_append_history_line (which, line)
|
||||
int which;
|
||||
const char *line;
|
||||
{
|
||||
HIST_ENTRY *hent;
|
||||
size_t newlen, curlen;
|
||||
char *newline;
|
||||
|
||||
hent = the_history[which];
|
||||
curlen = strlen (hent->line);
|
||||
newlen = curlen + strlen (line) + 2;
|
||||
newline = realloc (hent->line, newlen);
|
||||
if (newline)
|
||||
{
|
||||
hent->line = newline;
|
||||
hent->line[curlen++] = '\n';
|
||||
strcpy (hent->line + curlen, line);
|
||||
}
|
||||
}
|
||||
|
||||
/* Replace the DATA in the specified history entries, replacing OLD with
|
||||
NEW. WHICH says which one(s) to replace: WHICH == -1 means to replace
|
||||
all of the history entries where entry->data == OLD; WHICH == -2 means
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* history.h -- the names of functions that you can call in history. */
|
||||
|
||||
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (History), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
@@ -263,6 +263,10 @@ extern int history_quotes_inhibit_expansion;
|
||||
|
||||
extern int history_write_timestamps;
|
||||
|
||||
/* These two are undocumented; the second is reserved for future use */
|
||||
extern int history_multiline_entries;
|
||||
extern int history_file_version;
|
||||
|
||||
/* Backwards compatibility */
|
||||
extern int max_input_history;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/* util.c -- readline utility functions */
|
||||
|
||||
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Reference in New Issue
Block a user