tweaks: elide an unneeded call of strlen(), and copy NUL byte with string
parent
258e7c6e65
commit
b0f563980d
|
@ -2610,7 +2610,7 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
|
||||||
mzero[common_len] = '\0';
|
mzero[common_len] = '\0';
|
||||||
|
|
||||||
/* Cover also the case of the user specifying a relative path. */
|
/* Cover also the case of the user specifying a relative path. */
|
||||||
glued = charalloc(strlen(present_path) + strlen(mzero) + 1);
|
glued = charalloc(strlen(present_path) + common_len + 1);
|
||||||
sprintf(glued, "%s%s", present_path, mzero);
|
sprintf(glued, "%s%s", present_path, mzero);
|
||||||
|
|
||||||
if (num_matches == 1 && (is_dir(mzero) || is_dir(glued)))
|
if (num_matches == 1 && (is_dir(mzero) || is_dir(glued)))
|
||||||
|
@ -2619,8 +2619,7 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
|
||||||
/* If the matches have something in common, copy that part. */
|
/* If the matches have something in common, copy that part. */
|
||||||
if (common_len != *place) {
|
if (common_len != *place) {
|
||||||
buf = charealloc(buf, common_len + 1);
|
buf = charealloc(buf, common_len + 1);
|
||||||
memmove(buf + common_len, buf + *place, 1);
|
strcpy(buf, mzero);
|
||||||
strncpy(buf, mzero, common_len);
|
|
||||||
*place = common_len;
|
*place = common_len;
|
||||||
} else if (num_matches == 1)
|
} else if (num_matches == 1)
|
||||||
beep();
|
beep();
|
||||||
|
|
Loading…
Reference in New Issue