From 18d616f253810303b588b67abea9bdcd18992673 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sun, 16 Jan 2005 19:30:48 +0000 Subject: [PATCH] put revstrstr() back in utils.c, as it's case sensitive and hance should work with multibyte strings as-is git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2279 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 20 ++++++++++---------- src/chars.c | 21 +-------------------- src/utils.c | 24 ++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c0a1297..a81cd9b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -102,16 +102,16 @@ CVS code - chars.c), is_cntrl_char() (moved to chars.c), nstricmp() (renamed nstrcasecmp() and moved to chars.c), nstrnicmp() (renamed nstrncasecmp() and moved to chars.c), nstristr() - (renamed nstrcasestr() and moved to chars.c), revstrstr() - (moved to chars.c), revstristr() (renamed revstrcasestr() and - moved to chars.c), nstrnlen() (moved to chars.c), - parse_char() (renamed parse_mbchar() and moved to chars.c), - move_left() (renamed move_mbleft() and moved to chars.c), - move_right() (renamed move_mbright() and moved to chars.c), - do_home(), do_verbatim_input(), do_delete(), do_tab(), - do_next_word(), do_prev_word(), do_input(), do_output(), - get_buffer(), unget_input(), unget_kbinput(), get_input(), - parse_kbinput(), unparse_kbinput(), parse_verbatim_kbinput(), + (renamed nstrcasestr() and moved to chars.c), revstristr() + (renamed revstrcasestr() and moved to chars.c), nstrnlen() + (moved to chars.c), parse_char() (renamed parse_mbchar() and + moved to chars.c), move_left() (renamed move_mbleft() and + moved to chars.c), move_right() (renamed move_mbright() and + moved to chars.c), do_home(), do_verbatim_input(), + do_delete(), do_tab(), do_next_word(), do_prev_word(), + do_input(), do_output(), get_buffer(), unget_input(), + unget_kbinput(), get_input(), parse_kbinput(), + unparse_kbinput(), parse_verbatim_kbinput(), do_statusbar_input(), do_statusbar_home(), do_statusbar_verbatim_kbinput(), do_statusbar_output(), and display_string(); removal of buffer_to_keys() and diff --git a/src/chars.c b/src/chars.c index 1eb11775..5b82ad8f 100644 --- a/src/chars.c +++ b/src/chars.c @@ -595,26 +595,7 @@ const char *nstrcasestr(const char *haystack, const char *needle) } #endif -/* None of this is needed if we're using NANO_SMALL! */ #ifndef NANO_SMALL -const char *revstrstr(const char *haystack, const char *needle, const - char *rev_start) -{ - assert(haystack != NULL && needle != NULL && rev_start != NULL); - - for (; rev_start >= haystack; rev_start--) { - const char *r, *q; - - for (r = rev_start, q = needle; *q == *r && *q != '\0'; r++, q++) - ; - - if (*q == '\0') - return rev_start; - } - - return NULL; -} - const char *revstrcasestr(const char *haystack, const char *needle, const char *rev_start) { @@ -632,7 +613,7 @@ const char *revstrcasestr(const char *haystack, const char *needle, return NULL; } -#endif /* !NANO_SMALL */ +#endif #ifndef HAVE_STRNLEN /* This function is equivalent to strnlen(). */ diff --git a/src/utils.c b/src/utils.c index 4ece1358..e00cb9f4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -131,7 +131,26 @@ void sunder(char *str) } } -#if !defined(NANO_SMALL) && defined(ENABLE_NANORC) +#ifndef NANO_SMALL +const char *revstrstr(const char *haystack, const char *needle, const + char *rev_start) +{ + assert(haystack != NULL && needle != NULL && rev_start != NULL); + + for (; rev_start >= haystack; rev_start--) { + const char *r, *q; + + for (r = rev_start, q = needle; *q == *r && *q != '\0'; r++, q++) + ; + + if (*q == '\0') + return rev_start; + } + + return NULL; +} + +#ifdef ENABLE_NANORC #ifndef HAVE_GETLINE /* This function is equivalent to getline(). It was adapted from * GNU mailutils' getline() function. */ @@ -189,7 +208,8 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream) return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1; } #endif -#endif /* !NANO_SMALL && ENABLE_NANORC */ +#endif /* ENABLE_NANORC */ +#endif /* !NANO_SMALL */ /* If we are searching backwards, we will find the last match that * starts no later than start. Otherwise we find the first match -- 2.39.5