mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Added strrstr_skip_count() function.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
fc8a86766b
commit
91f3d8f4fd
@ -524,6 +524,12 @@ int str_verscmp (const char *s1, const char *s2);
|
||||
*/
|
||||
void str_msg_term_size (const char *text, int *lines, int *columns);
|
||||
|
||||
/**
|
||||
skip first <skip_count> needle's in haystack and returns pointer to
|
||||
<skip_count+1> needle (or NULL if not found).
|
||||
*/
|
||||
char *strrstr_skip_count (const char *haystack, const char *needle, size_t skip_count);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
static inline void
|
||||
|
@ -803,3 +803,26 @@ str_msg_term_size (const char *text, int *lines, int *columns)
|
||||
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
char *
|
||||
strrstr_skip_count (const char *haystack, const char *needle, size_t skip_count)
|
||||
{
|
||||
char *semi;
|
||||
ssize_t len;
|
||||
|
||||
len = strlen (haystack);
|
||||
|
||||
do
|
||||
{
|
||||
semi = g_strrstr_len (haystack, len, needle);
|
||||
if (semi == NULL)
|
||||
return NULL;
|
||||
len = semi - haystack - 1;
|
||||
}
|
||||
while (skip_count-- != 0);
|
||||
return semi;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user