tests: replace binary GPG keyrings with ASCII-armored keys
[gitweb.git] / Documentation / technical / api-string-list.txt
index 32b35d91811aa775a13f2656966c3a49a5fea730..d51a6579c85f7417708f918cf9807447b1508e3c 100644 (file)
@@ -1,8 +1,9 @@
 string-list API
 ===============
 
-The string_list API offers a data structure and functions to handle sorted
-and unsorted string lists.
+The string_list API offers a data structure and functions to handle
+sorted and unsorted string lists.  A "sorted" list is one whose
+entries are sorted by string value in `strcmp()` order.
 
 The 'string_list' struct used to be called 'path_list', but was renamed
 because it is not specific to paths.
@@ -37,17 +38,17 @@ member (you need this if you add things later) and you should set the
   `unsorted_string_list_delete_item`.
 
 . Can remove items not matching a criterion from a sorted or unsorted
-  list using `filter_string_list`.
+  list using `filter_string_list`, or remove empty strings using
+  `string_list_remove_empty_items`.
 
 . Finally it should free the list using `string_list_clear`.
 
 Example:
 
 ----
-struct string_list list;
+struct string_list list = STRING_LIST_INIT_NODUP;
 int i;
 
-memset(&list, 0, sizeof(struct string_list));
 string_list_append(&list, "foo");
 string_list_append(&list, "bar");
 for (i = 0; i < list.nr; i++)
@@ -67,6 +68,11 @@ Functions
 
 * General ones (works with sorted and unsorted lists as well)
 
+`string_list_init`::
+
+       Initialize the members of the string_list, set `strdup_strings`
+       member according to the value of the second parameter.
+
 `filter_string_list`::
 
        Apply a function to each item in a list, retaining only the
@@ -75,13 +81,11 @@ Functions
        to be deleted.  Preserve the order of the items that are
        retained.
 
-`string_list_longest_prefix`::
+`string_list_remove_empty_items`::
 
-       Return the longest string within a string_list that is a
-       prefix (in the sense of prefixcmp()) of the specified string,
-       or NULL if no such prefix exists.  This function does not
-       require the string_list to be sorted (it does a linear
-       search).
+       Remove any empty strings from the list.  If free_util is true,
+       call free() on the util members of any items that have to be
+       deleted.  Preserve the order of the items that are retained.
 
 `print_string_list`::
 
@@ -144,7 +148,7 @@ write `string_list_insert(...)->util = ...;`.
 
 `sort_string_list`::
 
-       Make an unsorted list sorted.
+       Sort the list's entries by string value in `strcmp()` order.
 
 `unsorted_string_list_has_string`::
 
@@ -201,3 +205,5 @@ Represents the list itself.
   You should not tamper with it.
 . Setting the `strdup_strings` member to 1 will strdup() the strings
   before adding them, see above.
+. The `compare_strings_fn` member is used to specify a custom compare
+  function, otherwise `strcmp()` is used as the default function.