41 lines
1.4 KiB
Diff
41 lines
1.4 KiB
Diff
diff -Naur a/lib/widget/input_complete.c b/lib/widget/input_complete.c
|
|
--- a/lib/widget/input_complete.c 2024-08-08 13:49:18.000000000 +0600
|
|
+++ b/lib/widget/input_complete.c 2024-08-25 08:44:41.545041816 +0600
|
|
@@ -685,6 +685,27 @@
|
|
return strcmp (*(char *const *) a, *(char *const *) b);
|
|
}
|
|
|
|
+/* Replace by g_ptr_array_insert when we depend on glib >= 2.40. */
|
|
+static
|
|
+void array_insert(GPtrArray *array, gpointer element, size_t pos)
|
|
+{
|
|
+ size_t original_array_len = array->len;
|
|
+
|
|
+ /* Allocate an unused element at the end of the array. */
|
|
+ g_ptr_array_add(array, NULL);
|
|
+
|
|
+ /* If we are not inserting at the end, move the elements by one. */
|
|
+ if (pos < original_array_len) {
|
|
+ memmove(&(array->pdata[pos + 1]),
|
|
+ &(array->pdata[pos]),
|
|
+ (original_array_len - pos) * sizeof(gpointer));
|
|
+ }
|
|
+
|
|
+ /* Insert the value and bump the array len */
|
|
+ array->pdata[pos] = element;
|
|
+}
|
|
+
|
|
+
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
/** Returns an array of char * matches with the longest common denominator
|
|
in the 1st entry. Then a NULL terminated list of different possible
|
|
@@ -763,7 +784,7 @@
|
|
}
|
|
|
|
string = g_ptr_array_index (match_list, 0);
|
|
- g_ptr_array_insert (match_list, 0, g_strndup (string, low));
|
|
+ array_insert (match_list, g_strndup (string, low), 0);
|
|
}
|
|
|
|
return match_list;
|