[Bf-blender-cvs] [ea1f1fe] master: BLI_string, dont pass unicode to ascii BLI_str_partition functions

Campbell Barton noreply at git.blender.org
Mon Jul 7 22:42:46 CEST 2014


Commit: ea1f1fe0c20ab41fb9c9d332e7317d04a3bf0baf
Author: Campbell Barton
Date:   Tue Jul 8 06:06:34 2014 +1000
https://developer.blender.org/rBea1f1fe0c20ab41fb9c9d332e7317d04a3bf0baf

BLI_string, dont pass unicode to ascii BLI_str_partition functions

===================================================================

M	CMakeLists.txt
M	source/blender/blenlib/BLI_string.h
M	source/blender/blenlib/intern/string.c
M	tests/gtests/blenlib/BLI_string_test.cc

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3d3a8a4..856ce8e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1894,7 +1894,7 @@ elseif(APPLE)
 		else() # vanilla gcc or clang_omp support OpenMP
 			message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc
 			string(SUBSTRING "${CMAKE_C_COMPILER}" 0 5 CLANG_OMP)
-			message(STATUS "Using clang-omp from darwin libs "${CLANG_OMP})
+			message(STATUS "Using clang-omp from darwin libs " ${CLANG_OMP})
 			if(CMAKE_C_COMPILER_ID MATCHES "Clang") # clang-omp in darwin libs
 				set(OPENMP_FOUND ON)
 				set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "C compiler flags for OpenMP parallization" FORCE)
diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h
index 27bec22..786e5e9 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -79,9 +79,9 @@ int BLI_str_rstrip_float_zero(char *str, const char pad) ATTR_NONNULL();
 int BLI_str_index_in_array_n(const char *__restrict str, const char **__restrict str_array, const int str_array_len) ATTR_NONNULL();
 int BLI_str_index_in_array(const char *__restrict str, const char **__restrict str_array) ATTR_NONNULL();
 
-size_t BLI_str_partition(const char *str, const unsigned int delim[], char **sep, char **suf) ATTR_NONNULL();
-size_t BLI_str_rpartition(const char *str, const unsigned int delim[], char **sep, char **suf) ATTR_NONNULL();
-size_t BLI_str_partition_ex(const char *str, const unsigned int delim[], char **sep, char **suf, const bool from_right) ATTR_NONNULL();
+size_t BLI_str_partition(const char *str, const char delim[], char **sep, char **suf) ATTR_NONNULL();
+size_t BLI_str_rpartition(const char *str, const char delim[], char **sep, char **suf) ATTR_NONNULL();
+size_t BLI_str_partition_ex(const char *str, const char delim[], char **sep, char **suf, const bool from_right) ATTR_NONNULL();
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 87233d2..f396abb 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -690,7 +690,7 @@ int BLI_str_index_in_array(const char *str, const char **str_array)
  * \param suf Return value, set to next char after the first delimiter found (or NULL if none found).
  * \return The length of the prefix (i.e. *sep - str).
  */
-size_t BLI_str_partition(const char *str, const unsigned int delim[], char **sep, char **suf)
+size_t BLI_str_partition(const char *str, const char delim[], char **sep, char **suf)
 {
 	return BLI_str_partition_ex(str, delim, sep, suf, false);
 }
@@ -704,7 +704,7 @@ size_t BLI_str_partition(const char *str, const unsigned int delim[], char **sep
  * \param suf Return value, set to next char after the first delimiter found (or NULL if none found).
  * \return The length of the prefix (i.e. *sep - str).
  */
-size_t BLI_str_rpartition(const char *str, const unsigned int delim[], char **sep, char **suf)
+size_t BLI_str_rpartition(const char *str, const char delim[], char **sep, char **suf)
 {
 	return BLI_str_partition_ex(str, delim, sep, suf, true);
 }
@@ -719,15 +719,15 @@ size_t BLI_str_rpartition(const char *str, const unsigned int delim[], char **se
  * \param from_right If %true, search from the right of \a str, else, search from its left.
  * \return The length of the prefix (i.e. *sep - str).
  */
-size_t BLI_str_partition_ex(const char *str, const unsigned int delim[], char **sep, char **suf, const bool from_right)
+size_t BLI_str_partition_ex(const char *str, const char delim[], char **sep, char **suf, const bool from_right)
 {
-	const unsigned int *d;
+	const char *d;
 	char *(*func)(const char *str, int c) = from_right ? strrchr : strchr;
 
 	*sep = *suf = NULL;
 
 	for (d = delim; *d != '\0'; ++d) {
-		char *tmp = func(str, (int)*d);
+		char *tmp = func(str, *d);
 
 		if (tmp && (from_right ? (*sep < tmp) : (!*sep || *sep > tmp))) {
 			*sep = tmp;
diff --git a/tests/gtests/blenlib/BLI_string_test.cc b/tests/gtests/blenlib/BLI_string_test.cc
index 5a828f3..13091d9 100644
--- a/tests/gtests/blenlib/BLI_string_test.cc
+++ b/tests/gtests/blenlib/BLI_string_test.cc
@@ -35,7 +35,7 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n)
 /* BLI_str_partition */
 TEST(string, StrPartition)
 {
-	const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'};
+	const char delim[] = {'-', '.', '_', '~', '\\', '\0'};
 	char *sep, *suf;
 	size_t pre_ln;
 
@@ -94,7 +94,7 @@ TEST(string, StrPartition)
 /* BLI_str_rpartition */
 TEST(string, StrRPartition)
 {
-	const unsigned int delim[] = {'-', '.', '_', 0x00F1 /* n tilde */, 0x262F /* ying-yang */, '\0'};
+	const char delim[] = {'-', '.', '_', '~', '\\', '\0'};
 	char *sep, *suf;
 	size_t pre_ln;




More information about the Bf-blender-cvs mailing list