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/editors/armature/armature_add.c | 2 +- source/blender/editors/armature/armature_naming.c | 6 +++--- source/blender/editors/armature/armature_relations.c | 6 +++--- source/blender/editors/armature/editarmature_retarget.c | 6 +++--- source/blender/editors/armature/editarmature_sketch.c | 4 ++-- source/blender/editors/armature/pose_lib.c | 2 +- source/blender/editors/armature/pose_utils.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) (limited to 'source/blender/editors/armature') diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index eba1bc4d78d..22aaeccc4a8 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -270,7 +270,7 @@ static EditBone *get_named_editbone(ListBase *edbo, const char *name) if (name) { for (eBone = edbo->first; eBone; eBone = eBone->next) { - if (!strcmp(name, eBone->name)) + if (STREQ(name, eBone->name)) return eBone; } } diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index f984bf071fa..a8b5f888597 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -141,7 +141,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n char oldname[MAXBONENAME]; /* names better differ! */ - if (strncmp(oldnamep, newnamep, MAXBONENAME)) { + if (!STREQLEN(oldnamep, newnamep, MAXBONENAME)) { /* we alter newname string... so make copy */ BLI_strncpy(newname, newnamep, MAXBONENAME); @@ -219,7 +219,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n if (ob->parent && (ob->parent->data == arm)) { if (ob->partype == PARBONE) { /* bone name in object */ - if (!strcmp(ob->parsubstr, oldname)) + if (STREQ(ob->parsubstr, oldname)) BLI_strncpy(ob->parsubstr, newname, MAXBONENAME); } } @@ -285,7 +285,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->ob_centre && v3d->ob_centre->data == arm) { - if (!strcmp(v3d->ob_centre_bone, oldname)) { + if (STREQ(v3d->ob_centre_bone, oldname)) { BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME); } } diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 41f528bc5e2..53989dd783c 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -151,7 +151,7 @@ static void joined_armature_fix_animdata_cb(ID *id, AnimData *adt, void *user_da const char *new_name = BLI_ghashIterator_getValue(&gh_iter); /* only remap if changed; this still means there will be some waste if there aren't many drivers/keys */ - if (strcmp(old_name, new_name) && strstr(fcu->rna_path, old_name)) { + if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) { fcu->rna_path = BKE_animsys_fix_rna_path_rename(id, fcu->rna_path, "pose.bones", old_name, new_name, 0, 0, false); @@ -189,14 +189,14 @@ static void joined_armature_fix_animdata_cb(ID *id, AnimData *adt, void *user_da const char *new_name = BLI_ghashIterator_getValue(&gh_iter); /* only remap if changed */ - if (strcmp(old_name, new_name)) { + if (!STREQ(old_name, new_name)) { if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) { /* Fix up path */ dtar->rna_path = BKE_animsys_fix_rna_path_rename(id, dtar->rna_path, "pose.bones", old_name, new_name, 0, 0, false); break; /* no need to try any more names for bone path */ } - else if (strcmp(dtar->pchan_name, old_name) == 0) { + else if (STREQ(dtar->pchan_name, old_name)) { /* Change target bone name */ BLI_strncpy(dtar->pchan_name, new_name, sizeof(dtar->pchan_name)); break; /* no need to try any more names for bone subtarget */ diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index aace8c5434c..5376fc8c79b 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -718,7 +718,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) cti->get_constraint_targets(con, &targets); for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) { - if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { + if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) { /* SET bone link to bone corresponding to pchan */ EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name); @@ -841,7 +841,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) cti->get_constraint_targets(con, &targets); for (ct = targets.first; ct; ct = ct->next) { - if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { + if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) { /* SET bone link to ctrl corresponding to pchan */ RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name); @@ -1160,7 +1160,7 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo last_bone = bone; - if (strcmp(bone->name, "head") == 0) { + if (STREQ(bone->name, "head")) { contain_head = 1; } } diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 3dbf7b4b65a..6c2d4256a0f 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -333,11 +333,11 @@ static void sk_autoname(bContext *C, ReebArc *arc) if (side[0] == '\0') { valid = 1; } - else if (strcmp(side, "R") == 0 || strcmp(side, "L") == 0) { + else if (STREQ(side, "R") || STREQ(side, "L")) { valid = 1; caps = 1; } - else if (strcmp(side, "r") == 0 || strcmp(side, "l") == 0) { + else if (STREQ(side, "r") || STREQ(side, "l")) { valid = 1; caps = 0; } diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 2e6eace88aa..d571fb374d9 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -1050,7 +1050,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) LinkData *ld, *ldn, *ldc; /* free and rebuild if needed (i.e. if search-str changed) */ - if (strcmp(pld->searchstr, pld->searchold)) { + if (!STREQ(pld->searchstr, pld->searchold)) { /* free list of temporary search matches */ BLI_freelistN(&pld->searchp); diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index 1297755b7d0..2ba1eedd33b 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -259,7 +259,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con FCurve *fcu = (FCurve *)ld->data; /* check if paths match */ - if (strcmp(path, fcu->rna_path) == 0) + if (STREQ(path, fcu->rna_path)) return ld; } -- cgit v1.2.3