From 8dd5afc926acb9829ebf56e9b78826a5242cd638 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 7 Jan 2013 12:24:55 -0800 Subject: string-list: allow case-insensitive string list Some string list needs to be searched case insensitively, and for that to work correctly, the string needs to be sorted case insensitively from the beginning. Allow a custom comparison function to be defined on a string list instance and use it throughout in place of strcmp(). Signed-off-by: Junio C Hamano --- string-list.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'string-list.h') diff --git a/string-list.h b/string-list.h index c50b0d0dea..446e79e425 100644 --- a/string-list.h +++ b/string-list.h @@ -5,10 +5,14 @@ struct string_list_item { char *string; void *util; }; + +typedef int (*compare_strings_fn)(const char *, const char *); + struct string_list { struct string_list_item *items; unsigned int nr, alloc; unsigned int strdup_strings:1; + compare_strings_fn cmp; /* NULL uses strcmp() */ }; #define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 } -- cgit v1.2.3