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/blenlib/intern | |
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/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/BLI_args.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_ghash.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/listbase.c | 10 | ||||
-rw-r--r-- | source/blender/blenlib/intern/path_util.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 8 |
6 files changed, 13 insertions, 15 deletions
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)); } |