forked from enlightenment/efl
evil: add strsep function.
Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
This commit is contained in:
parent
d9e1b7d67c
commit
2070ca4205
|
@ -6,6 +6,10 @@
|
|||
|
||||
* Edje: Move cursor to correct position when selection handlers are pressed.
|
||||
|
||||
2013-06-20 Christophe Sadoine
|
||||
|
||||
* Evil: Added strsep function.
|
||||
|
||||
2013-06-19 Cedric Bail
|
||||
|
||||
* Evas: optimized path for when map use the same color for all corner.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -10,6 +10,7 @@ Additions:
|
|||
* Evil:
|
||||
- Add mkdtemp.
|
||||
- Add evil_rename() a wrapper for rename().
|
||||
- Add strsep().
|
||||
* eina:
|
||||
- Add DOCTYPE children parsing in eina_simple_xml
|
||||
- Add eina_barrier thread API
|
||||
|
|
|
@ -127,3 +127,48 @@ char *strcasestr(const char *haystack, const char *needle)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
strsep (char **stringp, const char *delim)
|
||||
{
|
||||
char *begin, *end;
|
||||
|
||||
begin = *stringp;
|
||||
if (begin == NULL)
|
||||
return NULL;
|
||||
|
||||
/* A frequent case is when the delimiter string contains only one
|
||||
character. Here we don't need to call the expensive `strpbrk'
|
||||
function and instead work using `strchr'. */
|
||||
if (delim[0] == '\0' || delim[1] == '\0')
|
||||
{
|
||||
char ch = delim[0];
|
||||
|
||||
if (ch == '\0')
|
||||
end = NULL;
|
||||
else
|
||||
{
|
||||
if (*begin == ch)
|
||||
end = begin;
|
||||
else if (*begin == '\0')
|
||||
end = NULL;
|
||||
else
|
||||
end = strchr (begin + 1, ch);
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Find the end of the token. */
|
||||
end = strpbrk (begin, delim);
|
||||
|
||||
if (end)
|
||||
{
|
||||
/* Terminate the token and set *STRINGP past NUL character. */
|
||||
*end++ = '\0';
|
||||
*stringp = end;
|
||||
}
|
||||
else
|
||||
/* No more delimiters; this is the last token. */
|
||||
*stringp = NULL;
|
||||
|
||||
return begin;
|
||||
}
|
||||
|
|
|
@ -144,10 +144,30 @@ EAPI int strcasecmp(const char *s1, const char *s2);
|
|||
*/
|
||||
EAPI char *strcasestr(const char *haystack, const char *needle);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
* @brief Implements the strsep function which is used to separate strings.
|
||||
*
|
||||
* @param stringp The pointer to the string to search in.
|
||||
* @param delim The delimiter that contains characters used to find the next token.
|
||||
* @return a pointer to the next token or NULL;
|
||||
*
|
||||
* The strsep() function locates, in the string referenced by *stringp, the
|
||||
* first occurrence of any character in the string delim (or the terminating
|
||||
* `\0' character) and replaces it with a `\0'. The location of the next
|
||||
* character after the delimiter character (or NULL, if the end of the
|
||||
* string was reached) is stored in *stringp. The original value of
|
||||
* stringp is returned.
|
||||
*
|
||||
* An ``empty'' field (i.e., a character in the string delim occurs as the
|
||||
* first character of *stringp) can be detected by comparing the location
|
||||
* referenced by the returned pointer to `\0'.
|
||||
|
||||
* If *stringp is initially NULL, strsep() returns NULL.
|
||||
*
|
||||
* This function is from LibGW32C.
|
||||
* @since 1.8
|
||||
*
|
||||
*/
|
||||
EAPI char *strsep(char **stringp, const char *delim);
|
||||
|
||||
#endif /* __EVIL_STRING_H__ */
|
||||
|
|
Loading…
Reference in New Issue