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
Этот коммит содержится в:
родитель
60e329e3b2
Коммит
ad96aff50d
@ -151,7 +151,7 @@ CVS code -
|
||||
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(),
|
||||
|
20
src/chars.c
20
src/chars.c
@ -591,7 +591,7 @@ const char *mbstrcasestr(const char *haystack, const char *needle)
|
||||
#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
|
||||
@ -611,7 +611,9 @@ 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,
|
||||
@ -750,19 +752,3 @@ size_t mbstrnlen(const char *s, size_t maxlen)
|
||||
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
|
||||
|
10
src/files.c
10
src/files.c
@ -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);
|
||||
|
||||
|
@ -356,7 +356,7 @@ void shortcut_init(bool unjustify)
|
||||
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
|
||||
|
@ -203,9 +203,6 @@ size_t mbstrlen(const char *s);
|
||||
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
|
||||
|
@ -249,7 +249,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
|
||||
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))
|
||||
|
@ -3026,7 +3026,7 @@ void reset_cursor(void)
|
||||
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. */
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user