1
1

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
Этот коммит содержится в:
David Lawrence Ramsey 2005-02-22 23:22:37 +00:00
родитель 60e329e3b2
Коммит ad96aff50d
7 изменённых файлов: 13 добавлений и 28 удалений

Просмотреть файл

@ -151,7 +151,7 @@ CVS code -
get_totals(), and do_cursorpos(). (DLR) get_totals(), and do_cursorpos(). (DLR)
- Overhaul the tab completion code, the file browser code, and - Overhaul the tab completion code, the file browser code, and
related functions to increase efficiency and support multibyte 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(), get_full_path(), check_writable_directory(), safe_tempnam(),
diralphasort(), username_tab_completion(), diralphasort(), username_tab_completion(),
cwd_tab_completion(), input_tab(), tail(), striponedir(), cwd_tab_completion(), input_tab(), tail(), striponedir(),

Просмотреть файл

@ -591,7 +591,7 @@ const char *mbstrcasestr(const char *haystack, const char *needle)
#endif #endif
} }
#ifndef NANO_SMALL #if !defined(NANO_SMALL) || !defined(DISABLE_TABCOMP)
/* This function is equivalent to strstr(), except in that it scans the /* This function is equivalent to strstr(), except in that it scans the
* string in reverse, starting at rev_start. */ * string in reverse, starting at rev_start. */
const char *revstrstr(const char *haystack, const char *needle, const 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; return NULL;
} }
#endif
#ifndef NANO_SMALL
/* This function is equivalent to strcasestr(), except in that it scans /* This function is equivalent to strcasestr(), except in that it scans
* the string in reverse, starting at rev_start. */ * the string in reverse, starting at rev_start. */
const char *revstrcasestr(const char *haystack, const char *needle, 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); nstrnlen(s, maxlen);
#endif #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

Просмотреть файл

@ -2157,8 +2157,10 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
beep(); beep();
else { else {
size_t match, common_len = 0; size_t match, common_len = 0;
size_t lastslash = strrchrn(buf, '/', *place);
char *mzero; char *mzero;
const char *lastslash = revstrstr(buf, "/", buf + *place);
size_t lastslash_len = (lastslash == NULL) ? 0 :
lastslash - buf + 1;
while (TRUE) { while (TRUE) {
for (match = 1; match < num_matches; match++) { 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++; common_len++;
} }
mzero = charalloc(lastslash + common_len + 1); mzero = charalloc(lastslash_len + common_len + 1);
sprintf(mzero, "%.*s%.*s", lastslash, buf, common_len, sprintf(mzero, "%.*s%.*s", lastslash_len, buf, common_len,
matches[0]); matches[0]);
common_len += lastslash; common_len += lastslash_len;
assert(common_len >= *place); 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_backup_msg = N_("Back up original file when saving");
const char *nano_execute_msg = N_("Execute external command"); const char *nano_execute_msg = N_("Execute external command");
#endif #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"); const char *nano_multibuffer_msg = N_("Insert into new buffer");
#endif #endif
#ifndef DISABLE_BROWSER #ifndef DISABLE_BROWSER

Просмотреть файл

@ -203,9 +203,6 @@ size_t mbstrlen(const char *s);
size_t nstrnlen(const char *s, size_t maxlen); size_t nstrnlen(const char *s, size_t maxlen);
#endif #endif
size_t mbstrnlen(const char *s, size_t maxlen); 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. */ /* Public functions in color.c. */
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR

Просмотреть файл

@ -249,7 +249,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
return NULL; return NULL;
} }
#endif /* HAVE_REGEX_H */ #endif /* HAVE_REGEX_H */
#if !defined(DISABLE_SPELLER) || !defined(NANO_SMALL) #if !defined(NANO_SMALL) || !defined(DISABLE_SPELLER)
if (ISSET(CASE_SENSITIVE)) { if (ISSET(CASE_SENSITIVE)) {
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (ISSET(REVERSE_SEARCH)) if (ISSET(REVERSE_SEARCH))

Просмотреть файл

@ -3026,7 +3026,7 @@ void reset_cursor(void)
void edit_add(const filestruct *fileptr, const char *converted, int void edit_add(const filestruct *fileptr, const char *converted, int
yval, size_t start) 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); size_t startpos = actual_x(fileptr->data, start);
/* The position in fileptr->data of the leftmost character /* The position in fileptr->data of the leftmost character
* that displays at least partially on the window. */ * that displays at least partially on the window. */