added "str_len" param in find_str_in_array

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-10-10 14:47:56 +08:00
parent 15b86eaf3b
commit 460dc1c5ec

View File

@ -2466,10 +2466,21 @@ namespace hgl
} }
template<typename T> template<typename T>
const int find_str_in_array(int count,const T **str_array,const T *str) const int find_str_in_array(int count,const T **str_array,const T *str,int str_len=0)
{ {
if(str_len<=0)
str_len=hgl::strlen(str);
int len;
for(int i=0;i<count;i++) for(int i=0;i<count;i++)
if(stricmp(str_array[i],str,strlen(str_array[i]))==0)return(i); {
len=strlen(str_array[i]);
if(len!=str_len)continue;
if(stricmp(str_array[i],str,len)==0)return(i);
}
return(-1); return(-1);
} }