summaryrefslogtreecommitdiffstats
path: root/contrib/libreadline/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libreadline/util.c')
-rw-r--r--contrib/libreadline/util.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/contrib/libreadline/util.c b/contrib/libreadline/util.c
index d96b29e..fde012e 100644
--- a/contrib/libreadline/util.c
+++ b/contrib/libreadline/util.c
@@ -166,6 +166,58 @@ rl_extend_line_buffer (len)
_rl_set_the_line ();
}
+
+/* A function for simple tilde expansion. */
+int
+rl_tilde_expand (ignore, key)
+ int ignore, key;
+{
+ register int start, end;
+ char *homedir, *temp;
+ int len;
+
+ end = rl_point;
+ start = end - 1;
+
+ if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
+ {
+ homedir = tilde_expand ("~");
+ _rl_replace_text (homedir, start, end);
+ return (0);
+ }
+ else if (rl_line_buffer[start] != '~')
+ {
+ for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
+ ;
+ start++;
+ }
+
+ end = start;
+ do
+ end++;
+ while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
+
+ if (whitespace (rl_line_buffer[end]) || end >= rl_end)
+ end--;
+
+ /* If the first character of the current word is a tilde, perform
+ tilde expansion and insert the result. If not a tilde, do
+ nothing. */
+ if (rl_line_buffer[start] == '~')
+ {
+ len = end - start + 1;
+ temp = xmalloc (len + 1);
+ strncpy (temp, rl_line_buffer + start, len);
+ temp[len] = '\0';
+ homedir = tilde_expand (temp);
+ free (temp);
+
+ _rl_replace_text (homedir, start, end);
+ }
+
+ return (0);
+}
+
/* **************************************************************** */
/* */
/* String Utility Functions */
@@ -300,3 +352,13 @@ _rl_digit_value (c)
{
return (isdigit (c) ? c - '0' : c);
}
+
+/* Backwards compatibility, now that savestring has been removed from
+ all `public' readline header files. */
+#undef _rl_savestring
+char *
+_rl_savestring (s)
+ char *s;
+{
+ return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
+}
OpenPOWER on IntegriCloud