Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/intern/string.c11
-rw-r--r--source/blender/editors/space_logic/logic_ops.c23
2 files changed, 21 insertions, 13 deletions
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index 815295b8eac..906a3095f91 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -509,10 +509,15 @@ void BLI_timestr(double _time, char *str)
}
/* determine the length of a fixed-size string */
-size_t BLI_strnlen(const char *str, const size_t maxlen)
+size_t BLI_strnlen(const char *s, size_t maxlen)
{
- const char *end = memchr(str, '\0', maxlen);
- return end ? (size_t) (end - str) : maxlen;
+ size_t len;
+
+ for (len = 0; len < maxlen; len++, s++) {
+ if (!*s)
+ break;
+ }
+ return len;
}
void BLI_ascii_strtolower(char *str, const size_t len)
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index 51be5262a57..5f2ecbf1b2b 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -122,7 +122,7 @@ static Object *edit_object_property_get(bContext *C, wmOperator *op)
/* if ob_name is valid try to find the object with this name
* otherwise gets the active object */
- if (BLI_strnlen(ob_name, MAX_NAME) > 0)
+ if (*ob_name)
ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2);
else
ob = ED_object_active_context(C);
@@ -295,12 +295,13 @@ static int sensor_add_exec(bContext *C, wmOperator *op)
prop = RNA_struct_find_property(&sens_ptr, "type");
RNA_string_get(op->ptr, "name", name);
- if (BLI_strnlen(name, MAX_NAME) < 1) {
+ if (*name) {
+ BLI_strncpy(sens->name, name, sizeof(sens->name));
+ }
+ else {
RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name);
BLI_strncpy(sens->name, sens_name, sizeof(sens->name));
}
- else
- BLI_strncpy(sens->name, name, sizeof(sens->name));
make_unique_prop_names(C, sens->name);
ob->scaflag |= OB_SHOWSENS;
@@ -401,12 +402,13 @@ static int controller_add_exec(bContext *C, wmOperator *op)
prop = RNA_struct_find_property(&cont_ptr, "type");
RNA_string_get(op->ptr, "name", name);
- if (BLI_strnlen(name, MAX_NAME) < 1) {
+ if (*name) {
+ BLI_strncpy(cont->name, name, sizeof(cont->name));
+ }
+ else {
RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name);
BLI_strncpy(cont->name, cont_name, sizeof(cont->name));
}
- else
- BLI_strncpy(cont->name, name, sizeof(cont->name));
make_unique_prop_names(C, cont->name);
/* set the controller state mask from the current object state.
@@ -518,12 +520,13 @@ static int actuator_add_exec(bContext *C, wmOperator *op)
prop = RNA_struct_find_property(&act_ptr, "type");
RNA_string_get(op->ptr, "name", name);
- if (BLI_strnlen(name, MAX_NAME) < 1) {
+ if (*name) {
+ BLI_strncpy(act->name, name, sizeof(act->name));
+ }
+ else {
RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name);
BLI_strncpy(act->name, act_name, sizeof(act->name));
}
- else
- BLI_strncpy(act->name, name, sizeof(act->name));
make_unique_prop_names(C, act->name);
ob->scaflag |= OB_SHOWACT;