get_totals(), and do_cursorpos(). (DLR)
- Overhaul the tab completion code, the file browser code, and
related functions to increase efficiency and support multibyte
- characters. New functions strrchrn() and is_dir(); changes to
+ characters. New function is_dir(); changes to
get_full_path(), check_writable_directory(), safe_tempnam(),
diralphasort(), username_tab_completion(),
cwd_tab_completion(), input_tab(), tail(), striponedir(),
#endif
}
-#ifndef NANO_SMALL
+#if !defined(NANO_SMALL) || !defined(DISABLE_TABCOMP)
/* This function is equivalent to strstr(), except in that it scans the
* string in reverse, starting at rev_start. */
const char *revstrstr(const char *haystack, const char *needle, const
return NULL;
}
+#endif
+#ifndef NANO_SMALL
/* This function is equivalent to strcasestr(), except in that it scans
* the string in reverse, starting at rev_start. */
const char *revstrcasestr(const char *haystack, const char *needle,
nstrnlen(s, maxlen);
#endif
}
-
-#ifndef DISABLE_TABCOMP
-/* Find the one-based position of the last occurrence of character c in
- * the first n characters of s. Return 0 if c is not found. */
-size_t strrchrn(const char *s, int c, size_t n)
-{
- assert(n <= strlen(s));
-
- for (s += n - 1; n >= 1; n--, s--) {
- if (c == *s)
- return n;
- }
-
- return 0;
-}
-#endif
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++) {
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);
const char *nano_backup_msg = N_("Back up original file when saving");
const char *nano_execute_msg = N_("Execute external command");
#endif
-#if defined(ENABLE_MULTIBUFFER) && !defined(NANO_SMALL)
+#if !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
const char *nano_multibuffer_msg = N_("Insert into new buffer");
#endif
#ifndef DISABLE_BROWSER
size_t nstrnlen(const char *s, size_t maxlen);
#endif
size_t mbstrnlen(const char *s, size_t maxlen);
-#ifndef DISABLE_TABCOMP
-size_t strrchrn(const char *s, int c, size_t n);
-#endif
/* Public functions in color.c. */
#ifdef ENABLE_COLOR
return NULL;
}
#endif /* HAVE_REGEX_H */
-#if !defined(DISABLE_SPELLER) || !defined(NANO_SMALL)
+#if !defined(NANO_SMALL) || !defined(DISABLE_SPELLER)
if (ISSET(CASE_SENSITIVE)) {
#ifndef NANO_SMALL
if (ISSET(REVERSE_SEARCH))
void edit_add(const filestruct *fileptr, const char *converted, int
yval, size_t start)
{
-#if defined(ENABLE_COLOR) || !defined(NANO_SMALL)
+#if !defined(NANO_SMALL) || defined(ENABLE_COLOR)
size_t startpos = actual_x(fileptr->data, start);
/* The position in fileptr->data of the leftmost character
* that displays at least partially on the window. */