瀏覽代碼

libobs: Make astrstri a bit more C-compliant

I actually kind of hate how strstr returns a non-const even though it
takes a const parameter, but I can understand why they made it that way.
They really should have split it in to two functions though, one const
and one non-const or something.  But alas, ultimately for a C programmer
who knows what they're doing it isn't a huge deal.
jp9000 10 年之前
父節點
當前提交
9a91bbc16c
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      libobs/util/dstr.c
  2. 1 1
      libobs/util/dstr.h

+ 2 - 2
libobs/util/dstr.c

@@ -162,7 +162,7 @@ int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n)
 	return 0;
 }
 
-char *astrstri(char *str, const char *find)
+char *astrstri(const char *str, const char *find)
 {
 	size_t len;
 
@@ -173,7 +173,7 @@ char *astrstri(char *str, const char *find)
 
 	do {
 		if (astrcmpi_n(str, find, len) == 0)
-			return str;
+			return (char*)str;
 	} while (*str++);
 
 	return NULL;

+ 1 - 1
libobs/util/dstr.h

@@ -46,7 +46,7 @@ EXPORT int wstrcmp_n(const wchar_t *str1, const wchar_t *str2, size_t n);
 EXPORT int astrcmpi_n(const char *str1, const char *str2, size_t n);
 EXPORT int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n);
 
-EXPORT char *astrstri(char *str, const char *find);
+EXPORT char *astrstri(const char *str, const char *find);
 
 EXPORT char *strdepad(char *str);
 EXPORT wchar_t *wcsdepad(wchar_t *str);