elextr approved this pull request.
@kugel- sorry I give up reviewing this, can't figure out the G* macro shit. Will approve so someone else can review it.
- */
+static gchar *utils_strv_find_common_prefix(gchar **strv, size_t num) +{ + gchar *prefix, **ptr; + + if (!NZV(strv)) + return NULL; + + if (num == 0) + num = g_strv_length(strv); + + prefix = g_strdup(strv[0]); + + for (gint i = 0; prefix[i]; i++) + { + foreach_strv(ptr, &strv[1])
why is this here?
@@ -2031,6 +2031,199 @@ gchar **utils_strv_join(gchar **first, gchar **second)
return strv; }
+/* * Returns the common prefix in a list of strings. + * + * The size of the list may be given explicitely automatically determined if passed a GStrv.
what you actually mean is a null terminated pointer array, GStrv is just a char**.
if (prefix[i] == '\0')
+ break; + } + return prefix; +} + +/* * Returns the common prefix in a list of strings. + * + * The size of the list may be given explicitely automatically determined if passed a GStrv. + * + * @param strv The list of strings to process. + * @param num The number of strings contained in @a strv. Can be 0 if @a strv is a @c GStrv + * + * @return The common prefix that is part of all strings. + */ +gchar *utils_strv_find_lcs(gchar **strv, size_t num)
whats the difference between this and the previous function