in nstrcasestr(), mbstrcasestr(), revstrstr(), revstrcasestr(), and
mbrevstrcasestr(), return char* instead of const char* git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4126 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
84763ef473
commit
ae46b91b7e
|
@ -1,3 +1,8 @@
|
||||||
|
2007-07-06 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
|
* chars.c (nstrcasestr, mbstrcasestr, revstrstr, revstrcasestr,
|
||||||
|
mbrevstrcasestr): Return char* instead of const char*.
|
||||||
|
|
||||||
2007-07-02 David Lawrence Ramsey <pooka109@gmail.com>
|
2007-07-02 David Lawrence Ramsey <pooka109@gmail.com>
|
||||||
|
|
||||||
* chars.c (nstrcasestr, mbstrcasestr, revstrstr, revstrcasestr,
|
* chars.c (nstrcasestr, mbstrcasestr, revstrstr, revstrcasestr,
|
||||||
|
|
36
src/chars.c
36
src/chars.c
|
@ -602,12 +602,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
|
||||||
* Boston, MA 02110-1301, USA. */
|
* Boston, MA 02110-1301, USA. */
|
||||||
|
|
||||||
/* This function is equivalent to strcasestr(). */
|
/* This function is equivalent to strcasestr(). */
|
||||||
const char *nstrcasestr(const char *haystack, const char *needle)
|
char *nstrcasestr(const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
assert(haystack != NULL && needle != NULL);
|
assert(haystack != NULL && needle != NULL);
|
||||||
|
|
||||||
if (needle == '\0')
|
if (needle == '\0')
|
||||||
return haystack;
|
return (char *)haystack;
|
||||||
|
|
||||||
for (; *haystack != '\0'; haystack++) {
|
for (; *haystack != '\0'; haystack++) {
|
||||||
const char *r = haystack, *q = needle;
|
const char *r = haystack, *q = needle;
|
||||||
|
@ -616,7 +616,7 @@ const char *nstrcasestr(const char *haystack, const char *needle)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (*q == '\0')
|
if (*q == '\0')
|
||||||
return haystack;
|
return (char *)haystack;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -624,7 +624,7 @@ const char *nstrcasestr(const char *haystack, const char *needle)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This function is equivalent to strcasestr() for multibyte strings. */
|
/* This function is equivalent to strcasestr() for multibyte strings. */
|
||||||
const char *mbstrcasestr(const char *haystack, const char *needle)
|
char *mbstrcasestr(const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
if (use_utf8) {
|
if (use_utf8) {
|
||||||
|
@ -635,7 +635,7 @@ const char *mbstrcasestr(const char *haystack, const char *needle)
|
||||||
assert(haystack != NULL && needle != NULL);
|
assert(haystack != NULL && needle != NULL);
|
||||||
|
|
||||||
if (needle == '\0')
|
if (needle == '\0')
|
||||||
return haystack;
|
return (char *)haystack;
|
||||||
|
|
||||||
r_mb = charalloc(MB_CUR_MAX);
|
r_mb = charalloc(MB_CUR_MAX);
|
||||||
q_mb = charalloc(MB_CUR_MAX);
|
q_mb = charalloc(MB_CUR_MAX);
|
||||||
|
@ -682,7 +682,7 @@ const char *mbstrcasestr(const char *haystack, const char *needle)
|
||||||
free(r_mb);
|
free(r_mb);
|
||||||
free(q_mb);
|
free(q_mb);
|
||||||
|
|
||||||
return found_needle ? haystack : NULL;
|
return found_needle ? (char *)haystack : NULL;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
return strcasestr(haystack, needle);
|
return strcasestr(haystack, needle);
|
||||||
|
@ -691,13 +691,13 @@ const char *mbstrcasestr(const char *haystack, const char *needle)
|
||||||
#if !defined(NANO_TINY) || !defined(DISABLE_TABCOMP)
|
#if !defined(NANO_TINY) || !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
|
char *revstrstr(const char *haystack, const char *needle, const char
|
||||||
char *rev_start)
|
*rev_start)
|
||||||
{
|
{
|
||||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||||
|
|
||||||
if (needle == '\0')
|
if (needle == '\0')
|
||||||
return rev_start;
|
return (char *)rev_start;
|
||||||
|
|
||||||
for (; rev_start >= haystack; rev_start--) {
|
for (; rev_start >= haystack; rev_start--) {
|
||||||
const char *r = rev_start, *q = needle;
|
const char *r = rev_start, *q = needle;
|
||||||
|
@ -706,7 +706,7 @@ const char *revstrstr(const char *haystack, const char *needle, const
|
||||||
;
|
;
|
||||||
|
|
||||||
if (*q == '\0')
|
if (*q == '\0')
|
||||||
return rev_start;
|
return (char *)rev_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -716,13 +716,13 @@ const char *revstrstr(const char *haystack, const char *needle, const
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* 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,
|
char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||||
const char *rev_start)
|
*rev_start)
|
||||||
{
|
{
|
||||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||||
|
|
||||||
if (needle == '\0')
|
if (needle == '\0')
|
||||||
return rev_start;
|
return (char *)rev_start;
|
||||||
|
|
||||||
for (; rev_start >= haystack; rev_start--) {
|
for (; rev_start >= haystack; rev_start--) {
|
||||||
const char *r = rev_start, *q = needle;
|
const char *r = rev_start, *q = needle;
|
||||||
|
@ -731,7 +731,7 @@ const char *revstrcasestr(const char *haystack, const char *needle,
|
||||||
;
|
;
|
||||||
|
|
||||||
if (*q == '\0')
|
if (*q == '\0')
|
||||||
return rev_start;
|
return (char *)rev_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -740,8 +740,8 @@ const char *revstrcasestr(const char *haystack, const char *needle,
|
||||||
/* This function is equivalent to strcasestr() for multibyte strings,
|
/* This function is equivalent to strcasestr() for multibyte strings,
|
||||||
* except in that it scans the string in reverse, starting at
|
* except in that it scans the string in reverse, starting at
|
||||||
* rev_start. */
|
* rev_start. */
|
||||||
const char *mbrevstrcasestr(const char *haystack, const char *needle,
|
char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||||
const char *rev_start)
|
char *rev_start)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
if (use_utf8) {
|
if (use_utf8) {
|
||||||
|
@ -752,7 +752,7 @@ const char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||||
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
assert(haystack != NULL && needle != NULL && rev_start != NULL);
|
||||||
|
|
||||||
if (needle == '\0')
|
if (needle == '\0')
|
||||||
return rev_start;
|
return (char *)rev_start;
|
||||||
|
|
||||||
r_mb = charalloc(MB_CUR_MAX);
|
r_mb = charalloc(MB_CUR_MAX);
|
||||||
q_mb = charalloc(MB_CUR_MAX);
|
q_mb = charalloc(MB_CUR_MAX);
|
||||||
|
@ -803,7 +803,7 @@ const char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||||
free(r_mb);
|
free(r_mb);
|
||||||
free(q_mb);
|
free(q_mb);
|
||||||
|
|
||||||
return found_needle ? rev_start : NULL;
|
return found_needle ? (char *)rev_start : NULL;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
return revstrcasestr(haystack, needle, rev_start);
|
return revstrcasestr(haystack, needle, rev_start);
|
||||||
|
|
16
src/proto.h
16
src/proto.h
|
@ -203,18 +203,18 @@ int nstrncasecmp(const char *s1, const char *s2, size_t n);
|
||||||
#endif
|
#endif
|
||||||
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
|
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
|
||||||
#ifndef HAVE_STRCASESTR
|
#ifndef HAVE_STRCASESTR
|
||||||
const char *nstrcasestr(const char *haystack, const char *needle);
|
char *nstrcasestr(const char *haystack, const char *needle);
|
||||||
#endif
|
#endif
|
||||||
const char *mbstrcasestr(const char *haystack, const char *needle);
|
char *mbstrcasestr(const char *haystack, const char *needle);
|
||||||
#if !defined(NANO_TINY) || !defined(DISABLE_TABCOMP)
|
#if !defined(NANO_TINY) || !defined(DISABLE_TABCOMP)
|
||||||
const char *revstrstr(const char *haystack, const char *needle, const
|
char *revstrstr(const char *haystack, const char *needle, const char
|
||||||
char *rev_start);
|
*rev_start);
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
const char *revstrcasestr(const char *haystack, const char *needle,
|
char *revstrcasestr(const char *haystack, const char *needle, const char
|
||||||
const char *rev_start);
|
*rev_start);
|
||||||
const char *mbrevstrcasestr(const char *haystack, const char *needle,
|
char *mbrevstrcasestr(const char *haystack, const char *needle, const
|
||||||
const char *rev_start);
|
char *rev_start);
|
||||||
#endif
|
#endif
|
||||||
size_t mbstrlen(const char *s);
|
size_t mbstrlen(const char *s);
|
||||||
#ifndef HAVE_STRNLEN
|
#ifndef HAVE_STRNLEN
|
||||||
|
|
Loading…
Reference in New Issue