reorganization: move revstrstr() back to chars.c, and move is_byte()
there too, since they both deal with strings and hence characters git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2286 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
2bd22761ac
Коммит
21954765ca
11
ChangeLog
11
ChangeLog
@ -98,11 +98,12 @@ CVS code -
|
|||||||
is_blank_wchar(), is_cntrl_mbchar(), is_cntrl_wchar(),
|
is_blank_wchar(), is_cntrl_mbchar(), is_cntrl_wchar(),
|
||||||
control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(),
|
control_mbrep(), control_wrep(), mbwidth(), mb_cur_max(),
|
||||||
make_mbchar(), mbstrnlen(), mbstrcasecmp(), and
|
make_mbchar(), mbstrnlen(), mbstrcasecmp(), and
|
||||||
mbstrncasecmp(); changes to is_blank_char() (moved to
|
mbstrncasecmp(); changes to is_byte() (moved to chars.c),
|
||||||
chars.c), is_cntrl_char() (moved to chars.c), nstricmp()
|
is_blank_char() (moved to chars.c), is_cntrl_char() (moved to
|
||||||
(renamed nstrcasecmp() and moved to chars.c), nstrnicmp()
|
chars.c), nstricmp() (renamed nstrcasecmp() and moved to
|
||||||
(renamed nstrncasecmp() and moved to chars.c), nstristr()
|
chars.c), nstrnicmp() (renamed nstrncasecmp() and moved to
|
||||||
(renamed nstrcasestr() and moved to chars.c), revstristr()
|
chars.c), nstristr() (renamed nstrcasestr() and moved to
|
||||||
|
chars.c), revstrstr() (moved to chars.c), revstristr()
|
||||||
(renamed revstrcasestr() and moved to chars.c), nstrnlen()
|
(renamed revstrcasestr() and moved to chars.c), nstrnlen()
|
||||||
(moved to chars.c), parse_char() (renamed parse_mbchar() and
|
(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_left() (renamed move_mbleft() and
|
||||||
|
29
src/chars.c
29
src/chars.c
@ -38,6 +38,13 @@
|
|||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Return TRUE if the value of c is in byte range, and FALSE
|
||||||
|
* otherwise. */
|
||||||
|
bool is_byte(unsigned int c)
|
||||||
|
{
|
||||||
|
return (c == (unsigned char)c);
|
||||||
|
}
|
||||||
|
|
||||||
/* This function is equivalent to isalnum(). */
|
/* This function is equivalent to isalnum(). */
|
||||||
bool is_alnum_char(unsigned int c)
|
bool is_alnum_char(unsigned int c)
|
||||||
{
|
{
|
||||||
@ -596,6 +603,28 @@ const char *nstrcasestr(const char *haystack, const char *needle)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
/* This function is equivalent to strstr(), except in that it scans the
|
||||||
|
* string in reverse. */
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is equivalent to strcasestr(), except in that it scans
|
||||||
|
* the string in reverse. */
|
||||||
const char *revstrcasestr(const char *haystack, const char *needle,
|
const char *revstrcasestr(const char *haystack, const char *needle,
|
||||||
const char *rev_start)
|
const char *rev_start)
|
||||||
{
|
{
|
||||||
|
@ -151,6 +151,7 @@ extern char *homedir;
|
|||||||
/* Functions we want available. */
|
/* Functions we want available. */
|
||||||
|
|
||||||
/* Public functions in chars.c. */
|
/* Public functions in chars.c. */
|
||||||
|
bool is_byte(unsigned int c);
|
||||||
bool is_alnum_char(unsigned int c);
|
bool is_alnum_char(unsigned int c);
|
||||||
bool is_alnum_mbchar(const char *c);
|
bool is_alnum_mbchar(const char *c);
|
||||||
#ifdef NANO_WIDE
|
#ifdef NANO_WIDE
|
||||||
@ -525,7 +526,6 @@ int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
|
|||||||
int regexp_bol_or_eol(const regex_t *preg, const char *string);
|
int regexp_bol_or_eol(const regex_t *preg, const char *string);
|
||||||
#endif
|
#endif
|
||||||
int num_of_digits(int n);
|
int num_of_digits(int n);
|
||||||
bool is_byte(unsigned int c);
|
|
||||||
bool parse_num(const char *str, ssize_t *val);
|
bool parse_num(const char *str, ssize_t *val);
|
||||||
void align(char **strp);
|
void align(char **strp);
|
||||||
void null_at(char **data, size_t index);
|
void null_at(char **data, size_t index);
|
||||||
|
29
src/utils.c
29
src/utils.c
@ -67,11 +67,6 @@ int num_of_digits(int n)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_byte(unsigned int c)
|
|
||||||
{
|
|
||||||
return (c == (unsigned char)c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read a ssize_t from str, and store it in *val (if val is not NULL).
|
/* Read a ssize_t from str, and store it in *val (if val is not NULL).
|
||||||
* On error, we return FALSE and don't change *val. Otherwise, we
|
* On error, we return FALSE and don't change *val. Otherwise, we
|
||||||
* return TRUE. */
|
* return TRUE. */
|
||||||
@ -131,26 +126,7 @@ void sunder(char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||||
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
|
#ifndef HAVE_GETLINE
|
||||||
/* This function is equivalent to getline(). It was adapted from
|
/* This function is equivalent to getline(). It was adapted from
|
||||||
* GNU mailutils' getline() function. */
|
* GNU mailutils' getline() function. */
|
||||||
@ -208,8 +184,7 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
|
|||||||
return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
|
return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* ENABLE_NANORC */
|
#endif /* !NANO_SMALL && ENABLE_NANORC */
|
||||||
#endif /* !NANO_SMALL */
|
|
||||||
|
|
||||||
/* If we are searching backwards, we will find the last match that
|
/* If we are searching backwards, we will find the last match that
|
||||||
* starts no later than start. Otherwise we find the first match
|
* starts no later than start. Otherwise we find the first match
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user