From 3bef9d40edc14d0fb68fa3a1db74cd7de31e5f32 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sun, 24 Feb 2008 07:51:25 +0000
Subject: [PATCH] Created strListIndexOf() to return the index of the passed
 string pointer.

---
 src/xpdev/str_list.c | 19 +++++++++++++++++--
 src/xpdev/str_list.h |  5 ++++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/xpdev/str_list.c b/src/xpdev/str_list.c
index 70a97c3c6d..d25f403cdf 100644
--- a/src/xpdev/str_list.c
+++ b/src/xpdev/str_list.c
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -43,7 +43,7 @@
 #include "genwrap.h"	/* stricmp */
 #include "str_list.h"
 
-str_list_t strListInit()
+str_list_t strListInit(void)
 {
 	str_list_t list;
 
@@ -63,6 +63,21 @@ size_t strListCount(const str_list_t list)
 	return(i);
 }
 
+int strListIndexOf(const str_list_t list, const char* str)
+{
+	size_t		i;
+
+	if(list==NULL)
+		return -1;
+
+	for(i=0; list[i]!=NULL; i++) {
+		if(list[i]==str)
+			return i;
+	}
+	
+	return -1;
+}
+
 static char* str_list_append(str_list_t* list, char* str, size_t index)
 {
 	str_list_t lp;
diff --git a/src/xpdev/str_list.h b/src/xpdev/str_list.h
index 7a57103814..d762e47989 100644
--- a/src/xpdev/str_list.h
+++ b/src/xpdev/str_list.h
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2008 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -101,6 +101,9 @@ size_t		strListMerge(str_list_t*, str_list_t append_list);
 /* Count the number of strings in the list and returns the count */
 size_t		strListCount(const str_list_t);
 
+/* Returns the index of the specified str (by ptr compare) or -1 if not found */
+int			strListIndexOf(const str_list_t, const char* str);
+
 /* Sort the strings in the string list */
 void		strListSortAlpha(str_list_t);
 void		strListSortAlphaReverse(str_list_t);
-- 
GitLab