rework things so that strrchrn() is no longer needed, and remove it

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2325 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey
2005-02-22 23:22:37 +00:00
parent 60e329e3b2
commit ad96aff50d
7 changed files with 13 additions and 28 deletions

View File

@@ -2157,8 +2157,10 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
beep();
else {
size_t match, common_len = 0;
size_t lastslash = strrchrn(buf, '/', *place);
char *mzero;
const char *lastslash = revstrstr(buf, "/", buf + *place);
size_t lastslash_len = (lastslash == NULL) ? 0 :
lastslash - buf + 1;
while (TRUE) {
for (match = 1; match < num_matches; match++) {
@@ -2173,11 +2175,11 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
common_len++;
}
mzero = charalloc(lastslash + common_len + 1);
sprintf(mzero, "%.*s%.*s", lastslash, buf, common_len,
mzero = charalloc(lastslash_len + common_len + 1);
sprintf(mzero, "%.*s%.*s", lastslash_len, buf, common_len,
matches[0]);
common_len += lastslash;
common_len += lastslash_len;
assert(common_len >= *place);