* src/lib/evil_string.c:
	* src/lib/evil_string.h:
	Add strcasestr() API.



SVN revision: 70350
devs/devilhorns/wayland_egl
Vincent Torri 11 years ago
parent c8412af437
commit f9f6d76e9a
  1. 7
      legacy/evil/ChangeLog
  2. 1
      legacy/evil/NEWS
  3. 34
      legacy/evil/src/lib/evil_string.c
  4. 18
      legacy/evil/src/lib/evil_string.h

@ -1,3 +1,10 @@
2012-04-20 Vincent Torri <doursse at users dot sf dot net>
* NEWS:
* src/lib/evil_string.c:
* src/lib/evil_string.h:
Add strcasestr() API.
2012-04-12 Vincent Torri <doursse at users dot sf dot net>
* NEWS:

@ -5,6 +5,7 @@ Evil NEWS - User visible changes.
** Add evil_path_is_absolute() API
** Add POSIX printf() family functions
** Add S_ISLNK macro
** Add strcasestr() API
** Do not declare and define localtime_r() if it's already defined
* Evil 1.0:

@ -92,3 +92,37 @@ int strcasecmp(const char *s1, const char *s2)
}
#endif /* _MSC_VER */
char *strcasestr(const char *haystack, const char *needle)
{
size_t length_needle;
size_t length_haystack;
size_t i;
if (!haystack || !needle)
return NULL;
length_needle = strlen(needle);
length_haystack = strlen(haystack) - length_needle + 1;
for (i = 0; i < length_haystack; i++)
{
size_t j;
for (j = 0; j < length_needle; j++)
{
unsigned char c1;
unsigned char c2;
c1 = haystack[i+j];
c2 = needle[j];
if (toupper(c1) != toupper(c2))
goto next;
}
return (char *) haystack + i;
next:
;
}
return NULL;
}

@ -125,6 +125,24 @@ EAPI int strcasecmp(const char *s1, const char *s2);
#endif /* _MSC_VER */
/**
* @brief Locatea substring into a string, ignoring case.
*
* @param haystack The string to search in.
* @param needle The substring to find.
* @return
*
* This function locates the string @p needle into the string @p haystack,
* ignoring the case of the characters. It returns apointer to the
* beginning of the substring, or NULL if the substring is not found.
* If @p haystack or @p needle are @c NULL, this function returns @c NULL.
*
* Conformity: Non applicable.
*
* Supported OS: Windows XP, Windows CE
*/
EAPI char *strcasestr(const char *haystack, const char *needle);
/**
* @}

Loading…
Cancel
Save