Commit: ac619aaf38c3058e1b8cd0e665f011a0e1f692c3
Author: Campbell Barton
Date: Fri Jan 9 23:38:23 2015 +1100
Branches: master
https://developer.blender.org/rBac619aaf38c3058e1b8cd0e665f011a0e1f692c3
BLI_string: BLI_str_ends_with -> BLI_str_endswith
Loosely following Python str convention.
===================================================================
M source/blender/blenlib/BLI_string.h
M source/blender/blenlib/intern/string.c
M source/blender/editors/animation/keyframes_general.c
===================================================================
diff --git a/source/blender/blenlib/BLI_string.h
b/source/blender/blenlib/BLI_string.h
index 4d2007f..54eb764 100644
--- a/source/blender/blenlib/BLI_string.h
+++ b/source/blender/blenlib/BLI_string.h
@@ -85,8 +85,8 @@ 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();
-bool BLI_str_ends_with(const char *str,const char *end) ATTR_NONNULL();
-bool BLI_strn_ends_with(const char *str,const char *end, int length)
ATTR_NONNULL();
+bool BLI_str_endswith(const char *__restrict str, const char *__restrict end)
ATTR_NONNULL();
+bool BLI_strn_endswith(const char *__restrict str, const char *__restrict end,
int length) 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();
diff --git a/source/blender/blenlib/intern/string.c
b/source/blender/blenlib/intern/string.c
index 365e555..cc049fc 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -773,12 +773,12 @@ int BLI_str_index_in_array(const char *__restrict str,
const char **__restrict s
return -1;
}
-bool BLI_strn_ends_with(const char *str,const char *end, int slength)
+bool BLI_strn_endswith(const char *__restrict str,const char *__restrict end,
int slength)
{
- size_t elength = strlen(end);
+ int elength = strlen(end);
if (elength < slength) {
- const char *iter = str + slength - elength;
+ const char *iter = &str[slength - elength];
while (*iter) {
if (*iter++ != *end++) {
return false;
@@ -796,10 +796,10 @@ bool BLI_strn_ends_with(const char *str,const char *end,
int slength)
* \param end The string we look for at the end.
* \return If str ends with end.
*/
-bool BLI_str_ends_with(const char *str,const char *end)
+bool BLI_str_endswith(const char *__restrict str,const char *end)
{
- size_t slength = strlen(str);
- return BLI_strn_ends_with(str, end, slength);
+ int slength = strlen(str);
+ return BLI_strn_endswith(str, end, slength);
}
/**
diff --git a/source/blender/editors/animation/keyframes_general.c
b/source/blender/editors/animation/keyframes_general.c
index ee212d6..64332f6 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -743,17 +743,18 @@ static tAnimCopybufItem *pastebuf_match_index_only(FCurve
*fcu, const short from
/* ................ */
-static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt) {
+static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt)
+{
if (aci->is_bone) {
int slength = strlen(aci->rna_path);
bool flip = false;
- if (BLI_strn_ends_with(aci->rna_path, "location", slength) &&
aci->array_index == 0)
+ if (BLI_strn_endswith(aci->rna_path, "location", slength) &&
aci->array_index == 0)
flip = true;
- else if (BLI_strn_ends_with(aci->rna_path,
"rotation_quaternion", slength) && ELEM(aci->array_index, 2, 3))
+ else if (BLI_strn_endswith(aci->rna_path,
"rotation_quaternion", slength) && ELEM(aci->array_index, 2, 3))
flip = true;
- else if (BLI_strn_ends_with(aci->rna_path, "rotation_euler",
slength) && ELEM(aci->array_index, 1, 2))
+ else if (BLI_strn_endswith(aci->rna_path, "rotation_euler",
slength) && ELEM(aci->array_index, 1, 2))
flip = true;
- else if (BLI_strn_ends_with(aci->rna_path,
"rotation_axis_angle", slength) && ELEM(aci->array_index, 2, 3))
+ else if (BLI_strn_endswith(aci->rna_path,
"rotation_axis_angle", slength) && ELEM(aci->array_index, 2, 3))
flip = true;
if (flip) {
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs