changes to placing rl_point after alias-expand-line or history-expand-line

This commit is contained in:
Chet Ramey
2023-02-15 15:31:02 -05:00
parent d7a6d947df
commit 5857180657
5 changed files with 74 additions and 14 deletions
+30
View File
@@ -270,6 +270,36 @@ strip_trailing (char *string, int len, int newlines_only)
string[len + 1] = '\0';
}
int
str_firstdiff (const char *s, const char *t)
{
int n;
if (s == 0 || t == 0 || *s == '\0' || *t == '\0')
return 0;
for (n = 0; s[n] && t[n] && s[n] == t[n]; n++)
;
return n;
}
/* This returns the index in OLD of a common suffix of OLD and NEW */
int
str_lastsame (const char *old, const char *new)
{
const char *o, *n;
if (old == 0 || *old == '\0' || new == 0 || *new == '\0')
return 0; /* XXX */
o = old + STRLEN (old) - 1;
n = new + STRLEN (new) - 1;
while (o > old && n > new && (*o == *n))
o--, n--;
return (o - old);
}
/* A wrapper for bcopy that can be prototyped in general.h */
void
xbcopy (const void *s, void *d, size_t n)