diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-26 18:03:11 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-26 18:59:24 +0300 |
commit | fca515838e70f8bec7028b840bb921a1be9fabbb (patch) | |
tree | 1752923de19eca5f01ca4cfb5754fd4d1f13d934 /source/blender/windowmanager | |
parent | d44890ee75634052f325531766a661a5bcef628f (diff) |
Cleanup: strcmp/strncmp -> STREQ/STREQLEN (in boolean usage).
Makes usage of those funcs much more clear, we even had mixed '!strcmp(foo, bar)'
and 'strcmp(foo, bar) == 0' in several places...
Diffstat (limited to 'source/blender/windowmanager')
4 files changed, 16 insertions, 22 deletions
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); } |