diff options
author | ache <ache@FreeBSD.org> | 1997-06-07 12:17:44 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-06-07 12:17:44 +0000 |
commit | b6bac891b077ba9da2b507a621c4a85d8eb378f1 (patch) | |
tree | 273a40857d601fa83d190bfbfb6ae23041a7743d /contrib/libreadline/histexpand.c | |
parent | c83c156e7342a7eb5f28600f69a0847e24720fc8 (diff) | |
download | FreeBSD-src-b6bac891b077ba9da2b507a621c4a85d8eb378f1.zip FreeBSD-src-b6bac891b077ba9da2b507a621c4a85d8eb378f1.tar.gz |
Virgin import of readline-2.1, unneded docs deleted
Diffstat (limited to 'contrib/libreadline/histexpand.c')
-rw-r--r-- | contrib/libreadline/histexpand.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/contrib/libreadline/histexpand.c b/contrib/libreadline/histexpand.c index d916c74..de71d78 100644 --- a/contrib/libreadline/histexpand.c +++ b/contrib/libreadline/histexpand.c @@ -59,11 +59,7 @@ static char *history_find_word (); extern int history_offset; -#if defined (SHELL) extern char *single_quote (); -#else -static char *single_quote (); -#endif /* !SHELL */ static char *quote_breaks (); extern char *xmalloc (), *xrealloc (); @@ -91,6 +87,10 @@ char *history_no_expand_chars = " \t\n\r="; The default is 0. */ int history_quotes_inhibit_expansion = 0; +/* If set, this points to a function that is called to verify that a + particular history expansion should be performed. */ +Function *history_inhibit_expansion_function; + /* **************************************************************** */ /* */ /* History Expansion */ @@ -289,38 +289,6 @@ hist_string_extract_single_quoted (string, sindex) *sindex = i; } -#if !defined (SHELL) -/* Does shell-like quoting using single quotes. */ -static char * -single_quote (string) - char *string; -{ - register int c; - char *result, *r, *s; - - result = (char *)xmalloc (3 + (3 * strlen (string))); - r = result; - *r++ = '\''; - - for (s = string; s && (c = *s); s++) - { - *r++ = c; - - if (c == '\'') - { - *r++ = '\\'; /* insert escaped single quote */ - *r++ = '\''; - *r++ = '\''; /* start new quoted string */ - } - } - - *r++ = '\''; - *r = '\0'; - - return (result); -} -#endif /* !SHELL */ - static char * quote_breaks (s) char *s; @@ -888,19 +856,14 @@ history_expand (hstring, output) { if (!cc || member (cc, history_no_expand_chars)) continue; -#if defined (SHELL) - /* The shell uses ! as a pattern negation character - in globbing [...] expressions, so let those pass - without expansion. */ - else if (i > 0 && (string[i - 1] == '[') && - member (']', string + i + 1)) - continue; - /* The shell uses ! as the indirect expansion character, so - let those expansions pass as well. */ - else if (i > 1 && string[i - 1] == '{' && string[i - 2] == '$' && - member ('}', string + i + 1)) + /* If the calling application has set + history_inhibit_expansion_function to a function that checks + for special cases that should not be history expanded, + call the function and skip the expansion if it returns a + non-zero value. */ + else if (history_inhibit_expansion_function && + (*history_inhibit_expansion_function) (string, i)) continue; -#endif /* SHELL */ else break; } |