aboutsummaryrefslogtreecommitdiff
path: root/readline/histexpand.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-07-14 20:29:21 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2015-07-25 09:53:01 -0400
commit4a11f2065906976675808364ddbd1c0f77eea41f (patch)
tree8b25495190b4d41b1785910c4cc4fd709d0a628a /readline/histexpand.c
parenta496fbc8802f0a5719db6347a43cc869e03d83c9 (diff)
downloadgdb-4a11f2065906976675808364ddbd1c0f77eea41f.zip
gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.gz
gdb-4a11f2065906976675808364ddbd1c0f77eea41f.tar.bz2
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".
Diffstat (limited to 'readline/histexpand.c')
-rw-r--r--readline/histexpand.c83
1 files changed, 44 insertions, 39 deletions
diff --git a/readline/histexpand.c b/readline/histexpand.c
index 8fb3798..fc13303 100644
--- a/readline/histexpand.c
+++ b/readline/histexpand.c
@@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */
-/* Copyright (C) 1989-2010 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2012 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -50,6 +50,7 @@
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
#define HISTORY_QUOTE_CHARACTERS "\"'`"
+#define HISTORY_EVENT_DELIMITERS "^$*%-"
#define slashify_in_quotes "\\`\"$"
@@ -62,6 +63,10 @@ static char *subst_rhs;
static int subst_lhs_len;
static int subst_rhs_len;
+/* Characters that delimit history event specifications and separate event
+ specifications from word designators. Static for now */
+static char *history_event_delimiter_chars = HISTORY_EVENT_DELIMITERS;
+
static char *get_history_word_specifier PARAMS((char *, char *, int *));
static int history_tokenize_word PARAMS((const char *, int));
static char **history_tokenize_internal PARAMS((const char *, int, int *));
@@ -112,7 +117,6 @@ rl_linebuf_func_t *history_inhibit_expansion_function;
/* The last string searched for by a !?string? search. */
static char *search_string;
-
/* The last string matched by a !?string? search. */
static char *search_match;
@@ -225,6 +229,7 @@ get_history_event (string, caller_index, delimiting_quote)
#endif /* HANDLE_MULTIBYTE */
if ((!substring_okay && (whitespace (c) || c == ':' ||
+ (history_event_delimiter_chars && member (c, history_event_delimiter_chars)) ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
string[i] == '\n' ||
@@ -272,6 +277,8 @@ get_history_event (string, caller_index, delimiting_quote)
if (local_index == 0 || substring_okay)
{
entry = current_history ();
+ if (entry == 0)
+ FAIL_SEARCH ();
history_offset = history_length;
/* If this was a substring search, then remember the
@@ -519,9 +526,9 @@ postproc_subst_rhs ()
the returned string. Returns the new index into string in
*END_INDEX_PTR, and the expanded specifier in *RET_STRING. */
static int
-history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
+history_expand_internal (string, start, qc, end_index_ptr, ret_string, current_line)
char *string;
- int start, *end_index_ptr;
+ int start, qc, *end_index_ptr;
char **ret_string;
char *current_line; /* for !# */
{
@@ -557,30 +564,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
event = current_line;
}
else
- {
- int quoted_search_delimiter = 0;
-
- /* If the character before this `!' is a double or single
- quote, then this expansion takes place inside of the
- quoted string. If we have to search for some text ("!foo"),
- allow the delimiter to end the search string. */
-#if defined (HANDLE_MULTIBYTE)
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- {
- int ch, l;
- l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY);
- ch = string[l];
- /* XXX - original patch had i - 1 ??? If i == 0 it would fail. */
- if (i && (ch == '\'' || ch == '"'))
- quoted_search_delimiter = ch;
- }
- else
-#endif /* HANDLE_MULTIBYTE */
- if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
- quoted_search_delimiter = string[i - 1];
-
- event = get_history_event (string, &i, quoted_search_delimiter);
- }
+ event = get_history_event (string, &i, qc);
if (event == 0)
{
@@ -854,7 +838,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
}
i += 2;
}
- /* Done with modfiers. */
+ /* Done with modifiers. */
/* Believe it or not, we have to back the pointer up by one. */
--i;
@@ -894,7 +878,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
1) If expansions did take place
2) If the `p' modifier was given and the caller should print the result
- If an error ocurred in expansion, then OUTPUT contains a descriptive
+ If an error occurred in expansion, then OUTPUT contains a descriptive
error message. */
#define ADD_STRING(s) \
@@ -928,7 +912,7 @@ history_expand (hstring, output)
char **output;
{
register int j;
- int i, r, l, passc, cc, modified, eindex, only_printing, dquote, flag;
+ int i, r, l, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
char *string;
/* The output string, and its length. */
@@ -991,7 +975,7 @@ history_expand (hstring, output)
/* `!' followed by one of the characters in history_no_expand_chars
is NOT an expansion. */
- for (i = dquote = 0; string[i]; i++)
+ for (i = dquote = squote = 0; string[i]; i++)
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
@@ -1012,6 +996,7 @@ history_expand (hstring, output)
history expansion performed on it.
Skip the rest of the line and break out of the loop. */
if (history_comment_char && string[i] == history_comment_char &&
+ dquote == 0 &&
(i == 0 || member (string[i - 1], history_word_delimiters)))
{
while (string[i])
@@ -1022,6 +1007,13 @@ history_expand (hstring, output)
{
if (cc == 0 || member (cc, history_no_expand_chars))
continue;
+ /* DQUOTE won't be set unless history_quotes_inhibit_expansion
+ is set. The idea here is to treat double-quoted strings the
+ same as the word outside double quotes; in effect making the
+ double quote part of history_no_expand_chars when DQUOTE is
+ set. */
+ else if (dquote && cc == '"')
+ continue;
/* If the calling application has set
history_inhibit_expansion_function to a function that checks
for special cases that should not be history expanded,
@@ -1071,9 +1063,9 @@ history_expand (hstring, output)
}
/* Extract and perform the substitution. */
- for (passc = dquote = i = j = 0; i < l; i++)
+ for (passc = dquote = squote = i = j = 0; i < l; i++)
{
- int tchar = string[i];
+ int qc, tchar = string[i];
if (passc)
{
@@ -1130,8 +1122,14 @@ history_expand (hstring, output)
case '\'':
{
/* If history_quotes_inhibit_expansion is set, single quotes
- inhibit history expansion. */
- if (dquote == 0 && history_quotes_inhibit_expansion)
+ inhibit history expansion, otherwise they are treated like
+ double quotes. */
+ if (squote)
+ {
+ squote = 0;
+ ADD_CHAR (tchar);
+ }
+ else if (dquote == 0 && history_quotes_inhibit_expansion)
{
int quote, slen;
@@ -1146,13 +1144,19 @@ history_expand (hstring, output)
ADD_STRING (temp);
xfree (temp);
}
+ else if (dquote == 0 && squote == 0 && history_quotes_inhibit_expansion == 0)
+ {
+ squote = 1;
+ ADD_CHAR (string[i]);
+ }
else
ADD_CHAR (string[i]);
break;
}
case -2: /* history_comment_char */
- if (i == 0 || member (string[i - 1], history_word_delimiters))
+ if ((dquote == 0 || history_quotes_inhibit_expansion == 0) &&
+ (i == 0 || member (string[i - 1], history_word_delimiters)))
{
temp = (char *)xmalloc (l - i + 1);
strcpy (temp, string + i);
@@ -1171,6 +1175,7 @@ history_expand (hstring, output)
characters in history_no_expand_chars, then it is not a
candidate for expansion of any kind. */
if (cc == 0 || member (cc, history_no_expand_chars) ||
+ (dquote && cc == '"') ||
(history_inhibit_expansion_function && (*history_inhibit_expansion_function) (string, i)))
{
ADD_CHAR (string[i]);
@@ -1196,8 +1201,8 @@ history_expand (hstring, output)
break;
}
#endif
-
- r = history_expand_internal (string, i, &eindex, &temp, result);
+ qc = squote ? '\'' : (dquote ? '"' : 0);
+ r = history_expand_internal (string, i, qc, &eindex, &temp, result);
if (r < 0)
{
*output = temp;