diff options
Diffstat (limited to 'source')
133 files changed, 467 insertions, 471 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 6bbf07173b9..127826f98c8 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -137,7 +137,7 @@ static int blf_search(const char *name) for (i = 0; i < BLF_MAX_FONT; i++) { font = global_font[i]; - if (font && (!strcmp(font->name, name))) + if (font && (STREQ(font->name, name))) return i; } @@ -324,7 +324,7 @@ void BLF_unload(const char *name) for (i = 0; i < BLF_MAX_FONT; i++) { font = global_font[i]; - if (font && (!strcmp(font->name, name))) { + if (font && (STREQ(font->name, name))) { blf_font_free(font); global_font[i] = NULL; } diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index e7d2c14b16f..2a4a152f0eb 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -133,7 +133,7 @@ void BLF_free_unifont_mono(void) bool BLF_is_default_context(const char *msgctxt) { /* We use the "short" test, a more complete one could be: - * return (!msgctxt || !msgctxt[0] || !strcmp(msgctxt == BLF_I18NCONTEXT_DEFAULT_BPYRNA)) + * return (!msgctxt || !msgctxt[0] || STREQ(msgctxt, BLF_I18NCONTEXT_DEFAULT_BPYRNA)) */ /* Note: trying without the void string check for now, it *should* not be necessary... */ return (!msgctxt || msgctxt[0] == BLF_I18NCONTEXT_DEFAULT_BPYRNA[0]); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index ea168ca6a84..8e2b3de9586 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -791,7 +791,7 @@ static void fcurves_path_rename_fix(ID *owner_id, const char *prefix, const char if (fcu->rna_path != old_path) { bActionGroup *agrp = fcu->grp; - if ((agrp) && strcmp(oldName, agrp->name) == 0) { + if ((agrp) && STREQ(oldName, agrp->name)) { BLI_strncpy(agrp->name, newName, sizeof(agrp->name)); } } @@ -828,7 +828,7 @@ static void drivers_path_rename_fix(ID *owner_id, ID *ref_id, const char *prefix /* also fix the bone-name (if applicable) */ if (strstr(prefix, "bones")) { if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB) && (!ref_id || ((Object *)(dtar->id))->data == ref_id)) && - (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name) == 0) ) + (dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name) ) { BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); } @@ -1281,7 +1281,7 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], eq_id = 0; /* path */ - if ((ksp->rna_path == NULL) || strcmp(rna_path, ksp->rna_path)) + if ((ksp->rna_path == NULL) || !STREQ(rna_path, ksp->rna_path)) eq_path = 0; /* index - need to compare whole-array setting too... */ diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index 9f34d5b9cd9..60e81003c40 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -641,7 +641,7 @@ static void bli_where_am_i(char *fullname, const size_t maxlen, const char *name } } #if defined(DEBUG) - if (strcmp(name, fullname)) { + if (!STREQ(name, fullname)) { printf("guessing '%s' == '%s'\n", name, fullname); } #endif diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 431c24d3ed0..7d04ab7778f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -233,7 +233,7 @@ static Bone *get_named_bone_bonechildren(Bone *bone, const char *name) { Bone *curBone, *rbone; - if (!strcmp(bone->name, name)) + if (STREQ(bone->name, name)) return bone; for (curBone = bone->childbase.first; curBone; curBone = curBone->next) { @@ -2417,7 +2417,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha /* validate first */ if (amod->ob && amod->ob->type == OB_CURVE && amod->channel[0]) { - if (strcmp(pchan->name, amod->channel) == 0) { + if (STREQ(pchan->name, amod->channel)) { float mat4[4][4], mat3[3][3]; curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); @@ -2430,7 +2430,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha break; case ACTSTRIP_MOD_NOISE: { - if (strcmp(pchan->name, amod->channel) == 0) { + if (STREQ(pchan->name, amod->channel)) { float nor[3], loc[3], ofs; float eul[3], size[3], eulo[3], sizeo[3]; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 8f6c9735aaf..7142c092583 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -454,7 +454,7 @@ static void data_dir_add(ListBase *lb, const char *member, const bool use_all) { LinkData *link; - if ((use_all == false) && strcmp(member, "scene") == 0) /* exception */ + if ((use_all == false) && STREQ(member, "scene")) /* exception */ return; if (BLI_findstring(lb, member, offsetof(LinkData, data))) @@ -546,7 +546,7 @@ ListBase CTX_data_dir_get(const bContext *C) bool CTX_data_equals(const char *member, const char *str) { - return (strcmp(member, str) == 0); + return (STREQ(member, str)); } bool CTX_data_dir(const char *member) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 89ebed258a3..a259958dc0c 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1553,7 +1553,7 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha for (i = 0; i < data->totlayer; ++i) if (data->layers[i].type == type) - if (strcmp(data->layers[i].name, name) == 0) + if (STREQ(data->layers[i].name, name)) return i; return -1; @@ -2690,7 +2690,7 @@ void CustomData_bmesh_copy_data(const CustomData *source, CustomData *dest, /* if we found a matching layer, copy the data */ if (dest->layers[dest_i].type == source->layers[src_i].type && - strcmp(dest->layers[dest_i].name, source->layers[src_i].name) == 0) + STREQ(dest->layers[dest_i].name, source->layers[src_i].name)) { const char *src_data = (char *)src_block + source->layers[src_i].offset; char *dest_data = (char *)*dest_block + dest->layers[dest_i].offset; @@ -3163,12 +3163,12 @@ static bool cd_layer_find_dupe(CustomData *data, const char *name, int type, int CustomDataLayer *layer = &data->layers[i]; if (CustomData_is_property_layer(type)) { - if (CustomData_is_property_layer(layer->type) && strcmp(layer->name, name) == 0) { + if (CustomData_is_property_layer(layer->type) && STREQ(layer->name, name)) { return true; } } else { - if (i != index && layer->type == type && strcmp(layer->name, name) == 0) { + if (i != index && layer->type == type && STREQ(layer->name, name)) { return true; } } diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 97972cca30c..41579aaa568 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -417,7 +417,7 @@ CDataFileLayer *cdf_layer_find(CDataFile *cdf, int type, const char *name) for (a = 0; a < cdf->totlayer; a++) { layer = &cdf->layer[a]; - if (layer->type == type && strcmp(layer->name, name) == 0) + if (layer->type == type && STREQ(layer->name, name)) return layer; } diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 80db62801d6..e2bb326b226 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -542,7 +542,7 @@ static bool defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object * for (curdef = ob->defbase.first; curdef; curdef = curdef->next) { if (dg != curdef) { - if (!strcmp(curdef->name, name)) { + if (STREQ(curdef->name, name)) { return true; } } diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 3541b3fba3f..bbc8cc314f5 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -368,7 +368,7 @@ static bool surface_duplicateNameExists(void *arg, const char *name) DynamicPaintSurface *surface = t_surface->canvas->surfaces.first; for (; surface; surface = surface->next) { - if (surface != t_surface && !strcmp(name, surface->name)) return true; + if (surface != t_surface && STREQ(name, surface->name)) return true; } return false; } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 4648d70b62b..765917794e8 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -230,7 +230,7 @@ FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_ /* check paths of curves, then array indices... */ for (fcu = list->first; fcu; fcu = fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ - if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { + if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) { /* now check indices */ if (fcu->array_index == array_index) return fcu; @@ -253,7 +253,7 @@ FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[]) /* check paths of curves, then array indices... */ for (fcu = fcu_iter; fcu; fcu = fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ - if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { + if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) { return fcu; } } @@ -290,7 +290,7 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, if (quotedName) { /* check if the quoted name matches the required name */ - if (strcmp(quotedName, dataName) == 0) { + if (STREQ(quotedName, dataName)) { LinkData *ld = MEM_callocN(sizeof(LinkData), __func__); ld->data = fcu; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 8d4bb7ec058..2adf8ebc615 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -245,7 +245,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) } /* Do not add FO_BUILTIN_NAME to temporary listbase */ - if (strcmp(filename, FO_BUILTIN_NAME)) { + if (!STREQ(filename, FO_BUILTIN_NAME)) { vfont->temp_pf = temp_pf; } } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 2b99b5f4620..4d83f8cf916 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -804,7 +804,7 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is case IDP_STRING: { return (((prop1->len == prop2->len) && - strncmp(IDP_String(prop1), IDP_String(prop2), (size_t)prop1->len) == 0)); + STREQLEN(IDP_String(prop1), IDP_String(prop2), (size_t)prop1->len))); } case IDP_ARRAY: if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) { diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 27165042cb2..4404182192e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1223,37 +1223,37 @@ char BKE_imtype_valid_depths(const char imtype) * creator.c help info */ char BKE_imtype_from_arg(const char *imtype_arg) { - if (!strcmp(imtype_arg, "TGA")) return R_IMF_IMTYPE_TARGA; - else if (!strcmp(imtype_arg, "IRIS")) return R_IMF_IMTYPE_IRIS; + if (STREQ(imtype_arg, "TGA")) return R_IMF_IMTYPE_TARGA; + else if (STREQ(imtype_arg, "IRIS")) return R_IMF_IMTYPE_IRIS; #ifdef WITH_DDS - else if (!strcmp(imtype_arg, "DDS")) return R_IMF_IMTYPE_DDS; + else if (STREQ(imtype_arg, "DDS")) return R_IMF_IMTYPE_DDS; #endif - else if (!strcmp(imtype_arg, "JPEG")) return R_IMF_IMTYPE_JPEG90; - else if (!strcmp(imtype_arg, "IRIZ")) return R_IMF_IMTYPE_IRIZ; - else if (!strcmp(imtype_arg, "RAWTGA")) return R_IMF_IMTYPE_RAWTGA; - else if (!strcmp(imtype_arg, "AVIRAW")) return R_IMF_IMTYPE_AVIRAW; - else if (!strcmp(imtype_arg, "AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG; - else if (!strcmp(imtype_arg, "PNG")) return R_IMF_IMTYPE_PNG; - else if (!strcmp(imtype_arg, "QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME; - else if (!strcmp(imtype_arg, "BMP")) return R_IMF_IMTYPE_BMP; + else if (STREQ(imtype_arg, "JPEG")) return R_IMF_IMTYPE_JPEG90; + else if (STREQ(imtype_arg, "IRIZ")) return R_IMF_IMTYPE_IRIZ; + else if (STREQ(imtype_arg, "RAWTGA")) return R_IMF_IMTYPE_RAWTGA; + else if (STREQ(imtype_arg, "AVIRAW")) return R_IMF_IMTYPE_AVIRAW; + else if (STREQ(imtype_arg, "AVIJPEG")) return R_IMF_IMTYPE_AVIJPEG; + else if (STREQ(imtype_arg, "PNG")) return R_IMF_IMTYPE_PNG; + else if (STREQ(imtype_arg, "QUICKTIME")) return R_IMF_IMTYPE_QUICKTIME; + else if (STREQ(imtype_arg, "BMP")) return R_IMF_IMTYPE_BMP; #ifdef WITH_HDR - else if (!strcmp(imtype_arg, "HDR")) return R_IMF_IMTYPE_RADHDR; + else if (STREQ(imtype_arg, "HDR")) return R_IMF_IMTYPE_RADHDR; #endif #ifdef WITH_TIFF - else if (!strcmp(imtype_arg, "TIFF")) return R_IMF_IMTYPE_TIFF; + else if (STREQ(imtype_arg, "TIFF")) return R_IMF_IMTYPE_TIFF; #endif #ifdef WITH_OPENEXR - else if (!strcmp(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR; - else if (!strcmp(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER; + else if (STREQ(imtype_arg, "EXR")) return R_IMF_IMTYPE_OPENEXR; + else if (STREQ(imtype_arg, "MULTILAYER")) return R_IMF_IMTYPE_MULTILAYER; #endif - else if (!strcmp(imtype_arg, "MPEG")) return R_IMF_IMTYPE_FFMPEG; - else if (!strcmp(imtype_arg, "FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER; + else if (STREQ(imtype_arg, "MPEG")) return R_IMF_IMTYPE_FFMPEG; + else if (STREQ(imtype_arg, "FRAMESERVER")) return R_IMF_IMTYPE_FRAMESERVER; #ifdef WITH_CINEON - else if (!strcmp(imtype_arg, "CINEON")) return R_IMF_IMTYPE_CINEON; - else if (!strcmp(imtype_arg, "DPX")) return R_IMF_IMTYPE_DPX; + else if (STREQ(imtype_arg, "CINEON")) return R_IMF_IMTYPE_CINEON; + else if (STREQ(imtype_arg, "DPX")) return R_IMF_IMTYPE_DPX; #endif #ifdef WITH_OPENJPEG - else if (!strcmp(imtype_arg, "JP2")) return R_IMF_IMTYPE_JP2; + else if (STREQ(imtype_arg, "JP2")) return R_IMF_IMTYPE_JP2; #endif else return R_IMF_IMTYPE_INVALID; } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index f8c79832dfc..c748568b4c5 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -922,11 +922,11 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); } else if (actname && actname[0]) { - if ((blocktype == ID_OB) && strcmp(actname, "Object") == 0) { + if ((blocktype == ID_OB) && STREQ(actname, "Object")) { /* Actionified "Object" IPO's... no extra path stuff needed */ buf[0] = '\0'; /* empty string */ } - else if ((blocktype == ID_KE) && strcmp(actname, "Shape") == 0) { + else if ((blocktype == ID_KE) && STREQ(actname, "Shape")) { /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */ strcpy(buf, "data.shape_keys"); } @@ -1326,7 +1326,7 @@ static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *i * - we now need as 'frames' */ if ( (id) && (icu->blocktype == GS(id->name)) && - (fcu->rna_path && strcmp(fcu->rna_path, "eval_time") == 0) ) + (fcu->rna_path && STREQ(fcu->rna_path, "eval_time")) ) { Curve *cu = (Curve *)id; @@ -1403,9 +1403,9 @@ static void ipo_to_animato(ID *id, Ipo *ipo, char actname[], char constname[], S * F-Curves for bones). This may be added later... for now let's just dump without them... */ if (actname) { - if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Object") == 0)) + if ((ipo->blocktype == ID_OB) && STREQ(actname, "Object")) actname = NULL; - else if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Shape") == 0)) + else if ((ipo->blocktype == ID_OB) && STREQ(actname, "Shape")) actname = NULL; } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 752c2961f28..4cb792da179 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1202,7 +1202,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) /* do not test alphabetic! */ /* optimized */ if (idtest->name[2] == name[0]) { - if (strcmp(name, idtest->name + 2) == 0) break; + if (STREQ(name, idtest->name + 2)) break; } } } @@ -1260,7 +1260,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name) if ( (id != idtest) && (idtest->lib == NULL) && (*name == *(idtest->name + 2)) && - (strncmp(name, idtest->name + 2, left_len) == 0) && + STREQLEN(name, idtest->name + 2, left_len) && (BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len) ) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 981064bb22a..f8f69b8901d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1027,7 +1027,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) Group *group; for (group = G.main->group.first; group; group = group->id.next) { - if (!group->id.lib && strcmp(group->id.name, ma->group->id.name) == 0) { + if (!group->id.lib && STREQ(group->id.name, ma->group->id.name)) { ma->group = group; } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 5649164a273..ce20636233a 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -468,7 +468,7 @@ bool BKE_mball_is_basis_for(Object *ob1, Object *ob2) BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.'); BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.'); - if (!strcmp(basis1name, basis2name)) { + if (STREQ(basis1name, basis2name)) { return BKE_mball_is_basis(ob1); } else { @@ -503,7 +503,7 @@ void BKE_mball_properties_copy(Scene *scene, Object *active_object) /* Object ob has to be in same "group" ... it means, that it has to have * same base of its name */ - if (strcmp(obname, basisname) == 0) { + if (STREQ(obname, basisname)) { MetaBall *mb = ob->data; /* Copy properties from selected/edited metaball */ @@ -545,7 +545,7 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis) BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* object ob has to be in same "group" ... it means, that it has to have same base of its name */ - if (strcmp(obname, basisname) == 0) { + if (STREQ(obname, basisname)) { if (obnr < basisnr) { basis = ob; basisnr = obnr; @@ -1679,7 +1679,7 @@ static float init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *sce int nr; BLI_split_name_num(name, &nr, bob->id.name + 2, '.'); - if (strcmp(obname, name) == 0) { + if (STREQ(obname, name)) { mb = bob->data; if (mb->editelems) ml = mb->editelems->first; @@ -2243,7 +2243,7 @@ static void mball_count(EvaluationContext *eval_ctx, PROCESS *process, Scene *sc /* object ob has to be in same "group" ... it means, that it has to have * same base of its name */ - if (strcmp(obname, basisname) == 0) { + if (STREQ(obname, basisname)) { MetaBall *mb = ob->data; /* if object is in edit mode, then dynamic list of all MetaElems diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index c47d294cfb2..8ad20df18db 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -703,7 +703,7 @@ bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int } /* Loop until we do have exactly the same name for all layers! */ - for (i = 1; (strcmp(cdlp->name, cdlu->name) != 0 || (cdlf && strcmp(cdlp->name, cdlf->name) != 0)); i++) { + for (i = 1; !STREQ(cdlp->name, cdlu->name) || (cdlf && !STREQ(cdlp->name, cdlf->name)); i++) { switch (i % step) { case 0: BLI_strncpy(cdlp->name, cdlu->name, sizeof(cdlp->name)); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index fe38fedd7aa..491fb46bd1f 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -621,7 +621,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name) BLI_strncpy(strtest, clip->name, sizeof(clip->name)); BLI_path_abs(strtest, G.main->name); - if (strcmp(strtest, str) == 0) { + if (STREQ(strtest, str)) { BLI_strncpy(clip->name, name, sizeof(clip->name)); /* for stringcode */ clip->id.us++; /* officially should not, it doesn't link here! */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 039af949d81..f30e3b699dd 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2250,7 +2250,7 @@ StructRNA *ntreeInterfaceTypeGet(bNodeTree *ntree, int create) ntree_interface_identifier_base(ntree, base); /* RNA identifier may have a number suffix, but should start with the idbase string */ - if (strncmp(RNA_struct_identifier(srna), base, sizeof(base)) != 0) { + if (!STREQLEN(RNA_struct_identifier(srna), base, sizeof(base))) { /* generate new unique RNA identifier from the ID name */ ntree_interface_identifier(ntree, base, identifier, sizeof(identifier), name, description); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 19ed49c727a..a8add058590 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -772,7 +772,7 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) /* version header */ ptcache_file_read(pf, version, 4, sizeof(char)); - if (strncmp(version, SMOKE_CACHE_VERSION, 4)) + if (!STREQLEN(version, SMOKE_CACHE_VERSION, 4)) { /* reset file pointer */ fseek(pf->fp, -4, SEEK_CUR); @@ -954,7 +954,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) /* version header */ ptcache_file_read(pf, version, 1, sizeof(char) * 4); - if (strncmp(version, DPAINT_CACHE_VERSION, 4)) { + if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) { printf("Dynamic Paint: Invalid cache version: '%c%c%c%c'!\n", UNPACK4(version)); return 0; } @@ -1716,7 +1716,7 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) if (fread(bphysics, sizeof(char), 8, pf->fp) != 8) error = 1; - if (!error && strncmp(bphysics, "BPHYSICS", 8)) + if (!error && !STREQLEN(bphysics, "BPHYSICS", 8)) error = 1; if (!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp)) @@ -2588,7 +2588,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ + if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ if (mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); @@ -2794,7 +2794,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ + if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ /* read the number of the file */ unsigned int frame, len2 = (int)strlen(de->d_name); char num[7]; @@ -2975,7 +2975,7 @@ void BKE_ptcache_remove(void) return; while ((de = readdir(dir)) != NULL) { - if ( strcmp(de->d_name, ".")==0 || strcmp(de->d_name, "..")==0) { + if (STREQ(de->d_name, ".") || STREQ(de->d_name, "..")) { /* do nothing */ } else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/ @@ -3532,7 +3532,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (strncmp(old_filename, de->d_name, len ) == 0) { /* do we have the right prefix */ + if (STREQLEN(old_filename, de->d_name, len)) { /* do we have the right prefix */ /* read the number of the file */ int frame, len2 = (int)strlen(de->d_name); char num[7]; @@ -3587,7 +3587,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ - if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ + if (STREQLEN(filename, de->d_name, len)) { /* do we have the right prefix */ /* read the number of the file */ int frame, len2 = (int)strlen(de->d_name); char num[7]; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index bb04d548a44..819f4af054c 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -136,7 +136,7 @@ static bProperty *bproperty_get(bProperty *first, bProperty *self, const char *n { bProperty *p; for (p = first; p; p = p->next) { - if (p != self && (strcmp(p->name, name) == 0)) + if (p != self && STREQ(p->name, name)) return p; } return NULL; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 577dbd6d323..8f479d4adf9 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -2003,7 +2003,7 @@ void BKE_scene_disable_color_management(Scene *scene) bool BKE_scene_check_color_management_enabled(const Scene *scene) { - return strcmp(scene->display_settings.display_device, "None") != 0; + return !STREQ(scene->display_settings.display_device, "None"); } bool BKE_scene_check_rigidbody_active(const Scene *scene) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 3a311bfb23b..cb2819825c2 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2740,7 +2740,7 @@ void txt_unindent(Text *text) while (true) { bool changed = false; - if (strncmp(text->curl->line, remove, indentlen) == 0) { + if (STREQLEN(text->curl->line, remove, indentlen)) { if (num == 0) unindented_first = true; text->curl->len -= indentlen; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index d580c184a8b..0037002f6d8 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -721,7 +721,7 @@ MovieTrackingTrack *BKE_tracking_track_get_named(MovieTracking *tracking, MovieT MovieTrackingTrack *track = tracksbase->first; while (track) { - if (!strcmp(track->name, name)) + if (STREQ(track->name, name)) return track; track = track->next; @@ -1267,7 +1267,7 @@ MovieTrackingPlaneTrack *BKE_tracking_plane_track_get_named(MovieTracking *track plane_track; plane_track = plane_track->next) { - if (!strcmp(plane_track->name, name)) { + if (STREQ(plane_track->name, name)) { return plane_track; } } @@ -1563,7 +1563,7 @@ MovieTrackingObject *BKE_tracking_object_get_named(MovieTracking *tracking, cons MovieTrackingObject *object = tracking->objects.first; while (object) { - if (!strcmp(object->name, name)) + if (STREQ(object->name, name)) return object; object = object->next; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 9737ef429cb..128a5da9b68 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -469,8 +469,8 @@ static int ffmpeg_proprty_valid(AVCodecContext *c, const char *prop_name, IDProp { int valid = 1; - if (strcmp(prop_name, "video") == 0) { - if (strcmp(curr->name, "bf") == 0) { + if (STREQ(prop_name, "video")) { + if (STREQ(curr->name, "bf")) { /* flash codec doesn't support b frames */ valid &= c->codec_id != AV_CODEC_ID_FLV1; } @@ -624,9 +624,9 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex if ((of->oformat->flags & AVFMT_GLOBALHEADER) #if 0 - || !strcmp(of->oformat->name, "mp4") - || !strcmp(of->oformat->name, "mov") - || !strcmp(of->oformat->name, "3gp") + || STREQ(of->oformat->name, "mp4") + || STREQ(of->oformat->name, "mov") + || STREQ(of->oformat->name, "3gp") #endif ) { diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 746b99ffb52..ae6b19fb019 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -214,7 +214,7 @@ static int handle_request(RenderData *rd, char *req) *p = 0; - if (strcmp(path, "/index.html") == 0 || strcmp(path, "/") == 0) { + if (STREQ(path, "/index.html") || STREQ(path, "/")) { safe_puts(index_page); return -1; } @@ -226,7 +226,7 @@ static int handle_request(RenderData *rd, char *req) write_ppm = 1; return atoi(path + 12); } - if (strcmp(path, "/info.txt") == 0) { + if (STREQ(path, "/info.txt")) { char buf[4096]; sprintf(buf, @@ -250,7 +250,7 @@ static int handle_request(RenderData *rd, char *req) safe_puts(buf); return -1; } - if (strcmp(path, "/close.txt") == 0) { + if (STREQ(path, "/close.txt")) { safe_puts(good_bye); G.is_break = true; /* Abort render */ return -1; diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c index 49a3c466727..9faf6c93447 100644 --- a/source/blender/blenlib/intern/BLI_args.c +++ b/source/blender/blenlib/intern/BLI_args.c @@ -100,7 +100,7 @@ static bool keycmp(const void *a, const void *b) return (BLI_strcasecmp(ka->arg, kb->arg) != 0); } else { - return (strcmp(ka->arg, kb->arg) != 0); + return (!STREQ(ka->arg, kb->arg)); } } else { diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index c87b60f08db..5360ea744a1 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -771,7 +771,7 @@ unsigned int BLI_ghashutil_strhash_p(const void *ptr) } bool BLI_ghashutil_strcmp(const void *a, const void *b) { - return (strcmp(a, b) != 0); + return (!STREQ(a, b)); } GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second) diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 62e1b6e4cbf..8ae99c0da97 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -584,7 +584,7 @@ static int recursive_operation(const char *startfrom, const char *startto, for (i = 0; i < n; i++) { const struct dirent * const dirent = dirlist[i]; - if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) + if (STREQ(dirent->d_name, ".") || STREQ(dirent->d_name, "..")) continue; join_dirfile_alloc(&from_path, &from_alloc_len, from, dirent->d_name); diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index bd3e1e0bbb0..d52c09790f9 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -474,7 +474,7 @@ void *BLI_findstring(const ListBase *listbase, const char *id, const int offset) for (link = listbase->first; link; link = link->next) { id_iter = ((const char *)link) + offset; - if (id[0] == id_iter[0] && strcmp(id, id_iter) == 0) { + if (id[0] == id_iter[0] && STREQ(id, id_iter)) { return link; } } @@ -494,7 +494,7 @@ void *BLI_rfindstring(const ListBase *listbase, const char *id, const int offset for (link = listbase->last; link; link = link->prev) { id_iter = ((const char *)link) + offset; - if (id[0] == id_iter[0] && strcmp(id, id_iter) == 0) { + if (id[0] == id_iter[0] && STREQ(id, id_iter)) { return link; } } @@ -515,7 +515,7 @@ void *BLI_findstring_ptr(const ListBase *listbase, const char *id, const int off /* exact copy of BLI_findstring(), except for this line */ id_iter = *((const char **)(((const char *)link) + offset)); - if (id[0] == id_iter[0] && strcmp(id, id_iter) == 0) { + if (id[0] == id_iter[0] && STREQ(id, id_iter)) { return link; } } @@ -536,7 +536,7 @@ void *BLI_rfindstring_ptr(const ListBase *listbase, const char *id, const int of /* exact copy of BLI_rfindstring(), except for this line */ id_iter = *((const char **)(((const char *)link) + offset)); - if (id[0] == id_iter[0] && strcmp(id, id_iter) == 0) { + if (id[0] == id_iter[0] && STREQ(id, id_iter)) { return link; } } @@ -600,7 +600,7 @@ int BLI_findstringindex(const ListBase *listbase, const char *id, const int offs while (link) { id_iter = ((const char *)link) + offset; - if (id[0] == id_iter[0] && strcmp(id, id_iter) == 0) + if (id[0] == id_iter[0] && STREQ(id, id_iter)) return i; i++; link = link->next; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 35398939ab7..0cc7524bfb5 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -1369,9 +1369,7 @@ bool BLI_ensure_extension(char *path, size_t maxlen, const char *ext) ssize_t a; /* first check the extension is already there */ - if ( (ext_len <= path_len) && - (strcmp(path + (path_len - ext_len), ext) == 0)) - { + if ((ext_len <= path_len) && (STREQ(path + (path_len - ext_len), ext))) { return true; } diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 4c5268562ad..0d09b50a52c 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -135,10 +135,10 @@ static int bli_compare(struct direntry *entry1, struct direntry *entry2) /* OK, now we know their S_IFMT fields are the same, go on to a name comparison */ /* make sure "." and ".." are always first */ - if (strcmp(entry1->relname, ".") == 0) return (-1); - if (strcmp(entry2->relname, ".") == 0) return (1); - if (strcmp(entry1->relname, "..") == 0) return (-1); - if (strcmp(entry2->relname, "..") == 0) return (1); + if (STREQ(entry1->relname, ".")) return (-1); + if (STREQ(entry2->relname, ".")) return (1); + if (STREQ(entry1->relname, "..")) return (-1); + if (STREQ(entry2->relname, "..")) return (1); return (BLI_natstrcmp(entry1->relname, entry2->relname)); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5893c2275be..34ad6d3ea61 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -777,7 +777,7 @@ static void decode_blender_header(FileData *fd) readsize = fd->read(fd, header, sizeof(header)); if (readsize == sizeof(header)) { - if (strncmp(header, "BLENDER", 7) == 0) { + if (STREQLEN(header, "BLENDER", 7)) { int remove_this_endian_test = 1; fd->flags |= FD_FLAGS_FILE_OK; @@ -1182,7 +1182,7 @@ bool BLO_is_a_library(const char *path, char *dir, char *group) /* now we know that we are in a blend file and it is safe to * assume that gp actually points to a group */ - if (strcmp("Screen", gp) != 0) + if (!STREQ("Screen", gp)) BLI_strncpy(group, gp, BLO_GROUP_MAX); } return 1; @@ -6011,7 +6011,7 @@ typedef enum ePointerUserMode { static bool restore_pointer(ID *id, ID *newid, ePointerUserMode user) { - if (strcmp(newid->name + 2, id->name + 2) == 0) { + if (STREQ(newid->name + 2, id->name + 2)) { if (newid->lib == id->lib) { if (user == USER_ONE) { if (newid->us == 0) { @@ -9099,7 +9099,7 @@ static ID *append_named_part(Main *mainl, FileData *fd, const char *idname, cons if (bhead->code == idcode) { const char *idname_test= bhead_id_name(fd, bhead); - if (strcmp(idname_test + 2, idname) == 0) { + if (STREQ(idname_test + 2, idname)) { found = 1; id = is_yet_read(fd, mainl, bhead); if (id == NULL) { @@ -9220,7 +9220,7 @@ static void append_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id) for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) { if (bhead->code == GS(id->name)) { - if (strcmp(id->name, bhead_id_name(fd, bhead))==0) { + if (STREQ(id->name, bhead_id_name(fd, bhead))) { id->flag &= ~LIB_READ; id->flag |= LIB_NEED_EXPAND; // printf("read lib block %s\n", id->name); diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index a28ca7d187a..5dae6fbc464 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1299,7 +1299,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Object *ob; for (vf = main->vfont.first; vf; vf = vf->id.next) { - if (strcmp(vf->name + strlen(vf->name)-6, ".Bfont") == 0) { + if (STREQ(vf->name + strlen(vf->name)-6, ".Bfont")) { strcpy(vf->name, FO_BUILTIN_NAME); } } @@ -2314,7 +2314,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile == 241) { Image *ima; for (ima = main->image.first; ima; ima = ima->id.next) - if (strcmp(ima->name, "Compositor") == 0) { + if (STREQ(ima->name, "Compositor")) { strcpy(ima->id.name + 2, "Viewer Node"); strcpy(ima->name, "Viewer Node"); } @@ -2502,11 +2502,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ima->gen_x = 256; ima->gen_y = 256; ima->gen_type = 1; - if (0 == strncmp(ima->id.name + 2, "Viewer Node", sizeof(ima->id.name) - 2)) { + if (STREQLEN(ima->id.name + 2, "Viewer Node", sizeof(ima->id.name) - 2)) { ima->source = IMA_SRC_VIEWER; ima->type = IMA_TYPE_COMPOSITE; } - if (0 == strncmp(ima->id.name + 2, "Render Result", sizeof(ima->id.name) - 2)) { + if (STREQLEN(ima->id.name + 2, "Render Result", sizeof(ima->id.name) - 2)) { ima->source = IMA_SRC_VIEWER; ima->type = IMA_TYPE_R_RESULT; } diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index f2c057d32d8..9077db524db 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -76,9 +76,9 @@ void AnimationExporter::operator()(Object *ob) else transformName = extract_transform_name(fcu->rna_path); - if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || - (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) || - (!strcmp(transformName, "rotation_quaternion"))) + if ((STREQ(transformName, "location") || STREQ(transformName, "scale")) || + (STREQ(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) || + (STREQ(transformName, "rotation_quaternion"))) { dae_animation(ob, fcu, transformName, false); } @@ -98,8 +98,8 @@ void AnimationExporter::operator()(Object *ob) while (fcu) { transformName = extract_transform_name(fcu->rna_path); - if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size")) || - (!strcmp(transformName, "spot_blend")) || (!strcmp(transformName, "distance"))) + if ((STREQ(transformName, "color")) || (STREQ(transformName, "spot_size")) || + (STREQ(transformName, "spot_blend")) || (STREQ(transformName, "distance"))) { dae_animation(ob, fcu, transformName, true); } @@ -113,10 +113,10 @@ void AnimationExporter::operator()(Object *ob) while (fcu) { transformName = extract_transform_name(fcu->rna_path); - if ((!strcmp(transformName, "lens")) || - (!strcmp(transformName, "ortho_scale")) || - (!strcmp(transformName, "clip_end")) || - (!strcmp(transformName, "clip_start"))) + if ((STREQ(transformName, "lens")) || + (STREQ(transformName, "ortho_scale")) || + (STREQ(transformName, "clip_end")) || + (STREQ(transformName, "clip_start"))) { dae_animation(ob, fcu, transformName, true); } @@ -134,9 +134,9 @@ void AnimationExporter::operator()(Object *ob) while (fcu) { transformName = extract_transform_name(fcu->rna_path); - if ((!strcmp(transformName, "specular_hardness")) || (!strcmp(transformName, "specular_color")) || - (!strcmp(transformName, "diffuse_color")) || (!strcmp(transformName, "alpha")) || - (!strcmp(transformName, "ior"))) + if ((STREQ(transformName, "specular_hardness")) || (STREQ(transformName, "specular_color")) || + (STREQ(transformName, "diffuse_color")) || (STREQ(transformName, "alpha")) || + (STREQ(transformName, "ior"))) { dae_animation(ob, fcu, transformName, true, ma); } @@ -225,7 +225,7 @@ float *AnimationExporter::get_eul_source_for_quat(Object *ob) while (fcu) { char *transformName = extract_transform_name(fcu->rna_path); - if (!strcmp(transformName, "rotation_quaternion") ) { + if (STREQ(transformName, "rotation_quaternion") ) { for (int i = 0; i < fcu->totvert; i++) { *(quat + (i * 4) + fcu->array_index) = fcu->bezt[i].vec[1][1]; } @@ -278,17 +278,17 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa bool has_tangents = false; bool quatRotation = false; - if (!strcmp(transformName, "rotation_quaternion") ) { + if (STREQ(transformName, "rotation_quaternion") ) { fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); quatRotation = true; return; } //axis names for colors - else if (!strcmp(transformName, "color") || - !strcmp(transformName, "specular_color") || - !strcmp(transformName, "diffuse_color") || - !strcmp(transformName, "alpha")) + else if (STREQ(transformName, "color") || + STREQ(transformName, "specular_color") || + STREQ(transformName, "diffuse_color") || + STREQ(transformName, "alpha")) { const char *axis_names[] = {"R", "G", "B"}; if (fcu->array_index < 3) @@ -296,10 +296,10 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa } //axis names for transforms - else if (!strcmp(transformName, "location") || - !strcmp(transformName, "scale") || - !strcmp(transformName, "rotation_euler") || - !strcmp(transformName, "rotation_quaternion")) + else if (STREQ(transformName, "location") || + STREQ(transformName, "scale") || + STREQ(transformName, "rotation_euler") || + STREQ(transformName, "rotation_quaternion")) { const char *axis_names[] = {"X", "Y", "Z"}; if (fcu->array_index < 3) @@ -357,7 +357,7 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa MEM_freeN(eul); MEM_freeN(eul_axis); } - else if (!strcmp(transformName, "lens") && (ob->type == OB_CAMERA)) { + else if (STREQ(transformName, "lens") && (ob->type == OB_CAMERA)) { output_id = create_lens_source_from_fcurve((Camera *) ob->data, COLLADASW::InputSemantic::OUTPUT, fcu, anim_id); } else { @@ -763,7 +763,7 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti { std::string source_id = anim_id + get_semantic_suffix(semantic); - //bool is_angle = !strcmp(fcu->rna_path, "rotation"); + //bool is_angle = STREQ(fcu->rna_path, "rotation"); bool is_angle = false; if (strstr(fcu->rna_path, "rotation") || strstr(fcu->rna_path,"spot_size")) is_angle = true; @@ -1103,13 +1103,13 @@ std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, if (rna_path) { char *name = extract_transform_name(rna_path); - if (!strcmp(name, "color")) + if (STREQ(name, "color")) tm_type = 1; - else if (!strcmp(name, "spot_size")) + else if (STREQ(name, "spot_size")) tm_type = 2; - else if (!strcmp(name, "spot_blend")) + else if (STREQ(name, "spot_blend")) tm_type = 3; - else if (!strcmp(name, "distance")) + else if (STREQ(name, "distance")) tm_type = 4; else tm_type = -1; @@ -1151,13 +1151,13 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, if (rna_path) { char *name = extract_transform_name(rna_path); - if (!strcmp(name, "lens")) + if (STREQ(name, "lens")) tm_type = 0; - else if (!strcmp(name, "ortho_scale")) + else if (STREQ(name, "ortho_scale")) tm_type = 1; - else if (!strcmp(name, "clip_end")) + else if (STREQ(name, "clip_end")) tm_type = 2; - else if (!strcmp(name, "clip_start")) + else if (STREQ(name, "clip_start")) tm_type = 3; else @@ -1203,23 +1203,23 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co if (rna_path) { char *name = extract_transform_name(rna_path); - if (!strcmp(name, "rotation_euler")) + if (STREQ(name, "rotation_euler")) tm_type = 0; - else if (!strcmp(name, "rotation_quaternion")) + else if (STREQ(name, "rotation_quaternion")) tm_type = 1; - else if (!strcmp(name, "scale")) + else if (STREQ(name, "scale")) tm_type = 2; - else if (!strcmp(name, "location")) + else if (STREQ(name, "location")) tm_type = 3; - else if (!strcmp(name, "specular_hardness")) + else if (STREQ(name, "specular_hardness")) tm_type = 4; - else if (!strcmp(name, "specular_color")) + else if (STREQ(name, "specular_color")) tm_type = 5; - else if (!strcmp(name, "diffuse_color")) + else if (STREQ(name, "diffuse_color")) tm_type = 6; - else if (!strcmp(name, "alpha")) + else if (STREQ(name, "alpha")) tm_type = 7; - else if (!strcmp(name, "ior")) + else if (STREQ(name, "ior")) tm_type = 8; else @@ -1311,7 +1311,7 @@ void AnimationExporter::enable_fcurves(bAction *act, char *bone_name) for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) { if (bone_name) { - if (!strncmp(fcu->rna_path, prefix, strlen(prefix))) + if (STREQLEN(fcu->rna_path, prefix, strlen(prefix))) fcu->flag &= ~FCURVE_DISABLED; else fcu->flag |= FCURVE_DISABLED; @@ -1378,11 +1378,11 @@ void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const c FCurve *fcu = (FCurve *)ob->adt->action->curves.first; for (; fcu; fcu = fcu->next) { - if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) + if (prefix && !STREQLEN(prefix, fcu->rna_path, strlen(prefix))) continue; char *name = extract_transform_name(fcu->rna_path); - if (!strcmp(name, tm_name)) { + if (STREQ(name, tm_name)) { for (unsigned int i = 0; i < fcu->totvert; i++) { float f = fcu->bezt[i].vec[1][0]; if (std::find(fra.begin(), fra.end(), f) == fra.end()) diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 6e2d337a32e..7e937e42787 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -649,7 +649,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve *fcu = *iter; /* All anim_types whose values are to be converted from Degree to Radians can be ORed here */ - if (strcmp("spot_size", anim_type)==0) { + if (STREQ("spot_size", anim_type)) { /* NOTE: Do NOT convert if imported file was made by blender <= 2.69.10 * Reason: old blender versions stored spot_size in radians (was a bug) */ diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 5ce62873377..36ab85b9b5b 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -181,7 +181,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce, std::list<Object *>::iterator i = child_objects.begin(); while (i != child_objects.end()) { - if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) { + if ((*i)->partype == PARBONE && STREQ((*i)->parsubstr, bone->name)) { float backup_parinv[4][4]; copy_m4_m4(backup_parinv, (*i)->parentinv); diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 7ffd300c6de..c2ee6170470 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -54,7 +54,7 @@ static EditBone *get_edit_bone(bArmature * armature, char *name) { EditBone *eBone; for (eBone = (EditBone *)armature->edbo->first; eBone; eBone = eBone->next) { - if (!strcmp(name, eBone->name)) + if (STREQ(name, eBone->name)) return eBone; } diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp index 854e8abd76d..b271604f839 100644 --- a/source/blender/collada/ErrorHandler.cpp +++ b/source/blender/collada/ErrorHandler.cpp @@ -34,6 +34,8 @@ #include <string.h> +#include "BLI_utildefines.h" + //-------------------------------------------------------------------- ErrorHandler::ErrorHandler() : mError(false) { @@ -55,13 +57,13 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error) // Workaround to avoid wrong error if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) { - if (strcmp(parserError.getElement(), "effect") == 0) { + if (STREQ(parserError.getElement(), "effect")) { isError = false; } } if (parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) { - if (!((strcmp(parserError.getElement(), "extra") == 0) && - (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0))) + if (!(STREQ(parserError.getElement(), "extra") && + STREQ(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract"))) { isError = false; } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 571faf8c2e9..3c6c90068de 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -1061,7 +1061,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri // set texture face if (color_texture && strlen((color_texture)->uvname) && - strcmp(layername, color_texture->uvname) != 0) { + !STREQ(layername, color_texture->uvname)) { texture_face = (MTFace *)CustomData_get_layer_named(&me->fdata, CD_MTFACE, color_texture->uvname); strcpy(layername, color_texture->uvname); diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp index 2ac027ca326..b80ca2fcdbd 100644 --- a/source/blender/compositor/nodes/COM_TextureNode.cpp +++ b/source/blender/compositor/nodes/COM_TextureNode.cpp @@ -35,7 +35,7 @@ void TextureNode::convertToOperations(NodeConverter &converter, const Compositor Tex *texture = (Tex *)editorNode->id; TextureOperation *operation = new TextureOperation(); const ColorManagedDisplaySettings *displaySettings = context.getDisplaySettings(); - bool sceneColorManage = strcmp(displaySettings->display_device, "None") != 0; + bool sceneColorManage = !STREQ(displaySettings->display_device, "None"); operation->setTexture(texture); operation->setRenderData(context.getRenderData()); operation->setSceneColorManage(sceneColorManage); diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 7ac11c1cd06..3784cd5621e 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -663,14 +663,14 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, const short from_ if ((from_single) || (aci->array_index == fcu->array_index)) { char *name = NULL; flip_names(aci, &name); - if (strcmp(name, fcu->rna_path) == 0) { + if (STREQ(name, fcu->rna_path)) { MEM_freeN(name); break; } MEM_freeN(name); } } - else if (to_simple || (strcmp(aci->rna_path, fcu->rna_path) == 0)) { + else if (to_simple || STREQ(aci->rna_path, fcu->rna_path)) { if ((from_single) || (aci->array_index == fcu->array_index)) { break; } @@ -711,7 +711,7 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f int len_path = strlen(fcu->rna_path); if (len_id <= len_path) { /* note, paths which end with "] will fail with this test - Animated ID Props */ - if (strcmp(identifier, fcu->rna_path + (len_path - len_id)) == 0) { + if (STREQ(identifier, fcu->rna_path + (len_path - len_id))) { if ((from_single) || (aci->array_index == fcu->array_index)) break; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 6c2cc10f2a3..4b9a629183e 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -556,7 +556,7 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[] /* loop over KeyingSets checking names */ for (ks = first; ks; ks = ks->next) { - if (strcmp(name, ks->idname) == 0) + if (STREQ(name, ks->idname)) return ks; } @@ -603,7 +603,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) ksn = ks->next; /* remove if matching typeinfo name */ - if (strcmp(ks->typeinfo, ksi->idname) == 0) { + if (STREQ(ks->typeinfo, ksi->idname)) { Scene *scene; BKE_keyingset_free(ks); BLI_remlink(&builtin_keyingsets, ks); 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; } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f17c46252c4..51c621cbf19 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -999,7 +999,7 @@ static void fcurve_path_rename(AnimData *adt, const char *orig_rna_path, char *r for (fcu = orig_curves->first; fcu; fcu = nextfcu) { nextfcu = fcu->next; - if (!strncmp(fcu->rna_path, orig_rna_path, len)) { + if (STREQLEN(fcu->rna_path, orig_rna_path, len)) { char *spath, *suffix = fcu->rna_path + len; nfcu = copy_fcurve(fcu); spath = nfcu->rna_path; @@ -1102,10 +1102,10 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) for (fcu = orig_curves->first; fcu; fcu = next) { next = fcu->next; - if (!strncmp(fcu->rna_path, "splines", 7)) { + if (STREQLEN(fcu->rna_path, "splines", 7)) { const char *ch = strchr(fcu->rna_path, '.'); - if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7))) + if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7))) fcurve_remove(adt, orig_curves, fcu); } } @@ -1129,7 +1129,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) for (fcu = orig_curves->first; fcu; fcu = next) { next = fcu->next; - if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(adt, orig_curves, fcu); + if (STREQLEN(fcu->rna_path, "splines", 7)) fcurve_remove(adt, orig_curves, fcu); else BLI_addtail(&curves, fcu); } @@ -6768,7 +6768,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - int clear = (strcmp(op->idname, "CURVE_OT_shade_flat") == 0); + int clear = (STREQ(op->idname, "CURVE_OT_shade_flat")); if (obedit->type != OB_CURVE) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 97adaea41a8..a2ba6216f9c 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -390,7 +390,7 @@ void paste_gpdata(Scene *scene) /* find suitable layer from buffer to use to paste from */ for (gpls = gpcopybuf.first; gpls; gpls = gpls->next) { /* check if layer name matches */ - if ((no_name) || (strcmp(gpls->info, gpld->info) == 0)) + if ((no_name) || STREQ(gpls->info, gpld->info)) break; } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index caa22a4fde2..0f1be590e9c 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -2502,50 +2502,50 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) const bool valid_timing = RNA_boolean_get(ptr, "use_timing_data"); /* Always show those props */ - if (strcmp(prop_id, "type") == 0 || - strcmp(prop_id, "use_normalize_weights") == 0 || - strcmp(prop_id, "radius_multiplier") == 0 || - strcmp(prop_id, "use_link_strokes") == 0) + if (STREQ(prop_id, "type") || + STREQ(prop_id, "use_normalize_weights") || + STREQ(prop_id, "radius_multiplier") || + STREQ(prop_id, "use_link_strokes")) { return true; } /* Never show this prop */ - if (strcmp(prop_id, "use_timing_data") == 0) + if (STREQ(prop_id, "use_timing_data")) return false; if (link_strokes) { /* Only show when link_stroke is true */ - if (strcmp(prop_id, "timing_mode") == 0) + if (STREQ(prop_id, "timing_mode")) return true; if (timing_mode != GP_STROKECONVERT_TIMING_NONE) { /* Only show when link_stroke is true and stroke timing is enabled */ - if (strcmp(prop_id, "frame_range") == 0 || - strcmp(prop_id, "start_frame") == 0) + if (STREQ(prop_id, "frame_range") || + STREQ(prop_id, "start_frame")) { return true; } /* Only show if we have valid timing data! */ - if (valid_timing && strcmp(prop_id, "use_realtime") == 0) + if (valid_timing && STREQ(prop_id, "use_realtime")) return true; /* Only show if realtime or valid_timing is false! */ - if ((!realtime || !valid_timing) && strcmp(prop_id, "end_frame") == 0) + if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame")) return true; if (valid_timing && timing_mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) { /* Only show for custom gaps! */ - if (strcmp(prop_id, "gap_duration") == 0) + if (STREQ(prop_id, "gap_duration")) return true; /* Only show randomness for non-null custom gaps! */ - if (strcmp(prop_id, "gap_randomness") == 0 && (gap_duration > 0.0f)) + if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f)) return true; /* Only show seed for randomize action! */ - if (strcmp(prop_id, "seed") == 0 && (gap_duration > 0.0f) && (gap_randomness > 0.0f)) + if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f)) return true; } } diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 5f0647fb43d..34e640a4b7b 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -76,7 +76,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) if (step == 1) { /* undo */ //printf("\t\tGP - undo step\n"); if (cur_node->prev) { - if (!name || strcmp(cur_node->name, name) == 0) { + if (!name || STREQ(cur_node->name, name)) { cur_node = cur_node->prev; new_gpd = cur_node->gpd; } @@ -85,7 +85,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) else if (step == -1) { //printf("\t\tGP - redo step\n"); if (cur_node->next) { - if (!name || strcmp(cur_node->name, name) == 0) { + if (!name || STREQ(cur_node->name, name)) { cur_node = cur_node->next; new_gpd = cur_node->gpd; } diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 0b1d1c8c30c..8fa604d57cb 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -297,7 +297,7 @@ void ui_block_bounds_calc(uiBlock *block) /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; - if (bt && strncmp(bt->str, "ERROR", 5) == 0) xof = 10; + if (bt && STREQLEN(bt->str, "ERROR", 5)) xof = 10; else xof = 40; block->safety.xmin = block->rect.xmin - xof; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 074faaa86bc..9bd09b571db 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -515,7 +515,7 @@ static bool ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) && (but_a->unit_type == but_b->unit_type) && - (strncmp(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR) == 0)) + STREQLEN(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR)) { return true; } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 21e7b8eef97..b6a93c8306d 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1919,7 +1919,7 @@ static void ui_update_color_picker_buts_rgb(uiBlock *block, ColorPicker *cpicker ui_but_v3_set(bt, rgb); } - else if (strcmp(bt->str, "Hex: ") == 0) { + else if (STREQ(bt->str, "Hex: ")) { float rgb_gamma[3]; unsigned char rgb_gamma_uchar[3]; double intpart; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 407843d663c..56ab27821d7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2862,7 +2862,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co /* validate arguments */ /* Forbid default UI_UL_DEFAULT_CLASS_NAME list class without a custom list_id! */ - if (!strcmp(UI_UL_DEFAULT_CLASS_NAME, listtype_name) && !(list_id && list_id[0])) { + if (STREQ(UI_UL_DEFAULT_CLASS_NAME, listtype_name) && !(list_id && list_id[0])) { RNA_warning("template_list using default '%s' UIList class must provide a custom list_id", UI_UL_DEFAULT_CLASS_NAME); return; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index aa5b2570952..fb174e113b1 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1574,7 +1574,7 @@ void init_userdef_do_versions(void) U.tb_rightmouse = 5; } if (U.mixbufsize == 0) U.mixbufsize = 2048; - if (strcmp(U.tempdir, "/") == 0) { + if (STREQ(U.tempdir, "/")) { BKE_tempdir_system_init(U.tempdir); } if (U.autokey_mode == 0) { @@ -1907,39 +1907,39 @@ void init_userdef_do_versions(void) wmKeyMap *km; for (km = U.user_keymaps.first; km; km = km->next) { - if (strcmp(km->idname, "Armature_Sketch") == 0) + if (STREQ(km->idname, "Armature_Sketch")) strcpy(km->idname, "Armature Sketch"); - else if (strcmp(km->idname, "View3D") == 0) + else if (STREQ(km->idname, "View3D")) strcpy(km->idname, "3D View"); - else if (strcmp(km->idname, "View3D Generic") == 0) + else if (STREQ(km->idname, "View3D Generic")) strcpy(km->idname, "3D View Generic"); - else if (strcmp(km->idname, "EditMesh") == 0) + else if (STREQ(km->idname, "EditMesh")) strcpy(km->idname, "Mesh"); - else if (strcmp(km->idname, "TimeLine") == 0) + else if (STREQ(km->idname, "TimeLine")) strcpy(km->idname, "Timeline"); - else if (strcmp(km->idname, "UVEdit") == 0) + else if (STREQ(km->idname, "UVEdit")) strcpy(km->idname, "UV Editor"); - else if (strcmp(km->idname, "Animation_Channels") == 0) + else if (STREQ(km->idname, "Animation_Channels")) strcpy(km->idname, "Animation Channels"); - else if (strcmp(km->idname, "GraphEdit Keys") == 0) + else if (STREQ(km->idname, "GraphEdit Keys")) strcpy(km->idname, "Graph Editor"); - else if (strcmp(km->idname, "GraphEdit Generic") == 0) + else if (STREQ(km->idname, "GraphEdit Generic")) strcpy(km->idname, "Graph Editor Generic"); - else if (strcmp(km->idname, "Action_Keys") == 0) + else if (STREQ(km->idname, "Action_Keys")) strcpy(km->idname, "Dopesheet"); - else if (strcmp(km->idname, "NLA Data") == 0) + else if (STREQ(km->idname, "NLA Data")) strcpy(km->idname, "NLA Editor"); - else if (strcmp(km->idname, "Node Generic") == 0) + else if (STREQ(km->idname, "Node Generic")) strcpy(km->idname, "Node Editor"); - else if (strcmp(km->idname, "Logic Generic") == 0) + else if (STREQ(km->idname, "Logic Generic")) strcpy(km->idname, "Logic Editor"); - else if (strcmp(km->idname, "File") == 0) + else if (STREQ(km->idname, "File")) strcpy(km->idname, "File Browser"); - else if (strcmp(km->idname, "FileMain") == 0) + else if (STREQ(km->idname, "FileMain")) strcpy(km->idname, "File Browser Main"); - else if (strcmp(km->idname, "FileButtons") == 0) + else if (STREQ(km->idname, "FileButtons")) strcpy(km->idname, "File Browser Buttons"); - else if (strcmp(km->idname, "Buttons Generic") == 0) + else if (STREQ(km->idname, "Buttons Generic")) strcpy(km->idname, "Property Editor"); } } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 19040062fda..dee216d9c73 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -329,7 +329,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) if (odg) { /* Search for a match in the new object, and set new index */ for (dg = ob->defbase.first, index = 0; dg; dg = dg->next, index++) { - if (!strcmp(dg->name, odg->name)) { + if (STREQ(dg->name, odg->name)) { dvert[i].dw[j].def_nr = index; break; } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 2596ea0a064..8f793f7f7f9 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -471,7 +471,7 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) /* TODO: clear subtarget? */ curcon->flag |= CONSTRAINT_DISABLE; } - else if (strcmp(pchan->name, ct->subtarget) == 0) { + else if (STREQ(pchan->name, ct->subtarget)) { /* cannot target self */ ct->subtarget[0] = '\0'; curcon->flag |= CONSTRAINT_DISABLE; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 93956128b84..62c27d8922d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1347,7 +1347,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) ID *data; Curve *cu; Nurb *nu; - int clear = (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0); + int clear = (STREQ(op->idname, "OBJECT_OT_shade_flat")); bool done = false, linked_data = false; CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 16874bd49dc..99edaff759e 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -359,7 +359,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre for (base = sce->base.first; base; base = base->next) { if (base->object->type == OB_LAMP) { /* if doesn't match 'Lamp.002' --> main key light */ - if (strcmp(base->object->id.name + 2, "Lamp.002") != 0) { + if (!STREQ(base->object->id.name + 2, "Lamp.002")) { if (mat->material_type == MA_TYPE_VOLUME) base->object->restrictflag |= OB_RESTRICT_RENDER; else diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 1f5ee708ad0..439c2a639bd 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -108,7 +108,7 @@ static void paintcurve_undo_restore(bContext *C, ListBase *lb) uc = (UndoCurve *)lb->first; - if (strncmp(uc->idname, pc->id.name, BLI_strnlen(uc->idname, sizeof(uc->idname))) == 0) { + if (STREQLEN(uc->idname, pc->id.name, BLI_strnlen(uc->idname, sizeof(uc->idname)))) { SWAP(PaintCurvePoint *, pc->points, uc->points); SWAP(int, pc->tot_points, uc->tot_points); SWAP(int, pc->add_index, uc->active_point); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index df38117f376..5cfbd164153 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -193,7 +193,7 @@ void *image_undo_find_tile(Image *ima, ImBuf *ibuf, int x_tile, int y_tile, unsi for (tile = lb->first; tile; tile = tile->next) { if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) { if (tile->use_float == use_float) { - if (strcmp(tile->idname, ima->id.name) == 0 && strcmp(tile->ibufname, ibuf->name) == 0) { + if (STREQ(tile->idname, ima->id.name) && STREQ(tile->ibufname, ibuf->name)) { if (mask) { /* allocate mask if requested */ if (!tile->mask) { @@ -328,7 +328,7 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) short use_float; /* find image based on name, pointer becomes invalid with global undo */ - if (ima && strcmp(tile->idname, ima->id.name) == 0) { + if (ima && STREQ(tile->idname, ima->id.name)) { /* ima is valid */ } else { @@ -337,7 +337,7 @@ void ED_image_undo_restore(bContext *C, ListBase *lb) ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); - if (ima && ibuf && strcmp(tile->ibufname, ibuf->name) != 0) { + if (ima && ibuf && !STREQ(tile->ibufname, ibuf->name)) { /* current ImBuf filename was changed, probably current frame * was changed when painting on image sequence, rather than storing * full image user (which isn't so obvious, btw) try to find ImBuf with diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index 20e3155c01d..0293a0bfc00 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -210,7 +210,7 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * /* pass */ } else { - if (!name || strcmp(stack->current->name, name) == 0) { + if (!name || STREQ(stack->current->name, name)) { if (G.debug & G_DEBUG_WM) { printf("%s: undo '%s'\n", __func__, stack->current->name); } @@ -225,7 +225,7 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * /* pass */ } else { - if (!name || strcmp(stack->current->name, name) == 0) { + if (!name || STREQ(stack->current->name, name)) { undo = (stack->current && stack->current->next) ? stack->current->next : stack->elems.first; undo_restore(C, stack, undo); stack->current = undo; @@ -394,7 +394,7 @@ int ED_undo_paint_valid(int type, const char *name) /* pass */ } else { - if (name && strcmp(stack->current->name, name) == 0) + if (name && STREQ(stack->current->name, name)) return 1; else return stack->elems.first != stack->elems.last; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 4e9d23d3d97..a4adbc6bca8 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -104,7 +104,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo if (unode->maxvert) { /* regular mesh restore */ - if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) { + if (ss->kb && !STREQ(ss->kb->name, unode->shapeName)) { /* shape key has been changed before calling undo operator */ Key *key = BKE_key_from_object(ob); @@ -404,7 +404,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) bool need_mask = false; for (unode = lb->first; unode; unode = unode->next) { - if (strcmp(unode->idname, ob->id.name) == 0) { + if (STREQ(unode->idname, ob->id.name)) { if (unode->type == SCULPT_UNDO_MASK) { /* is possible that we can't do the mask undo (below) * because of the vertex count */ @@ -423,7 +423,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) return; for (unode = lb->first; unode; unode = unode->next) { - if (!(strcmp(unode->idname, ob->id.name) == 0)) + if (!STREQ(unode->idname, ob->id.name)) continue; /* check if undo data matches current data well enough to @@ -550,7 +550,7 @@ static bool sculpt_undo_cleanup(bContext *C, ListBase *lb) unode = lb->first; - if (unode && strcmp(unode->idname, ob->id.name) != 0) { + if (unode && !STREQ(unode->idname, ob->id.name)) { if (unode->bm_entry) BM_log_cleanup_entry(unode->bm_entry); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index d9f4b97fe09..5ce3517696e 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -399,7 +399,7 @@ static bool sound_mixdown_check(bContext *UNUSED(C), wmOperator *op) if (item->value == container) { const char **ext = snd_ext_sound; while (*ext != NULL) { - if (!strcmp(*ext + 1, item->name)) { + if (STREQ(*ext + 1, item->name)) { extension = *ext; break; } @@ -449,9 +449,9 @@ static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *even static bool sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); - return !(strcmp(prop_id, "filepath") == 0 || - strcmp(prop_id, "directory") == 0 || - strcmp(prop_id, "filename") == 0); + return !(STREQ(prop_id, "filepath") || + STREQ(prop_id, "directory") || + STREQ(prop_id, "filename")); } static void sound_mixdown_draw(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index a67af289f59..a263f22e072 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -559,7 +559,7 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS char name[UI_MAX_NAME_STR]; /* add label per category */ - if (!last_category || strcmp(last_category, user->category) != 0) { + if (!last_category || !STREQ(last_category, user->category)) { uiItemL(layout, user->category, ICON_NONE); but = block->buttons.last; but->drawflag = UI_BUT_TEXT_LEFT; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 2d5e5c6e0f2..8263268898f 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -107,7 +107,7 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons if (cl == cl_ignore) continue; - if (strcmp(str, cl->line) == 0) + if (STREQ(str, cl->line)) return cl; } @@ -722,7 +722,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) if (ci->prev) { ConsoleLine *ci_prev = (ConsoleLine *)ci->prev; - if (strcmp(ci->line, ci_prev->line) == 0) + if (STREQ(ci->line, ci_prev->line)) console_history_free(sc, ci_prev); } @@ -791,7 +791,7 @@ static int console_history_append_exec(bContext *C, wmOperator *op) while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); - if (strcmp(str, ci->line) == 0) { + if (STREQ(str, ci->line)) { MEM_freeN(str); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index a2e8eeaa058..836e1f80765 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -239,7 +239,7 @@ static void draw_tile(int sx, int sy, int width, int height, int colorid, int sh static int get_file_icon(struct direntry *file) { if (file->type & S_IFDIR) { - if (strcmp(file->relname, "..") == 0) { + if (STREQ(file->relname, "..")) { return ICON_FILE_PARENT; } if (file->flags & FILE_TYPE_APPLICATIONBUNDLE) { @@ -403,7 +403,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); - if (strcmp(orgname, newname) != 0) { + if (!STREQ(orgname, newname)) { if (!BLI_exists(newname)) { BLI_rename(orgname, newname); /* to make sure we show what is on disk */ diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 3a579820106..697ac23c84d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -183,11 +183,11 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) retval = FILE_SELECT_DIR; } /* the path is too long and we are not going up! */ - else if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { + else if (!STREQ(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { // XXX error("Path too long, cannot enter this directory"); } else { - if (strcmp(file->relname, "..") == 0) { + if (STREQ(file->relname, "..")) { /* avoids /../../ */ BLI_parent_dir(params->dir); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index bcef0817ffe..bf9c6626706 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -304,10 +304,10 @@ static int compare_direntry_generic(const struct direntry *entry1, const struct if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if (strcmp(entry1->relname, ".") == 0) return (-1); - if (strcmp(entry2->relname, ".") == 0) return (1); - if (strcmp(entry1->relname, "..") == 0) return (-1); - if (strcmp(entry2->relname, "..") == 0) return (1); + if (STREQ(entry1->relname, ".")) return (-1); + if (STREQ(entry2->relname, ".")) return (1); + if (STREQ(entry1->relname, "..")) return (-1); + if (STREQ(entry2->relname, "..")) return (1); return 0; } @@ -634,10 +634,10 @@ ImBuf *filelist_geticon(struct FileList *filelist, const int index) fidx = filelist->fidx[index]; file = &filelist->filelist[fidx]; if (file->type & S_IFDIR) { - if (strcmp(filelist->filelist[fidx].relname, "..") == 0) { + if (STREQ(filelist->filelist[fidx].relname, "..")) { ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT]; } - else if (strcmp(filelist->filelist[fidx].relname, ".") == 0) { + else if (STREQ(filelist->filelist[fidx].relname, ".")) { ibuf = gSpecialFileImages[SPECIAL_IMG_REFRESH]; } else { @@ -773,7 +773,8 @@ int filelist_find(struct FileList *filelist, const char *filename) for (i = 0; i < filelist->numfiles; ++i) { - if (strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ + /* not dealing with user input so don't need BLI_path_cmp */ + if (STREQ(filelist->filelist[i].relname, filename)) { index = i; break; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 3e663275dcd..815faa1c223 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -669,7 +669,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) AutoComplete *autocpl = UI_autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { - if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { + if (STREQ(de->d_name, ".") || STREQ(de->d_name, "..")) { /* pass */ } else { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 4ab9bc6a849..05dfdf66ab6 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -283,10 +283,10 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename) if (!fp) return; while (fgets(line, sizeof(line), fp) != NULL) { /* read a line */ - if (strncmp(line, "[Bookmarks]", 11) == 0) { + if (STREQLEN(line, "[Bookmarks]", 11)) { category = FS_CATEGORY_BOOKMARKS; } - else if (strncmp(line, "[Recent]", 8) == 0) { + else if (STREQLEN(line, "[Recent]", 8)) { category = FS_CATEGORY_RECENT; } else { @@ -359,7 +359,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) continue; FSRefMakePath(&dir, path, FILE_MAX); - if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) { + if (!STREQ((char *)path, "/home") && !STREQ((char *)path, "/net")) { /* /net and /home are meaningless on OSX, home folders are stored in /Users */ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); } @@ -488,7 +488,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) else { while ((mnt = getmntent(fp))) { /* not sure if this is right, but seems to give the relevant mnts */ - if (strncmp(mnt->mnt_fsname, "/dev", 4)) + if (!STREQLEN(mnt->mnt_fsname, "/dev", 4)) continue; len = strlen(mnt->mnt_dir); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index b87f80c4e62..2944901663b 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1721,7 +1721,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) * so if the paths or the ID's don't match up, then a curve needs to be added * to a new group */ - if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path) == 0)) { + if ((euf) && (euf->id == ale->id) && (STREQ(euf->rna_path, fcu->rna_path))) { /* this should be fine to add to the existing group then */ euf->fcurves[fcu->array_index] = fcu; } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 21a9246d7e6..9e87fe02da1 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -166,7 +166,7 @@ void make_unique_prop_names(bContext *C, char *str) /* now we check for double names, and change them */ for (nr=0; nr<propcount; nr++) { - if (names[nr]!=str && strcmp( names[nr], str )==0 ) { + if (names[nr] != str && STREQ(names[nr], str)) { BLI_newname(str, +1); } } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1e258368b8b..f79d6e26f22 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -566,7 +566,7 @@ void snode_set_context(const bContext *C) return; } - if (snode->nodetree && strcmp(snode->nodetree->idname, snode->tree_idname) != 0) { + if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) { /* current tree does not match selected type, clear tree path */ ntree = NULL; id = NULL; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 23586a6a509..a98f57fa8ff 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -775,7 +775,7 @@ static eOLDrawState tree_element_active_sequence_dup( continue; } -// if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) +// if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); p = p->next; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index a4b12311fde..c7cd4fa29d1 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1160,7 +1160,7 @@ static int need_add_seq_dup(Sequence *seq) continue; } - if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) return(2); p = p->prev; } @@ -1172,7 +1172,7 @@ static int need_add_seq_dup(Sequence *seq) continue; } - if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) return(0); p = p->next; } @@ -1191,7 +1191,7 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t continue; } - if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) /* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); p = p->next; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 3233c4192b9..6d7e4ad1d8d 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -467,7 +467,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float } } else if (seq->type == SEQ_TYPE_MOVIECLIP) { - if (seq->clip && strcmp(name, seq->clip->id.name + 2) != 0) { + if (seq->clip && !STREQ(name, seq->clip->id.name + 2)) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->clip->id.name + 2, seq->len); } @@ -477,7 +477,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float } } else if (seq->type == SEQ_TYPE_MASK) { - if (seq->mask && strcmp(name, seq->mask->id.name + 2) != 0) { + if (seq->mask && !STREQ(name, seq->mask->id.name + 2)) { str_len = BLI_snprintf(str, sizeof(str), "%s: %s | %d", name, seq->mask->id.name + 2, seq->len); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 81af6dccc70..5f9900d10e3 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -987,13 +987,13 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) // XXX if (0 == sbutton(to, 0, sizeof(to)-1, "To: ")) // return; - if (strcmp(to, from) == 0) + if (STREQ(to, from)) return; SEQP_BEGIN (ed, seq) { if (seq->flag & SELECT) { - if (strncmp(seq->strip->dir, from, strlen(from)) == 0) { + if (STREQLEN(seq->strip->dir, from, strlen(from))) { printf("found %s\n", seq->strip->dir); /* strip off the beginning */ diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 6792bbe0577..4fbe0c6a241 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -996,7 +996,7 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq) if (SEQ_HAS_PATH(actseq) && dir) { SEQP_BEGIN (ed, seq) { - if (SEQ_HAS_PATH(seq) && seq->strip && strcmp(seq->strip->dir, dir) == 0) { + if (SEQ_HAS_PATH(seq) && seq->strip && STREQ(seq->strip->dir, dir)) { seq->flag |= SELECT; changed = true; } diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 99e1606c9bd..19af71c9139 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -183,7 +183,7 @@ static GHash *text_autocomplete_build(Text *text) const int choice_len = i_end - i_start; if ((choice_len > seek_len) && - (seek_len == 0 || strncmp(seek, str_sub, seek_len) == 0) && + (seek_len == 0 || STREQLEN(seek, str_sub, seek_len)) && (seek != str_sub)) { // printf("Adding: %s\n", s); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index bc5c56c3e58..462b619f497 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -549,7 +549,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) full_update |= drawcache->tabnumber != st->tabnumber; /* word-wrapping option was toggled */ full_update |= drawcache->lheight != st->lheight_dpi; /* word-wrapping option was toggled */ full_update |= drawcache->cwidth != st->cwidth; /* word-wrapping option was toggled */ - full_update |= strncmp(drawcache->text_id, txt->id.name, MAX_ID_NAME); /* text datablock was changed */ + full_update |= !STREQLEN(drawcache->text_id, txt->id.name, MAX_ID_NAME); /* text datablock was changed */ if (st->wordwrap) { /* update line heights */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 1185d37f813..ad8050a50e8 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2923,7 +2923,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) if (mode != TEXT_FIND && txt_has_sel(text)) { tmp = txt_sel_to_buf(text); - if (flags & ST_MATCH_CASE) found = strcmp(st->findstr, tmp) == 0; + if (flags & ST_MATCH_CASE) found = STREQ(st->findstr, tmp); else found = BLI_strcasecmp(st->findstr, tmp) == 0; if (found) { diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index f127f375a9f..af24a99a6f2 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -216,7 +216,7 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) CustomTool *ct; for (ct = st->toolshelf.first; ct; ct = ct->next) { - if (0 == strncmp(context, ct->context, OP_MAX_TYPENAME)) { + if (STREQLEN(context, ct->context, OP_MAX_TYPENAME)) { col = uiLayoutColumn(pa->layout, true); uiItemFullO(col, ct->opname, NULL, ICON_NONE, NULL, WM_OP_INVOKE_REGION_WIN, 0); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 9c59ff125dd..cf4f1b02832 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5354,7 +5354,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o /* only if bone name matches too... * NOTE: this will do constraints too, but those are ok to do here too? */ - if (pchanName && strcmp(pchanName, pchan->name) == 0) + if (pchanName && STREQ(pchanName, pchan->name)) insert_keyframe(reports, id, act, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); if (pchanName) MEM_freeN(pchanName); diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 32d4f2e5a15..438eb1f3864 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -231,7 +231,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha BLI_split_file_part(abs_name, fi, sizeof(fi)); BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); - if (strcmp(abs_name, local_name) != 0) { + if (!STREQ(abs_name, local_name)) { switch (checkPackedFile(local_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), IFACE_("Create %s"), local_name); diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 2428ee21367..7f5edb5ea9e 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -206,7 +206,7 @@ static void undo_clean_stack(bContext *C) /* for when objects are converted, renamed, or global undo changes pointers... */ if (uel->type == obedit->type) { - if (strcmp(uel->id.name, obedit->id.name) == 0) { + if (STREQ(uel->id.name, obedit->id.name)) { if (uel->validate_undo == NULL) is_valid = true; else if (uel->validate_undo(uel->undodata, editdata)) @@ -305,7 +305,7 @@ void undo_editmode_name(bContext *C, const char *undoname) UndoElem *uel; for (uel = undobase.last; uel; uel = uel->prev) { - if (strcmp(undoname, uel->name) == 0) + if (STREQ(undoname, uel->name)) break; } if (uel && uel->prev) { @@ -321,7 +321,7 @@ int undo_editmode_valid(const char *undoname) UndoElem *uel; for (uel = undobase.last; uel; uel = uel->prev) { - if (strcmp(undoname, uel->name) == 0) + if (STREQ(undoname, uel->name)) break; } return uel != NULL; diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index f4ead300d5e..487a473b7bd 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -87,24 +87,24 @@ static PyObject *Freestyle_getCurrentScene(PyObject *self) static int ramp_blend_type(const char *type) { - if (!strcmp(type, "MIX")) return MA_RAMP_BLEND; - if (!strcmp(type, "ADD")) return MA_RAMP_ADD; - if (!strcmp(type, "MULTIPLY")) return MA_RAMP_MULT; - if (!strcmp(type, "SUBTRACT")) return MA_RAMP_SUB; - if (!strcmp(type, "SCREEN")) return MA_RAMP_SCREEN; - if (!strcmp(type, "DIVIDE")) return MA_RAMP_DIV; - if (!strcmp(type, "DIFFERENCE")) return MA_RAMP_DIFF; - if (!strcmp(type, "DARKEN")) return MA_RAMP_DARK; - if (!strcmp(type, "LIGHTEN")) return MA_RAMP_LIGHT; - if (!strcmp(type, "OVERLAY")) return MA_RAMP_OVERLAY; - if (!strcmp(type, "DODGE")) return MA_RAMP_DODGE; - if (!strcmp(type, "BURN")) return MA_RAMP_BURN; - if (!strcmp(type, "HUE")) return MA_RAMP_HUE; - if (!strcmp(type, "SATURATION")) return MA_RAMP_SAT; - if (!strcmp(type, "VALUE")) return MA_RAMP_VAL; - if (!strcmp(type, "COLOR")) return MA_RAMP_COLOR; - if (!strcmp(type, "SOFT_LIGHT")) return MA_RAMP_SOFT; - if (!strcmp(type, "LINEAR_LIGHT")) return MA_RAMP_LINEAR; + if (STREQ(type, "MIX")) return MA_RAMP_BLEND; + if (STREQ(type, "ADD")) return MA_RAMP_ADD; + if (STREQ(type, "MULTIPLY")) return MA_RAMP_MULT; + if (STREQ(type, "SUBTRACT")) return MA_RAMP_SUB; + if (STREQ(type, "SCREEN")) return MA_RAMP_SCREEN; + if (STREQ(type, "DIVIDE")) return MA_RAMP_DIV; + if (STREQ(type, "DIFFERENCE")) return MA_RAMP_DIFF; + if (STREQ(type, "DARKEN")) return MA_RAMP_DARK; + if (STREQ(type, "LIGHTEN")) return MA_RAMP_LIGHT; + if (STREQ(type, "OVERLAY")) return MA_RAMP_OVERLAY; + if (STREQ(type, "DODGE")) return MA_RAMP_DODGE; + if (STREQ(type, "BURN")) return MA_RAMP_BURN; + if (STREQ(type, "HUE")) return MA_RAMP_HUE; + if (STREQ(type, "SATURATION")) return MA_RAMP_SAT; + if (STREQ(type, "VALUE")) return MA_RAMP_VAL; + if (STREQ(type, "COLOR")) return MA_RAMP_COLOR; + if (STREQ(type, "SOFT_LIGHT")) return MA_RAMP_SOFT; + if (STREQ(type, "LINEAR_LIGHT")) return MA_RAMP_LINEAR; return -1; } diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 56a753ff768..e77ea32e574 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -915,7 +915,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType outnode = link->output->node; name = outnode->name; - if (strcmp(name, "set_value")==0 || strcmp(name, "set_rgb")==0) { + if (STREQ(name, "set_value") || STREQ(name, "set_rgb")) { input = MEM_dupallocN(outnode->inputs.first); input->type = type; if (input->link) @@ -1109,7 +1109,7 @@ static void gpu_nodes_get_vertex_attributes(ListBase *nodes, GPUVertexAttribs *a if (input->source == GPU_SOURCE_ATTRIB) { for (a=0; a<attribs->totlayer; a++) { if (attribs->layer[a].type == input->attribtype && - strcmp(attribs->layer[a].name, input->attribname) == 0) + STREQ(attribs->layer[a].name, input->attribname)) { break; } @@ -1351,7 +1351,7 @@ int GPU_link_changed(GPUNodeLink *link) node = link->output->node; name = node->name; - if (strcmp(name, "set_value")==0 || strcmp(name, "set_rgb")==0) { + if (STREQ(name, "set_value") || STREQ(name, "set_rgb")) { input = node->inputs.first; return (input->link != NULL); } diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c index e5e22da1524..95e166b2f8b 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -1141,7 +1141,7 @@ void IMB_colormanagement_validate_settings(ColorManagedDisplaySettings *display_ for (view_link = display->views.first; view_link; view_link = view_link->next) { ColorManagedView *view = view_link->data; - if (!strcmp(view->name, view_settings->view_transform)) + if (STREQ(view->name, view_settings->view_transform)) break; } @@ -1496,7 +1496,7 @@ static bool is_ibuf_rect_in_display_space(ImBuf *ibuf, const ColorManagedViewSet const char *from_colorspace = ibuf->rect_colorspace->name; const char *to_colorspace = IMB_colormanagement_get_display_colorspace_name(view_settings, display_settings); - if (to_colorspace && !strcmp(from_colorspace, to_colorspace)) + if (to_colorspace && STREQ(from_colorspace, to_colorspace)) return true; } @@ -1625,7 +1625,7 @@ static void colormanagement_transform_ex(float *buffer, int width, int height, i return; } - if (!strcmp(from_colorspace, to_colorspace)) { + if (STREQ(from_colorspace, to_colorspace)) { /* if source and destination color spaces are identical, skip * threading overhead and simply do nothing */ @@ -1666,7 +1666,7 @@ void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspac return; } - if (!strcmp(from_colorspace, to_colorspace)) { + if (STREQ(from_colorspace, to_colorspace)) { /* if source and destination color spaces are identical, skip * threading overhead and simply do nothing */ @@ -2152,7 +2152,7 @@ ColorManagedDisplay *colormanage_display_get_named(const char *name) ColorManagedDisplay *display; for (display = global_displays.first; display; display = display->next) { - if (!strcmp(display->name, name)) + if (STREQ(display->name, name)) return display; } @@ -2257,7 +2257,7 @@ ColorManagedView *colormanage_view_get_named(const char *name) ColorManagedView *view; for (view = global_views.first; view; view = view->next) { - if (!strcmp(view->name, name)) + if (STREQ(view->name, name)) return view; } @@ -2373,7 +2373,7 @@ ColorSpace *colormanage_colorspace_get_named(const char *name) ColorSpace *colorspace; for (colorspace = global_colorspaces.first; colorspace; colorspace = colorspace->next) { - if (!strcmp(colorspace->name, name)) + if (STREQ(colorspace->name, name)) return colorspace; } @@ -2459,7 +2459,7 @@ ColorManagedLook *colormanage_look_get_named(const char *name) ColorManagedLook *look; for (look = global_looks.first; look; look = look->next) { - if (!strcmp(look->name, name)) { + if (STREQ(look->name, name)) { return look; } } diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index e66be77ecaf..e067cd64022 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -1237,7 +1237,7 @@ void IMB_free_indices(struct anim *anim) void IMB_anim_set_index_dir(struct anim *anim, const char *dir) { - if (strcmp(anim->index_dir, dir) == 0) { + if (STREQ(anim->index_dir, dir)) { return; } BLI_strncpy(anim->index_dir, dir, sizeof(anim->index_dir)); diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index f4b5f987869..6093a1477ce 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -37,6 +37,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_fileops.h" @@ -267,7 +268,7 @@ handle_app1(j_decompress_ptr cinfo) if (length < 16) { for (i = 0; i < length; i++) INPUT_BYTE(cinfo, neogeo[i], return false); length = 0; - if (strncmp(neogeo, "NeoGeo", 6) == 0) memcpy(&ibuf_ftype, neogeo + 6, 4); + if (STREQLEN(neogeo, "NeoGeo", 6)) memcpy(&ibuf_ftype, neogeo + 6, 4); ibuf_ftype = BIG_LONG(ibuf_ftype); } INPUT_SYNC(cinfo); /* do before skip_input_data */ @@ -385,7 +386,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla * That is why we need split it to the * common key/value here. */ - if (strncmp(str, "Blender", 7)) { + if (!STREQLEN(str, "Blender", 7)) { /* * Maybe the file have text that * we don't know "what it's", in that @@ -494,7 +495,7 @@ static void write_jpeg(struct jpeg_compress_struct *cinfo, struct ImBuf *ibuf) text = MEM_mallocN(530, "stamp info read"); iptr = ibuf->metadata; while (iptr) { - if (!strcmp(iptr->key, "None")) { + if (STREQ(iptr->key, "None")) { jpeg_write_marker(cinfo, JPEG_COM, (JOCTET *) iptr->value, strlen(iptr->value) + 1); goto next_stamp_info; } diff --git a/source/blender/imbuf/intern/metadata.c b/source/blender/imbuf/intern/metadata.c index 797d34d118b..35d921beabd 100644 --- a/source/blender/imbuf/intern/metadata.c +++ b/source/blender/imbuf/intern/metadata.c @@ -76,7 +76,7 @@ bool IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, con } info = img->metadata; while (info) { - if (strcmp(key, info->key) == 0) { + if (STREQ(key, info->key)) { BLI_strncpy(field, info->value, len); retval = true; break; @@ -123,7 +123,7 @@ bool IMB_metadata_del_field(struct ImBuf *img, const char *key) p = img->metadata; p1 = NULL; while (p) { - if (!strcmp(key, p->key)) { + if (STREQ(key, p->key)) { if (p1) p1->next = p->next; else @@ -152,7 +152,7 @@ bool IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *f p = img->metadata; while (p) { - if (!strcmp(key, p->key)) { + if (STREQ(key, p->key)) { MEM_freeN(p->value); p->value = BLI_strdup(field); return true; diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index ba1bda640a6..ad19c547db3 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -784,7 +784,7 @@ void IMB_exr_read_channels(void *handle) /* check if exr was saved with previous versions of blender which flipped images */ const StringAttribute *ta = data->ifile->header().findTypedAttribute <StringAttribute> ("BlenderMultiChannel"); - short flip = (ta && strncmp(ta->value().c_str(), "Blender V2.43", 13) == 0); /* 'previous multilayer attribute, flipped */ + short flip = (ta && STREQLEN(ta->value().c_str(), "Blender V2.43", 13)); /* 'previous multilayer attribute, flipped */ for (echan = (ExrChannel *)data->channels.first; echan; echan = echan->next) { @@ -982,7 +982,7 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname) if (pass == NULL) { pass = (ExrPass *)MEM_callocN(sizeof(ExrPass), "exr pass"); - if (strcmp(passname, "Combined") == 0) + if (STREQ(passname, "Combined")) BLI_addhead(lb, pass); else BLI_addtail(lb, pass); diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 3266dc97c78..94914db3a1a 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -490,7 +490,7 @@ static void imb_png_warning(png_structp UNUSED(png_ptr), png_const_charp message * and with new libpng it became too much picky, giving a warning on * the splash screen even. */ - if ((G.debug & G_DEBUG) == 0 && !strncmp(message, "iCCP", 4)) { + if ((G.debug & G_DEBUG) == 0 && STREQLEN(message, "iCCP", 4)) { return; } fprintf(stderr, "libpng warning: %s\n", message); diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index af353461f1f..aee465c49cc 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -55,7 +55,7 @@ static ImBuf *loadblend_thumb(gzFile gzfile) /* read the blend file header */ if (gzread(gzfile, buf, 12) != 12) return NULL; - if (strncmp(buf, "BLENDER", 7)) + if (!STREQLEN(buf, "BLENDER", 7)) return NULL; if (buf[7] == '-') diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index e3b8e271387..dca10fd7eda 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -594,7 +594,7 @@ ImBuf *imb_loadtiff(unsigned char *mem, size_t size, int flags, char colorspace[ format = NULL; TIFFGetField(image, TIFFTAG_PIXAR_TEXTUREFORMAT, &format); - if (format && strcmp(format, "Plain Texture") == 0 && TIFFIsTiled(image)) { + if (format && STREQ(format, "Plain Texture") && TIFFIsTiled(image)) { int numlevel = TIFFNumberOfDirectories(image); /* create empty mipmap levels in advance */ 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); diff --git a/source/blender/modifiers/intern/MOD_meshcache_pc2.c b/source/blender/modifiers/intern/MOD_meshcache_pc2.c index 679bdcd1d47..219eae4ecca 100644 --- a/source/blender/modifiers/intern/MOD_meshcache_pc2.c +++ b/source/blender/modifiers/intern/MOD_meshcache_pc2.c @@ -57,7 +57,7 @@ static bool meshcache_read_pc2_head(FILE *fp, const int verts_tot, return false; } - if (strcmp(pc2_head->header, "POINTCACHE2") != 0) { + if (!STREQ(pc2_head->header, "POINTCACHE2")) { *err_str = "Invalid header"; return false; } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index ecc02e732ce..e8845b543b8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -439,7 +439,7 @@ static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr) static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree) { - if (strcmp(ntree->idname, "CompositorNodeTree") == 0) { + if (STREQ(ntree->idname, "CompositorNodeTree")) { Scene *scene; /* XXX ugly: check if ntree is a local scene node tree. diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index 282567b797f..01c642b063d 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -108,7 +108,7 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in bNodeSocket *sock; for (sock = socklist->first; sock; sock = sock->next) { - if (strncmp(sock->name, stemp->name, NODE_MAXSTR) == 0) + if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR)) break; } if (sock) { diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index 7c598f92bed..2fb03536bbe 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -63,7 +63,7 @@ static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, b if (ngeo->uvname[0]) { /* find uv map by name */ for (i = 0; i < shi->totuv; i++) { - if (strcmp(shi->uv[i].name, ngeo->uvname) == 0) { + if (STREQ(shi->uv[i].name, ngeo->uvname)) { suv = &shi->uv[i]; break; } @@ -84,7 +84,7 @@ static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, b if (ngeo->colname[0]) { for (i = 0; i < shi->totcol; i++) { - if (strcmp(shi->col[i].name, ngeo->colname) == 0) { + if (STREQ(shi->col[i].name, ngeo->colname)) { scol = &shi->col[i]; break; } diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c index fd864f1c7c6..9fe56d4f01d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c @@ -51,7 +51,7 @@ static void node_shader_init_subsurface_scattering(bNodeTree *UNUSED(ntree), bNo node->custom1 = SHD_SUBSURFACE_CUBIC; /*for (sock = node->inputs.first; sock; sock = sock->next) { - if (strcmp(sock->name, "Sharpness") == 0) { + if (STREQ(sock->name, "Sharpness")) { bNodeSocketValueFloat *dval = sock->default_value; dval->value = 0.0f; } @@ -72,7 +72,7 @@ static void node_shader_update_subsurface_scattering(bNodeTree *UNUSED(ntree), b int falloff = node->custom1; for (sock = node->inputs.first; sock; sock = sock->next) { - if (strcmp(sock->name, "Sharpness") == 0) { + if (STREQ(sock->name, "Sharpness")) { if (falloff == SHD_SUBSURFACE_CUBIC) sock->flag &= ~SOCK_UNAVAIL; else diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 1a56c0f7c59..17a2038b7dc 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -260,7 +260,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms return msgid; tmp = BLF_lang_get(); - if (strcmp(tmp, locale) || !_translations_cache) { + if (!STREQ(tmp, locale) || !_translations_cache) { PyGILState_STATE _py_state; BLI_strncpy(locale, tmp, STATIC_LOCALE_SIZE); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 7605d7d9ea7..1e30e05fe1a 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -256,7 +256,7 @@ Render *RE_GetRender(const char *name) /* search for existing renders */ for (re = RenderGlobal.renderlist.first; re; re = re->next) - if (strncmp(re->name, name, RE_MAXNAME) == 0) + if (STREQLEN(re->name, name, RE_MAXNAME)) break; return re; diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 0d859f81e0c..6486844bacf 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -309,97 +309,97 @@ static const char *get_pass_name(int passtype, int channel) static int passtype_from_name(const char *str) { - if (strcmp(str, "Combined") == 0) + if (STREQ(str, "Combined")) return SCE_PASS_COMBINED; - if (strcmp(str, "Depth") == 0) + if (STREQ(str, "Depth")) return SCE_PASS_Z; - if (strcmp(str, "Vector") == 0) + if (STREQ(str, "Vector")) return SCE_PASS_VECTOR; - if (strcmp(str, "Normal") == 0) + if (STREQ(str, "Normal")) return SCE_PASS_NORMAL; - if (strcmp(str, "UV") == 0) + if (STREQ(str, "UV")) return SCE_PASS_UV; - if (strcmp(str, "Color") == 0) + if (STREQ(str, "Color")) return SCE_PASS_RGBA; - if (strcmp(str, "Emit") == 0) + if (STREQ(str, "Emit")) return SCE_PASS_EMIT; - if (strcmp(str, "Diffuse") == 0) + if (STREQ(str, "Diffuse")) return SCE_PASS_DIFFUSE; - if (strcmp(str, "Spec") == 0) + if (STREQ(str, "Spec")) return SCE_PASS_SPEC; - if (strcmp(str, "Shadow") == 0) + if (STREQ(str, "Shadow")) return SCE_PASS_SHADOW; - if (strcmp(str, "AO") == 0) + if (STREQ(str, "AO")) return SCE_PASS_AO; - if (strcmp(str, "Env") == 0) + if (STREQ(str, "Env")) return SCE_PASS_ENVIRONMENT; - if (strcmp(str, "Indirect") == 0) + if (STREQ(str, "Indirect")) return SCE_PASS_INDIRECT; - if (strcmp(str, "Reflect") == 0) + if (STREQ(str, "Reflect")) return SCE_PASS_REFLECT; - if (strcmp(str, "Refract") == 0) + if (STREQ(str, "Refract")) return SCE_PASS_REFRACT; - if (strcmp(str, "IndexOB") == 0) + if (STREQ(str, "IndexOB")) return SCE_PASS_INDEXOB; - if (strcmp(str, "IndexMA") == 0) + if (STREQ(str, "IndexMA")) return SCE_PASS_INDEXMA; - if (strcmp(str, "Mist") == 0) + if (STREQ(str, "Mist")) return SCE_PASS_MIST; - if (strcmp(str, "RayHits") == 0) + if (STREQ(str, "RayHits")) return SCE_PASS_RAYHITS; - if (strcmp(str, "DiffDir") == 0) + if (STREQ(str, "DiffDir")) return SCE_PASS_DIFFUSE_DIRECT; - if (strcmp(str, "DiffInd") == 0) + if (STREQ(str, "DiffInd")) return SCE_PASS_DIFFUSE_INDIRECT; - if (strcmp(str, "DiffCol") == 0) + if (STREQ(str, "DiffCol")) return SCE_PASS_DIFFUSE_COLOR; - if (strcmp(str, "GlossDir") == 0) + if (STREQ(str, "GlossDir")) return SCE_PASS_GLOSSY_DIRECT; - if (strcmp(str, "GlossInd") == 0) + if (STREQ(str, "GlossInd")) return SCE_PASS_GLOSSY_INDIRECT; - if (strcmp(str, "GlossCol") == 0) + if (STREQ(str, "GlossCol")) return SCE_PASS_GLOSSY_COLOR; - if (strcmp(str, "TransDir") == 0) + if (STREQ(str, "TransDir")) return SCE_PASS_TRANSM_DIRECT; - if (strcmp(str, "TransInd") == 0) + if (STREQ(str, "TransInd")) return SCE_PASS_TRANSM_INDIRECT; - if (strcmp(str, "TransCol") == 0) + if (STREQ(str, "TransCol")) return SCE_PASS_TRANSM_COLOR; - if (strcmp(str, "SubsurfaceDir") == 0) + if (STREQ(str, "SubsurfaceDir")) return SCE_PASS_SUBSURFACE_DIRECT; - if (strcmp(str, "SubsurfaceInd") == 0) + if (STREQ(str, "SubsurfaceInd")) return SCE_PASS_SUBSURFACE_INDIRECT; - if (strcmp(str, "SubsurfaceCol") == 0) + if (STREQ(str, "SubsurfaceCol")) return SCE_PASS_SUBSURFACE_COLOR; return 0; @@ -509,7 +509,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf for (nr = 0, srl = re->r.layers.first; srl; srl = srl->next, nr++) { if (layername && layername[0]) - if (strcmp(srl->name, layername) != 0) + if (!STREQ(srl->name, layername)) continue; if (re->r.scemode & R_SINGLE_LAYER) { diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index b1e00c4a451..c738fc3e06a 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2249,7 +2249,7 @@ void do_material_tex(ShadeInput *shi, Render *re) if (mtex->uvname[0] != 0) { for (i = 0; i < shi->totuv; i++) { - if (strcmp(shi->uv[i].name, mtex->uvname)==0) { + if (STREQ(shi->uv[i].name, mtex->uvname)) { suv= &shi->uv[i]; break; } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 93e8c6a275a..63a97a04b39 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -2064,7 +2064,7 @@ float RE_lamp_get_data(ShadeInput *shi, Object *lamp_obj, float col[4], float lv if (R.r.scemode & R_BUTS_PREVIEW) { for (go = R.lights.first; go; go = go->next) { /* "Lamp.002" is main key light of material preview */ - if (strcmp(go->ob->id.name + 2, "Lamp.002") == 0) + if (STREQ(go->ob->id.name + 2, "Lamp.002")) return lamp_get_data_internal(shi, go, col, lv, dist, shadow); } return 0.0f; diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index 9859a7ded87..cdc3c9eaaff 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -81,7 +81,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) for (dm = dropboxes.first; dm; dm = dm->next) if (dm->spaceid == spaceid && dm->regionid == regionid) - if (0 == strncmp(idname, dm->idname, KMAP_MAX_NAME)) + if (STREQLEN(idname, dm->idname, KMAP_MAX_NAME)) return &dm->dropboxes; dm = MEM_callocN(sizeof(struct wmDropBoxMap), "dropmap list"); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index afbc7bbc025..885aa69b179 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -870,7 +870,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, break; /* skip invalid properties */ - if (strcmp(RNA_property_identifier(prop), otmacro->idname) == 0) { + if (STREQ(RNA_property_identifier(prop), otmacro->idname)) { wmOperatorType *otm = WM_operatortype_find(otmacro->idname, 0); PointerRNA someptr = RNA_property_pointer_get(properties, prop); wmOperator *opm = wm_operator_create(wm, otm, &someptr, NULL); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index d159513e6a1..a500f24db16 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -355,7 +355,7 @@ static int wm_read_exotic(Scene *UNUSED(scene), const char *name) else { len = gzread(gzfile, header, sizeof(header)); gzclose(gzfile); - if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { + if (len == sizeof(header) && STREQLEN(header, "BLENDER", 7)) { retval = BKE_READ_EXOTIC_OK_BLEND; } else { diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index b52f3819d3f..a1643046fff 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -145,21 +145,15 @@ static void wm_keyconfig_properties_update_ot(ListBase *km_lb) } } -static int wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b) +static bool wm_keymap_item_equals_result(wmKeyMapItem *a, wmKeyMapItem *b) { - if (strcmp(a->idname, b->idname) != 0) - return 0; - - if (!RNA_struct_equals(a->ptr, b->ptr, RNA_EQ_UNSET_MATCH_NONE)) - return 0; - - if ((a->flag & KMI_INACTIVE) != (b->flag & KMI_INACTIVE)) - return 0; - - return (a->propvalue == b->propvalue); + return (STREQ(a->idname, b->idname) && + RNA_struct_equals(a->ptr, b->ptr, RNA_EQ_UNSET_MATCH_NONE) && + (a->flag & KMI_INACTIVE) == (b->flag & KMI_INACTIVE) && + a->propvalue == b->propvalue); } -static int wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b) +static bool wm_keymap_item_equals(wmKeyMapItem *a, wmKeyMapItem *b) { return (wm_keymap_item_equals_result(a, b) && a->type == b->type && @@ -266,7 +260,7 @@ wmKeyConfig *WM_keyconfig_new_user(wmWindowManager *wm, const char *idname) bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) { if (BLI_findindex(&wm->keyconfigs, keyconf) != -1) { - if (strncmp(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr)) == 0) { + if (STREQLEN(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr))) { BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr)); WM_keyconfig_update_tag(NULL, NULL); } @@ -421,7 +415,7 @@ wmKeyMapItem *WM_keymap_verify_item(wmKeyMap *keymap, const char *idname, int ty wmKeyMapItem *kmi; for (kmi = keymap->items.first; kmi; kmi = kmi->next) - if (strncmp(kmi->idname, idname, OP_MAX_TYPENAME) == 0) + if (STREQLEN(kmi->idname, idname, OP_MAX_TYPENAME)) break; if (kmi == NULL) { kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); @@ -728,7 +722,7 @@ wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int for (km = lb->first; km; km = km->next) if (km->spaceid == spaceid && km->regionid == regionid) - if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME)) + if (STREQLEN(idname, km->idname, KMAP_MAX_NAME)) return km; return NULL; @@ -787,7 +781,7 @@ wmKeyMap *WM_modalkeymap_get(wmKeyConfig *keyconf, const char *idname) for (km = keyconf->keymaps.first; km; km = km->next) if (km->flag & KEYMAP_MODAL) - if (0 == strncmp(idname, km->idname, KMAP_MAX_NAME)) + if (STREQLEN(idname, km->idname, KMAP_MAX_NAME)) break; return km; @@ -952,7 +946,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( if (kmi->flag & KMI_INACTIVE) continue; - if (strcmp(kmi->idname, opname) == 0 && WM_key_event_string(kmi->type)[0]) { + if (STREQ(kmi->idname, opname) && WM_key_event_string(kmi->type)[0]) { if (is_hotkey) { if (!ISHOTKEY(kmi->type)) continue; @@ -963,7 +957,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers( /* example of debugging keymaps */ #if 0 if (kmi->ptr) { - if (strcmp("MESH_OT_rip_move", opname) == 0) { + if (STREQ("MESH_OT_rip_move", opname)) { printf("OPERATOR\n"); IDP_spit(properties); printf("KEYMAP\n"); @@ -1353,7 +1347,7 @@ void WM_keymap_restore_item_to_default(bContext *C, wmKeyMap *keymap, wmKeyMapIt if (orig) { /* restore to original */ - if (strcmp(orig->idname, kmi->idname) != 0) { + if (!STREQ(orig->idname, kmi->idname)) { BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname)); WM_keymap_properties_reset(kmi, NULL); } diff --git a/source/creator/creator.c b/source/creator/creator.c index 67932bcfb30..15406485c7f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -755,7 +755,7 @@ static int set_engine(int argc, const char **argv, void *data) { bContext *C = data; if (argc >= 2) { - if (!strcmp(argv[1], "help")) { + if (STREQ(argv[1], "help")) { RenderEngineType *type = NULL; printf("Blender Engine Listing:\n"); for (type = R_engines.first; type; type = type->next) { @@ -925,11 +925,11 @@ static int set_ge_parameters(int argc, const char **argv, void *data) SYS_WriteCommandLineInt(syshandle, argv[a], 1); #endif /* doMipMap */ - if (!strcmp(argv[a], "nomipmap")) { + if (STREQ(argv[a], "nomipmap")) { GPU_set_mipmap(0); //doMipMap = 0; } /* linearMipMap */ - if (!strcmp(argv[a], "linearmipmap")) { + if (STREQ(argv[a], "linearmipmap")) { GPU_set_linear_mipmap(1); //linearMipMap = 1; } @@ -1555,7 +1555,7 @@ int main( #if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) /* patch to ignore argument finder gives us (pid?) */ - if (argc == 2 && strncmp(argv[1], "-psn_", 5) == 0) { + if (argc == 2 && STREQLEN(argv[1], "-psn_", 5)) { extern int GHOST_HACK_getFirstFile(char buf[]); static char firstfilebuf[512]; |