tweaks: rename two variables, because this 'rev_start' is irksome
And one-letter variables I cannot "see" -- they are too small.
Этот коммит содержится в:
родитель
b06407fbd7
Коммит
329021e24a
43
src/chars.c
43
src/chars.c
@ -647,51 +647,50 @@ char *mbstrpbrk(const char *s, const char *accept)
|
|||||||
return (char *) strpbrk(s, accept);
|
return (char *) strpbrk(s, accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is equivalent to strpbrk(), except in that it scans the
|
/* Locate the first occurrence in the string that starts at head
|
||||||
* string in reverse, starting at rev_start. */
|
* of any of the characters in the string accept, starting from
|
||||||
char *revstrpbrk(const char *s, const char *accept, const char
|
* the given index and searching backwards. */
|
||||||
*rev_start)
|
char *revstrpbrk(const char *head, const char *accept, const char *index)
|
||||||
{
|
{
|
||||||
if (*rev_start == '\0') {
|
if (*index == '\0') {
|
||||||
if (rev_start == s)
|
if (index == head)
|
||||||
return NULL;
|
return NULL;
|
||||||
rev_start--;
|
index--;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; rev_start >= s; rev_start--) {
|
while (index >= head) {
|
||||||
if (strchr(accept, *rev_start) != NULL)
|
if (strchr(accept, *index) != NULL)
|
||||||
return (char *)rev_start;
|
return (char *)index;
|
||||||
|
index--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is equivalent to strpbrk() for multibyte strings,
|
/* The same as the preceding function but then for multibyte strings. */
|
||||||
* except in that it scans the string in reverse, starting at rev_start. */
|
char *mbrevstrpbrk(const char *head, const char *accept, const char *index)
|
||||||
char *mbrevstrpbrk(const char *s, const char *accept, const char
|
|
||||||
*rev_start)
|
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
if (use_utf8) {
|
if (use_utf8) {
|
||||||
if (*rev_start == '\0') {
|
if (*index == '\0') {
|
||||||
if (rev_start == s)
|
if (index == head)
|
||||||
return NULL;
|
return NULL;
|
||||||
rev_start = s + move_mbleft(s, rev_start - s);
|
index = head + move_mbleft(head, index - head);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
if (mbstrchr(accept, rev_start) != NULL)
|
if (mbstrchr(accept, index) != NULL)
|
||||||
return (char *)rev_start;
|
return (char *)index;
|
||||||
|
|
||||||
/* If we've reached the head of the string, we found nothing. */
|
/* If we've reached the head of the string, we found nothing. */
|
||||||
if (rev_start == s)
|
if (index == head)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rev_start = s + move_mbleft(s, rev_start - s);
|
index = head + move_mbleft(head, index - head);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
return revstrpbrk(s, accept, rev_start);
|
return revstrpbrk(head, accept, index);
|
||||||
}
|
}
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
|
@ -216,10 +216,8 @@ char *mbstrchr(const char *s, const char *c);
|
|||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
char *mbstrpbrk(const char *s, const char *accept);
|
char *mbstrpbrk(const char *s, const char *accept);
|
||||||
char *revstrpbrk(const char *s, const char *accept, const char
|
char *revstrpbrk(const char *head, const char *accept, const char *index);
|
||||||
*rev_start);
|
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
|
||||||
char *mbrevstrpbrk(const char *s, const char *accept, const char
|
|
||||||
*rev_start);
|
|
||||||
#endif
|
#endif
|
||||||
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
|
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
|
||||||
bool has_blank_mbchars(const char *s);
|
bool has_blank_mbchars(const char *s);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user