mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-08-01 09:36:20 +00:00
fix #1761 by changing the implementation from recursive
... to an iterative approach Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
@@ -355,6 +355,7 @@ prof_occurrences(const char* const needle, const char* const haystack, int offse
|
|||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
gchar* haystack_curr = g_utf8_offset_to_pointer(haystack, offset);
|
gchar* haystack_curr = g_utf8_offset_to_pointer(haystack, offset);
|
||||||
if (g_str_has_prefix(haystack_curr, needle)) {
|
if (g_str_has_prefix(haystack_curr, needle)) {
|
||||||
if (whole_word) {
|
if (whole_word) {
|
||||||
@@ -379,9 +380,7 @@ prof_occurrences(const char* const needle, const char* const haystack, int offse
|
|||||||
}
|
}
|
||||||
|
|
||||||
offset++;
|
offset++;
|
||||||
if (g_strcmp0(g_utf8_offset_to_pointer(haystack, offset), "\0") != 0) {
|
} while (g_strcmp0(g_utf8_offset_to_pointer(haystack, offset), "\0") != 0);
|
||||||
*result = prof_occurrences(needle, haystack, offset, whole_word, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user