From 9e2db2dad4ee38036a28452039656594f73b4421 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Mar 2013 18:52:09 +0000 Subject: revert own change: don't use memchr for strnlen, causes problems when the len is longer then the string data, instead use strnlen from freebsd. also simplify empty string checks in logic_ops.c --- source/blender/editors/space_logic/logic_ops.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source/blender/editors/space_logic') 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; -- cgit v1.2.3