From fca515838e70f8bec7028b840bb921a1be9fabbb Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 26 Jan 2015 16:03:11 +0100 Subject: Cleanup: strcmp/strncmp -> STREQ/STREQLEN (in boolean usage). Makes usage of those funcs much more clear, we even had mixed '!strcmp(foo, bar)' and 'strcmp(foo, bar) == 0' in several places... --- source/blender/makesrna/intern/makesrna.c | 64 +++++++++++------------ source/blender/makesrna/intern/rna_access.c | 22 ++++---- source/blender/makesrna/intern/rna_actuator.c | 4 +- source/blender/makesrna/intern/rna_animation.c | 4 +- source/blender/makesrna/intern/rna_define.c | 26 ++++----- source/blender/makesrna/intern/rna_modifier.c | 2 +- source/blender/makesrna/intern/rna_object.c | 4 +- source/blender/makesrna/intern/rna_object_force.c | 2 +- source/blender/makesrna/intern/rna_render.c | 2 +- source/blender/makesrna/intern/rna_rna.c | 8 +-- source/blender/makesrna/intern/rna_scene.c | 6 +-- source/blender/makesrna/intern/rna_sensor.c | 4 +- source/blender/makesrna/intern/rna_space.c | 2 +- source/blender/makesrna/intern/rna_ui.c | 4 +- source/blender/makesrna/intern/rna_ui_api.c | 6 +-- source/blender/makesrna/intern/rna_wm.c | 2 +- 16 files changed, 81 insertions(+), 81 deletions(-) (limited to 'source/blender/makesrna/intern') diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 92a509d4d56..ec285bc448c 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -221,11 +221,11 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[]) static const char *rna_safe_id(const char *id) { - if (strcmp(id, "default") == 0) + if (STREQ(id, "default")) return "default_value"; - else if (strcmp(id, "operator") == 0) + else if (STREQ(id, "operator")) return "operator_value"; - else if (strcmp(id, "new") == 0) + else if (STREQ(id, "new")) return "create"; return id; @@ -246,11 +246,11 @@ static int cmp_property(const void *a, const void *b) const PropertyRNA *propa = *(const PropertyRNA **)a; const PropertyRNA *propb = *(const PropertyRNA **)b; - if (strcmp(propa->identifier, "rna_type") == 0) return -1; - else if (strcmp(propb->identifier, "rna_type") == 0) return 1; + if (STREQ(propa->identifier, "rna_type")) return -1; + else if (STREQ(propb->identifier, "rna_type")) return 1; - if (strcmp(propa->identifier, "name") == 0) return -1; - else if (strcmp(propb->identifier, "name") == 0) return 1; + if (STREQ(propa->identifier, "name")) return -1; + else if (STREQ(propb->identifier, "name")) return 1; return strcmp(propa->name, propb->name); } @@ -372,7 +372,7 @@ static StructRNA *rna_find_struct(const char *identifier) StructDefRNA *ds; for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) - if (strcmp(ds->srna->identifier, identifier) == 0) + if (STREQ(ds->srna->identifier, identifier)) return ds->srna; return NULL; @@ -383,7 +383,7 @@ static const char *rna_find_type(const char *type) StructDefRNA *ds; for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) - if (ds->dnaname && strcmp(ds->dnaname, type) == 0) + if (ds->dnaname && STREQ(ds->dnaname, type)) return ds->srna->identifier; return NULL; @@ -394,7 +394,7 @@ static const char *rna_find_dna_type(const char *type) StructDefRNA *ds; for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) - if (strcmp(ds->srna->identifier, type) == 0) + if (STREQ(ds->srna->identifier, type)) return ds->dnaname; return NULL; @@ -621,9 +621,9 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, "static PointerRNA %s(CollectionPropertyIterator *iter)\n", func); fprintf(f, "{\n"); if (manualfunc) { - if (strcmp(manualfunc, "rna_iterator_listbase_get") == 0 || - strcmp(manualfunc, "rna_iterator_array_get") == 0 || - strcmp(manualfunc, "rna_iterator_array_dereference_get") == 0) + if (STREQ(manualfunc, "rna_iterator_listbase_get") || + STREQ(manualfunc, "rna_iterator_array_get") || + STREQ(manualfunc, "rna_iterator_array_dereference_get")) { fprintf(f, " return rna_pointer_inherit_refine(&iter->parent, &RNA_%s, %s(iter));\n", (cprop->item_type) ? (const char *)cprop->item_type : "UnknownType", manualfunc); @@ -1168,8 +1168,8 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property return NULL; /* only supported in case of standard next functions */ - if (strcmp(nextfunc, "rna_iterator_array_next") == 0) {} - else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) {} + if (STREQ(nextfunc, "rna_iterator_array_next")) {} + else if (STREQ(nextfunc, "rna_iterator_listbase_next")) {} else return NULL; } @@ -1190,7 +1190,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property fprintf(f, " %s_%s_begin(&iter, ptr);\n\n", srna->identifier, rna_safe_id(prop->identifier)); fprintf(f, " if (iter.valid) {\n"); - if (strcmp(nextfunc, "rna_iterator_array_next") == 0) { + if (STREQ(nextfunc, "rna_iterator_array_next")) { fprintf(f, " ArrayIterator *internal = &iter.internal.array;\n"); fprintf(f, " if (index < 0 || index >= internal->length) {\n"); fprintf(f, "#ifdef __GNUC__\n"); @@ -1210,7 +1210,7 @@ static char *rna_def_property_lookup_int_func(FILE *f, StructRNA *srna, Property fprintf(f, " found = 1;\n"); fprintf(f, " }\n"); } - else if (strcmp(nextfunc, "rna_iterator_listbase_next") == 0) { + else if (STREQ(nextfunc, "rna_iterator_listbase_next")) { fprintf(f, " ListBaseIterator *internal = &iter.internal.listbase;\n"); fprintf(f, " if (internal->skip) {\n"); fprintf(f, " while (index-- > 0 && iter.valid) {\n"); @@ -1396,23 +1396,23 @@ static void rna_set_raw_property(PropertyDefRNA *dp, PropertyRNA *prop) if (!dp->dnatype || !dp->dnaname || !dp->dnastructname) return; - if (strcmp(dp->dnatype, "char") == 0) { + if (STREQ(dp->dnatype, "char")) { prop->rawtype = PROP_RAW_CHAR; prop->flag |= PROP_RAW_ACCESS; } - else if (strcmp(dp->dnatype, "short") == 0) { + else if (STREQ(dp->dnatype, "short")) { prop->rawtype = PROP_RAW_SHORT; prop->flag |= PROP_RAW_ACCESS; } - else if (strcmp(dp->dnatype, "int") == 0) { + else if (STREQ(dp->dnatype, "int")) { prop->rawtype = PROP_RAW_INT; prop->flag |= PROP_RAW_ACCESS; } - else if (strcmp(dp->dnatype, "float") == 0) { + else if (STREQ(dp->dnatype, "float")) { prop->rawtype = PROP_RAW_FLOAT; prop->flag |= PROP_RAW_ACCESS; } - else if (strcmp(dp->dnatype, "double") == 0) { + else if (STREQ(dp->dnatype, "double")) { prop->rawtype = PROP_RAW_DOUBLE; prop->flag |= PROP_RAW_ACCESS; } @@ -1525,7 +1525,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) const char *nextfunc = (const char *)cprop->next; const char *item_type = (const char *)cprop->item_type; - if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) { + if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) { /* pass */ } else if (dp->dnalengthname || dp->dnalengthfixed) { @@ -1535,8 +1535,8 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) /* test if we can allow raw array access, if it is using our standard * array get/next function, we can be sure it is an actual array */ if (cprop->next && cprop->get) - if (strcmp((const char *)cprop->next, "rna_iterator_array_next") == 0 && - strcmp((const char *)cprop->get, "rna_iterator_array_get") == 0) + if (STREQ((const char *)cprop->next, "rna_iterator_array_next") && + STREQ((const char *)cprop->get, "rna_iterator_array_get")) { prop->flag |= PROP_RAW_ARRAY; } @@ -2419,11 +2419,11 @@ static void rna_auto_types(void) for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { /* DNA name for Screen is patched in 2.5, we do the reverse here .. */ - if (ds->dnaname && strcmp(ds->dnaname, "Screen") == 0) + if (ds->dnaname && STREQ(ds->dnaname, "Screen")) ds->dnaname = "bScreen"; for (dp = ds->cont.properties.first; dp; dp = dp->next) { - if (dp->dnastructname && strcmp(dp->dnastructname, "Screen") == 0) + if (dp->dnastructname && STREQ(dp->dnastructname, "Screen")) dp->dnastructname = "bScreen"; if (dp->dnatype) { @@ -2443,7 +2443,7 @@ static void rna_auto_types(void) else if (dp->prop->type == PROP_COLLECTION) { CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop; - if (!cprop->item_type && !cprop->get && strcmp(dp->dnatype, "ListBase") == 0) + if (!cprop->item_type && !cprop->get && STREQ(dp->dnatype, "ListBase")) cprop->item_type = (StructRNA *)rna_find_type(dp->dnatype); } } @@ -2786,7 +2786,7 @@ static void rna_generate_struct_prototypes(FILE *f) const char *struct_name = rna_parameter_type_name(dp->prop); for (a = 0; a < all_structures; a++) { - if (strcmp(struct_name, structures[a]) == 0) { + if (STREQ(struct_name, structures[a])) { found = 1; break; } @@ -3417,7 +3417,7 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const if (!filename || ds->filename == filename) rna_generate_struct(brna, ds->srna, f); - if (strcmp(filename, "rna_ID.c") == 0) { + if (STREQ(filename, "rna_ID.c")) { /* this is ugly, but we cannot have c files compiled for both * makesrna and blender with some build systems at the moment */ fprintf(f, "#include \"rna_define.c\"\n\n"); @@ -3779,7 +3779,7 @@ static int rna_is_collection_functions_struct(const char **collection_structs, c int a = 0, found = 0; while (collection_structs[a]) { - if (!strcmp(collection_structs[a], struct_name)) { + if (STREQ(collection_structs[a], struct_name)) { found = 1; break; } @@ -3880,7 +3880,7 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { srna = ds->srna; - if (!strcmp(srna->identifier, first_collection_func_struct)) { + if (STREQ(srna->identifier, first_collection_func_struct)) { StructDefRNA *ds2; StructRNA *srna2; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 09b970fe7fd..7096060e73b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -241,13 +241,13 @@ static IDProperty *rna_idproperty_ui(PropertyRNA *prop) IDProperty *idprop; for (idprop = ((IDProperty *)prop)->prev; idprop; idprop = idprop->prev) { - if (strcmp(RNA_IDP_UI, idprop->name) == 0) + if (STREQ(RNA_IDP_UI, idprop->name)) break; } if (idprop == NULL) { for (idprop = ((IDProperty *)prop)->next; idprop; idprop = idprop->next) { - if (strcmp(RNA_IDP_UI, idprop->name) == 0) + if (STREQ(RNA_IDP_UI, idprop->name)) break; } } @@ -511,7 +511,7 @@ StructRNA *RNA_struct_find(const char *identifier) StructRNA *type; if (identifier) { for (type = BLENDER_RNA.structs.first; type; type = type->cont.next) - if (strcmp(type->identifier, identifier) == 0) + if (STREQ(type->identifier, identifier)) return type; } return NULL; @@ -719,7 +719,7 @@ FunctionRNA *RNA_struct_find_function(StructRNA *srna, const char *identifier) RNA_PROP_BEGIN (&tptr, funcptr, iterprop) { - if (strcmp(identifier, RNA_function_identifier(funcptr.data)) == 0) { + if (STREQ(identifier, RNA_function_identifier(funcptr.data))) { func = funcptr.data; break; } @@ -3229,7 +3229,7 @@ int RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, co nameptr = RNA_property_string_get_alloc(&iter.ptr, nameprop, name, sizeof(name), &namelen); - if ((keylen == namelen) && (strcmp(nameptr, key) == 0)) { + if ((keylen == namelen) && STREQ(nameptr, key)) { *r_ptr = iter.ptr; found = 1; } @@ -5264,7 +5264,7 @@ char *RNA_pointer_as_string_id(bContext *C, PointerRNA *ptr) { propname = RNA_property_identifier(prop); - if (strcmp(propname, "rna_type") == 0) + if (STREQ(propname, "rna_type")) continue; if (first_time == 0) @@ -5335,7 +5335,7 @@ char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, arg_name = RNA_property_identifier(prop); - if (strcmp(arg_name, "rna_type") == 0) { + if (STREQ(arg_name, "rna_type")) { continue; } @@ -5632,7 +5632,7 @@ PropertyRNA *RNA_function_find_parameter(PointerRNA *UNUSED(ptr), FunctionRNA *f parm = func->cont.properties.first; for (; parm; parm = parm->next) - if (strcmp(RNA_property_identifier(parm), identifier) == 0) + if (STREQ(RNA_property_identifier(parm), identifier)) break; return parm; @@ -5830,7 +5830,7 @@ void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void parm = parms->func->cont.properties.first; for (; parm; parm = parm->next) - if (strcmp(RNA_property_identifier(parm), identifier) == 0) + if (STREQ(RNA_property_identifier(parm), identifier)) break; if (parm) @@ -5886,7 +5886,7 @@ void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, cons parm = parms->func->cont.properties.first; for (; parm; parm = parm->next) - if (strcmp(RNA_property_identifier(parm), identifier) == 0) + if (STREQ(RNA_property_identifier(parm), identifier)) break; if (parm) @@ -6713,7 +6713,7 @@ bool RNA_property_equals(PointerRNA *a, PointerRNA *b, PropertyRNA *prop, eRNAEq int len_a, len_b; char *value_a = RNA_property_string_get_alloc(a, prop, fixed_a, sizeof(fixed_a), &len_a); char *value_b = RNA_property_string_get_alloc(b, prop, fixed_b, sizeof(fixed_b), &len_b); - bool equals = strcmp(value_a, value_b) == 0; + bool equals = STREQ(value_a, value_b); if (value_a != fixed_a) MEM_freeN(value_a); if (value_b != fixed_b) MEM_freeN(value_b); diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 6792dd7e5f8..9c7d66d00c7 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -494,11 +494,11 @@ static void rna_Actuator_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scen bPoseChannel *pchan; bPose *pose = ob->pose; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - if (!strcmp(pchan->name, posechannel)) { + if (STREQ(pchan->name, posechannel)) { /* found it, now look for constraint channel */ bConstraint *con; for (con = pchan->constraints.first; con; con = con->next) { - if (!strcmp(con->name, constraint)) { + if (STREQ(con->name, constraint)) { /* found it, all ok */ return; } diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index e858381b567..e4696d87992 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -343,7 +343,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value) KeyingSet *ks = (KeyingSet *)ptr->data; /* update names of corresponding groups if name changes */ - if (strcmp(ks->name, value)) { + if (!STREQ(ks->name, value)) { KS_Path *ksp; for (ksp = ks->paths.first; ksp; ksp = ksp->next) { @@ -359,7 +359,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value) * conflicts */ for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) { - if (strcmp(ks->name, agrp->name) == 0) { + if (STREQ(ks->name, agrp->name)) { /* there should only be one of these in the action, so can stop... */ BLI_strncpy(agrp->name, value, sizeof(agrp->name)); break; diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 54c08009792..7773b4c8f23 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -109,7 +109,7 @@ PropertyDefRNA *rna_findlink(ListBase *listbase, const char *identifier) for (link = listbase->first; link; link = link->next) { PropertyRNA *prop = ((PropertyDefRNA *)link)->prop; - if (prop && (strcmp(prop->identifier, identifier) == 0)) { + if (prop && (STREQ(prop->identifier, identifier))) { return (PropertyDefRNA *)link; } } @@ -428,7 +428,7 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro } for (a = 0; kwlist[a]; a++) { - if (strcmp(identifier, kwlist[a]) == 0) { + if (STREQ(identifier, kwlist[a])) { strcpy(error, "this keyword is reserved by python"); return 0; } @@ -442,7 +442,7 @@ static int rna_validate_identifier(const char *identifier, char *error, bool pro }; for (a = 0; kwlist_prop[a]; a++) { - if (strcmp(identifier, kwlist_prop[a]) == 0) { + if (STREQ(identifier, kwlist_prop[a])) { strcpy(error, "this keyword is reserved by python"); return 0; } @@ -496,7 +496,7 @@ void RNA_identifier_sanitize(char *identifier, int property) } for (a = 0; kwlist[a]; a++) { - if (strcmp(identifier, kwlist[a]) == 0) { + if (STREQ(identifier, kwlist[a])) { /* this keyword is reserved by python. * just replace the last character by '_' to keep it readable. */ @@ -513,7 +513,7 @@ void RNA_identifier_sanitize(char *identifier, int property) }; for (a = 0; kwlist_prop[a]; a++) { - if (strcmp(identifier, kwlist_prop[a]) == 0) { + if (STREQ(identifier, kwlist_prop[a])) { /* this keyword is reserved by python. * just replace the last character by '_' to keep it readable. */ @@ -814,7 +814,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * if (from) { /* find struct to derive from */ for (srnafrom = brna->structs.first; srnafrom; srnafrom = srnafrom->cont.next) - if (strcmp(srnafrom->identifier, from) == 0) + if (STREQ(srnafrom->identifier, from)) break; if (!srnafrom) { @@ -896,7 +896,7 @@ void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *struct /* find struct to derive from */ for (srnafrom = brna->structs.first; srnafrom; srnafrom = srnafrom->cont.next) - if (strcmp(srnafrom->identifier, structname) == 0) + if (STREQ(srnafrom->identifier, structname)) break; if (!srnafrom) { @@ -1871,15 +1871,15 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const } /* SDNA doesn't pass us unsigned unfortunately .. */ - if (dp->dnatype && strcmp(dp->dnatype, "char") == 0) { + if (dp->dnatype && STREQ(dp->dnatype, "char")) { iprop->hardmin = iprop->softmin = CHAR_MIN; iprop->hardmax = iprop->softmax = CHAR_MAX; } - else if (dp->dnatype && strcmp(dp->dnatype, "short") == 0) { + else if (dp->dnatype && STREQ(dp->dnatype, "short")) { iprop->hardmin = iprop->softmin = SHRT_MIN; iprop->hardmax = iprop->softmax = SHRT_MAX; } - else if (dp->dnatype && strcmp(dp->dnatype, "int") == 0) { + else if (dp->dnatype && STREQ(dp->dnatype, "int")) { iprop->hardmin = INT_MIN; iprop->hardmax = INT_MAX; @@ -1923,7 +1923,7 @@ void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, cons } } - if (dp->dnatype && strcmp(dp->dnatype, "char") == 0) { + if (dp->dnatype && STREQ(dp->dnatype, "char")) { fprop->hardmin = fprop->softmin = 0.0f; fprop->hardmax = fprop->softmax = 1.0f; } @@ -2060,7 +2060,7 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, } } - if (dp->dnatype && strcmp(dp->dnatype, "ListBase") == 0) { + if (dp->dnatype && STREQ(dp->dnatype, "ListBase")) { cprop->next = (PropCollectionNextFunc)"rna_iterator_listbase_next"; cprop->get = (PropCollectionGetFunc)"rna_iterator_listbase_get"; cprop->end = (PropCollectionEndFunc)"rna_iterator_listbase_end"; @@ -3427,7 +3427,7 @@ int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *ide PropertyRNA *prop; for (prop = cont->properties.first; prop; prop = prop->next) { - if (strcmp(prop->identifier, identifier) == 0) { + if (STREQ(prop->identifier, identifier)) { if (prop->flag & PROP_RUNTIME) { rna_def_property_free(cont_, prop); return 1; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 18bfea026e1..a7e0ed27299 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -611,7 +611,7 @@ static void rna_MultiresModifier_filepath_set(PointerRNA *ptr, const char *value Object *ob = (Object *)ptr->id.data; CustomDataExternal *external = ((Mesh *)ob->data)->ldata.external; - if (external && strcmp(external->filename, value)) { + if (external && !STREQ(external->filename, value)) { BLI_strncpy(external->filename, value, sizeof(external->filename)); multires_force_external_reload(ob); } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f9a76005df8..60cf7535135 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -640,7 +640,7 @@ void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *resul for (a = 0; a < me->pdata.totlayer; a++) { layer = &me->pdata.layers[a]; - if (layer->type == CD_MTEXPOLY && strcmp(layer->name, value) == 0) { + if (layer->type == CD_MTEXPOLY && STREQ(layer->name, value)) { BLI_strncpy(result, value, maxlen); return; } @@ -663,7 +663,7 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res for (a = 0; a < me->fdata.totlayer; a++) { layer = &me->fdata.layers[a]; - if (layer->type == CD_MCOL && strcmp(layer->name, value) == 0) { + if (layer->type == CD_MCOL && STREQ(layer->name, value)) { BLI_strncpy(result, value, maxlen); return; } diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index cd28c608667..4cc098fb4a6 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -190,7 +190,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P for (pid = pidlist.first; pid; pid = pid->next) { if (pid->cache == cache) pid2 = pid; - else if (cache->name[0] != '\0' && strcmp(cache->name, pid->cache->name) == 0) { + else if (cache->name[0] != '\0' && STREQ(cache->name, pid->cache->name)) { /*TODO: report "name exists" to user */ BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name)); new_name = 0; diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 6db9c8e9cd9..124a83a5f30 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -267,7 +267,7 @@ static StructRNA *rna_RenderEngine_register(Main *bmain, ReportList *reports, vo /* check if we have registered this engine type before, and remove it */ for (et = R_engines.first; et; et = et->next) { - if (strcmp(et->idname, dummyet.idname) == 0) { + if (STREQ(et->idname, dummyet.idname)) { if (et->ext.srna) rna_RenderEngine_unregister(bmain, et->ext.srna); break; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 4f51ec5468c..b2c135cd1f9 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -179,7 +179,7 @@ static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data) * for the second loop where we go over unknown id properties */ do { for (prop = ptype->cont.properties.first; prop; prop = prop->next) - if ((prop->flag & PROP_BUILTIN) == 0 && strcmp(prop->identifier, idprop->name) == 0) + if ((prop->flag & PROP_BUILTIN) == 0 && STREQ(prop->identifier, idprop->name)) return 1; } while ((ptype = ptype->base)); @@ -386,7 +386,7 @@ int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, Point } else { for (prop = srna->cont.properties.first; prop; prop = prop->next) { - if (!(prop->flag & PROP_BUILTIN) && strcmp(prop->identifier, key) == 0) { + if (!(prop->flag & PROP_BUILTIN) && STREQ(prop->identifier, key)) { propptr.type = &RNA_Property; propptr.data = prop; @@ -408,7 +408,7 @@ int rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key, Point if (group) { for (idp = group->data.group.first; idp; idp = idp->next) { - if (strcmp(idp->name, key) == 0) { + if (STREQ(idp->name, key)) { propptr.type = &RNA_Property; propptr.data = idp; @@ -1002,7 +1002,7 @@ static int rna_BlenderRNA_structs_lookup_string(PointerRNA *ptr, const char *key { StructRNA *srna = ((BlenderRNA *)ptr->data)->structs.first; for (; srna; srna = srna->cont.next) { - if (key[0] == srna->identifier[0] && strcmp(key, srna->identifier) == 0) { + if (key[0] == srna->identifier[0] && STREQ(key, srna->identifier)) { RNA_pointer_create(NULL, &RNA_Struct, srna, r_ptr); return true; } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7dd0185b3c6..1cc9ef15f08 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -385,7 +385,7 @@ static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key Base *base; for (base = scene->base.first; base; base = base->next) { - if (strncmp(base->object->id.name + 2, key, sizeof(base->object->id.name) - 2) == 0) { + if (STREQLEN(base->object->id.name + 2, key, sizeof(base->object->id.name) - 2)) { *r_ptr = rna_pointer_inherit_refine(ptr, &RNA_ObjectBase, base); return true; } @@ -1158,7 +1158,7 @@ static int rna_RenderSettings_engine_get(PointerRNA *ptr) int a = 0; for (type = R_engines.first; type; type = type->next, a++) - if (strcmp(type->idname, rd->engine) == 0) + if (STREQ(type->idname, rd->engine)) return a; return 0; @@ -1243,7 +1243,7 @@ static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) RenderEngineType *type; for (type = R_engines.first; type; type = type->next) - if (strcmp(type->idname, rd->engine) == 0) + if (STREQ(type->idname, rd->engine)) return (type->flag & RE_GAME); return 0; diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index 3944b59dff7..28b7b5fbcd8 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -246,11 +246,11 @@ static void rna_Sensor_Armature_update(Main *UNUSED(bmain), Scene *UNUSED(scene) bPoseChannel *pchan; bPose *pose = ob->pose; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - if (!strcmp(pchan->name, posechannel)) { + if (STREQ(pchan->name, posechannel)) { /* found it, now look for constraint channel */ bConstraint *con; for (con = pchan->constraints.first; con; con = con->next) { - if (!strcmp(con->name, constraint)) { + if (STREQ(con->name, constraint)) { /* found it, all ok */ return; } diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index c54822bef4d..ff9df16ae94 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1249,7 +1249,7 @@ static int rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, const PointerRNA bNodeTree *ntree = (bNodeTree *)value.data; /* node tree type must match the selected type in node editor */ - return (strcmp(snode->tree_idname, ntree->idname) == 0); + return (STREQ(snode->tree_idname, ntree->idname)); } static void rna_SpaceNodeEditor_node_tree_update(const bContext *C, PointerRNA *UNUSED(ptr)) diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index a61846fa028..fde43abe9fb 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -221,7 +221,7 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat /* check if we have registered this panel type before, and remove it */ for (pt = art->paneltypes.first; pt; pt = pt->next) { - if (strcmp(pt->idname, dummypt.idname) == 0) { + if (STREQ(pt->idname, dummypt.idname)) { if (pt->ext.srna) rna_Panel_unregister(bmain, pt->ext.srna); else @@ -587,7 +587,7 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da /* check if we have registered this header type before, and remove it */ for (ht = art->headertypes.first; ht; ht = ht->next) { - if (strcmp(ht->idname, dummyht.idname) == 0) { + if (STREQ(ht->idname, dummyht.idname)) { if (ht->ext.srna) rna_Header_unregister(bmain, ht->ext.srna); break; diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 4f889c91665..b5eeebae664 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -295,7 +295,7 @@ static const char *rna_ui_get_enum_name(bContext *C, PointerRNA *ptr, const char if (items) { for (item = items; item->identifier; item++) { - if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) { + if (item->identifier[0] && STREQ(item->identifier, identifier)) { name = item->name; break; } @@ -326,7 +326,7 @@ static const char *rna_ui_get_enum_description(bContext *C, PointerRNA *ptr, con if (items) { for (item = items; item->identifier; item++) { - if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) { + if (item->identifier[0] && STREQ(item->identifier, identifier)) { desc = item->description; break; } @@ -356,7 +356,7 @@ static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propna if (items) { for (item = items; item->identifier; item++) { - if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) { + if (item->identifier[0] && STREQ(item->identifier, identifier)) { icon = item->icon; break; } diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 3b97508dd67..347b669812e 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -835,7 +835,7 @@ static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value) WM_operator_bl_idname(idname, value); - if (strcmp(idname, kmi->idname) != 0) { + if (!STREQ(idname, kmi->idname)) { BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname)); WM_keymap_properties_reset(kmi, NULL); -- cgit v1.2.3