patch [#34103] use booleans for extensions testing.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 4 Mar 2013 18:36:37 +0000 (18:36 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 4 Mar 2013 18:36:37 +0000 (18:36 +0000)
bli_testextensie.patch - from Lawrence D'Oliveiro (ldo)

20 files changed:
source/blender/blenlib/BLI_path_util.h
source/blender/blenlib/intern/path_util.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_clip/clip_ops.c
source/blender/imbuf/intern/anim_movie.c
source/blender/imbuf/intern/readimage.c
source/blender/imbuf/intern/thumbs.c
source/blender/imbuf/intern/util.c
source/blender/makesrna/intern/rna_fluidsim.c
source/blender/makesrna/intern/rna_main.c
source/blender/makesrna/intern/rna_main_api.c
source/blender/makesrna/intern/rna_render.c
source/blender/makesrna/intern/rna_scene_api.c
source/blender/makesrna/intern/rna_texture_api.c
source/blender/nodes/composite/nodes/node_composite_outputFile.c
source/blender/python/intern/bpy.c
source/blender/python/intern/bpy_app.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_traceback.c

index 8c51c925d97000839de5f291067babcd45076470..b4a5e19d33bb234b30dcea05e59350d8e210fc5d 100644 (file)
@@ -106,9 +106,9 @@ void  BLI_del_slash(char *string);
 char *BLI_first_slash(char *string);
 
 void BLI_getlastdir(const char *dir, char *last, const size_t maxlen);
 char *BLI_first_slash(char *string);
 
 void BLI_getlastdir(const char *dir, char *last, const size_t maxlen);
-int BLI_testextensie(const char *str, const char *ext);
-int BLI_testextensie_array(const char *str, const char **ext_array);
-int BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
+bool BLI_testextensie(const char *str, const char *ext);
+bool BLI_testextensie_array(const char *str, const char **ext_array);
+bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch);
 int BLI_replace_extension(char *path, size_t maxlen, const char *ext);
 int BLI_ensure_extension(char *path, size_t maxlen, const char *ext);
 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
 int BLI_replace_extension(char *path, size_t maxlen, const char *ext);
 int BLI_ensure_extension(char *path, size_t maxlen, const char *ext);
 void BLI_uniquename(struct ListBase *list, void *vlink, const char defname[], char delim, short name_offs, short len);
index 5265d862ab8b6a802c6621fff15cd7e2bb0954b2..f521672630b06a6a6fdbef694dd8835a152d6824 100644 (file)
 
 #include "DNA_listBase.h"
 
 
 #include "DNA_listBase.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 #include "BLI_string_utf8.h"
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 #include "BLI_string_utf8.h"
-#include "BLI_utildefines.h"
 
 #include "../blenkernel/BKE_blender.h"  /* BLENDER_VERSION, bad level include (no function call) */
 
 
 #include "../blenkernel/BKE_blender.h"  /* BLENDER_VERSION, bad level include (no function call) */
 
@@ -1359,43 +1359,31 @@ void BLI_make_file_string(const char *relabase, char *string,  const char *dir,
        BLI_clean(string);
 }
 
        BLI_clean(string);
 }
 
-int BLI_testextensie(const char *str, const char *ext)
+/* does str end with ext. */
+bool BLI_testextensie(const char *str, const char *ext)
 {
 {
-       short a, b;
-       int retval;
-       
-       a = strlen(str);
-       b = strlen(ext);
-       
-       if (a == 0 || b == 0 || b >= a) {
-               retval = 0;
-       }
-       else if (BLI_strcasecmp(ext, str + a - b)) {
-               retval = 0;
-       }
-       else {
-               retval = 1;
-       }
-       
-       return (retval);
+       const size_t a = strlen(str);
+       const size_t b = strlen(ext);
+       return !(a == 0 || b == 0 || b >= a) && (BLI_strcasecmp(ext, str + a - b) == 0);
 }
 
 }
 
-int BLI_testextensie_array(const char *str, const char **ext_array)
+/* does str end with any of the suffixes in *ext_array. */
+bool BLI_testextensie_array(const char *str, const char **ext_array)
 {
        int i = 0;
        while (ext_array[i]) {
                if (BLI_testextensie(str, ext_array[i])) {
 {
        int i = 0;
        while (ext_array[i]) {
                if (BLI_testextensie(str, ext_array[i])) {
-                       return 1;
+                       return true;
                }
 
                i++;
        }
                }
 
                i++;
        }
-       return 0;
+       return false;
 }
 
 /* semicolon separated wildcards, eg:
  *  '*.zip;*.py;*.exe' */
 }
 
 /* semicolon separated wildcards, eg:
  *  '*.zip;*.py;*.exe' */
-int BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
+bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
 {
        const char *ext_step = ext_fnmatch;
        char pattern[16];
 {
        const char *ext_step = ext_fnmatch;
        char pattern[16];
@@ -1414,12 +1402,12 @@ int BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
                BLI_strncpy(pattern, ext_step, len_ext);
 
                if (fnmatch(pattern, str, FNM_CASEFOLD) == 0) {
                BLI_strncpy(pattern, ext_step, len_ext);
 
                if (fnmatch(pattern, str, FNM_CASEFOLD) == 0) {
-                       return 1;
+                       return true;
                }
                ext_step += len_ext;
        }
 
                }
                ext_step += len_ext;
        }
 
-       return 0;
+       return false;
 }
 
 
 }
 
 
index 0c9a5aab53706a2e1b008fcb466dece85ede283b..25560b3a33d9e071861ca937c1a2faa4910f8ecd 100644 (file)
@@ -36,6 +36,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_view3d_types.h"
 
 #include "DNA_scene_types.h"
 #include "DNA_view3d_types.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_array.h"
 #include "BLI_math.h"
 #include "BLI_path_util.h"
 #include "BLI_array.h"
 #include "BLI_math.h"
index 8b6682ff1c9778298a9aa4c16bbe2ee9668a7353..c723113aae719a5f02b8733e7414adf169649aac 100644 (file)
 
 #include "DNA_userdef_types.h"
 
 
 #include "DNA_userdef_types.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
-#include "BLI_utildefines.h"
 
 #include "BLF_translation.h"
 
 
 #include "BLF_translation.h"
 
index dfb69be6f188f5bce2b58836ca2d848a24db13ed..6d1cc335a26936f32936977a0ec713f20c3d67e5 100644 (file)
@@ -36,8 +36,8 @@
 #include "DNA_userdef_types.h"
 #include "DNA_scene_types.h"   /* min/max frames */
 
 #include "DNA_userdef_types.h"
 #include "DNA_scene_types.h"   /* min/max frames */
 
-#include "BLI_path_util.h"
 #include "BLI_utildefines.h"
 #include "BLI_utildefines.h"
+#include "BLI_path_util.h"
 #include "BLI_math.h"
 #include "BLI_rect.h"
 
 #include "BLI_math.h"
 #include "BLI_rect.h"
 
index 8d79482ed18060f6d46a9528aea3cc44a8410e1d..381e0b8c57cffd64733929dec2916b3e24d9befb 100644 (file)
@@ -64,9 +64,9 @@
 #include <io.h>
 #endif
 
 #include <io.h>
 #endif
 
+#include "BLI_utildefines.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
-#include "BLI_utildefines.h"
 #include "BLI_math_base.h"
 
 #include "MEM_guardedalloc.h"
 #include "BLI_math_base.h"
 
 #include "MEM_guardedalloc.h"
index 4d47d883444493929768a8459b1f84cace01be9b..d73fa9a7ab72dd878137f78f9933d139cfcc1560 100644 (file)
 #endif
 
 #include <stdlib.h>
 #endif
 
 #include <stdlib.h>
+#include "BLI_utildefines.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
 
 #include "BLI_string.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
 
-#include "BLI_utildefines.h"
-
 #include "imbuf.h"
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
 #include "imbuf.h"
 #include "IMB_imbuf_types.h"
 #include "IMB_imbuf.h"
index c1d80ad9067fe6eb761ce8ba4f3a45e3b98fb19a..bdf247660853c98959d47cc3f8f0da7c121e0255 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "MEM_guardedalloc.h"
 
 
 #include "MEM_guardedalloc.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
 #include "BLI_string.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
index 549a95e383dfd2771904d69b7901a5118c11dd5c..68d1c906a1faba246c2c1c78f048cc770c9b47b0 100644 (file)
@@ -41,9 +41,9 @@
 
 #include <stdlib.h>
 
 
 #include <stdlib.h>
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
-#include "BLI_utildefines.h"
 #include "BLI_string.h"
 
 #include "DNA_userdef_types.h"
 #include "BLI_string.h"
 
 #include "DNA_userdef_types.h"
index 84ff53ee68fb14cd76c3958acf6de82ac0827f5d..9ff83daa2f828e4a6a5542ca084b535a1536c814 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "DNA_object_fluidsim.h"
 
 
 #include "DNA_object_fluidsim.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
index 04b8d2fa3dfca40f2d6e99e0489f538400ee360e..75b7655006ff17a479db3c128b6d55769c9b72e7 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
index 7175c8eab78efc79be69f2d21b96dd5975525d3f..4d5d4d4a7cddb2f1e4063650e1183fd6f63a02b5 100644 (file)
@@ -36,8 +36,8 @@
 #include "DNA_ID.h"
 #include "DNA_modifier_types.h"
 
 #include "DNA_ID.h"
 #include "DNA_modifier_types.h"
 
-#include "BLI_path_util.h"
 #include "BLI_utildefines.h"
 #include "BLI_utildefines.h"
+#include "BLI_path_util.h"
 
 #include "RNA_define.h"
 #include "RNA_access.h"
 
 #include "RNA_define.h"
 #include "RNA_access.h"
index e2e373d8beb0653c4774994c719eeac6f4f19dcc..437518af5eea2a55083003b0e55d0d7155a1d7d7 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "DNA_scene_types.h"
 
 
 #include "DNA_scene_types.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
index b3619330e7a95b8af34e5eca66001d41e7e780d7..54b008d078781ee881e586a661550c931767b7ef 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
index 218fda361faf235d730688425fb3cf7f27736e8f..10ac5a9548a7907209205a1967721f962be4865d 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
 #include "BLI_path_util.h"
 
 #include "RNA_define.h"
index dff09b93845c9c5a5ab2843c94dddcbe1261cef4..dc5619ae10c00aaaa5fc85853f58d30585ddb429 100644 (file)
@@ -31,6 +31,7 @@
 
 
 #include <string.h>
 
 
 #include <string.h>
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 
 #include "node_composite_util.h"
 #include "BLI_path_util.h"
 
 #include "node_composite_util.h"
index c4d68290da3b1d37a31bd2b1e7313b1ca370ce35..71f85af8255f66eb12cda437e007b3cd23554121 100644 (file)
 #include "RNA_types.h"
 #include "RNA_access.h"
 
 #include "RNA_types.h"
 #include "RNA_access.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 #include "BKE_bpath.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 #include "BKE_bpath.h"
-#include "BLI_utildefines.h"
 
 #include "bpy.h"
 #include "bpy_util.h"
 
 #include "bpy.h"
 #include "bpy_util.h"
index 5195f821d56bdb2eb5f28af1f0e0de9d2dc44594..f2ad2398e9997e9742f26135435a5ec5825a2252 100644 (file)
@@ -41,9 +41,8 @@
 #include "bpy_app_handlers.h"
 #include "bpy_driver.h"
 
 #include "bpy_app_handlers.h"
 #include "bpy_driver.h"
 
-#include "BLI_path_util.h"
 #include "BLI_utildefines.h"
 #include "BLI_utildefines.h"
-
+#include "BLI_path_util.h"
 
 #include "BKE_blender.h"
 #include "BKE_global.h"
 
 #include "BKE_blender.h"
 #include "BKE_global.h"
index 90199a403dcf8d353014244c0f6aacabd24487e5..1b3d4cd870d84be5c1b8c083ff5c5860c2d80fa2 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
 
 #include "MEM_guardedalloc.h"
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
 #include "BLI_listbase.h"
 #include "BLI_math_base.h"
 #include "BLI_string.h"
 #include "BLI_string_utf8.h"
 #include "BLI_path_util.h"
 #include "BLI_fileops.h"
 #include "BLI_listbase.h"
 #include "BLI_math_base.h"
 #include "BLI_string.h"
 #include "BLI_string_utf8.h"
-#include "BLI_utildefines.h"
 #include "BLI_threads.h"
 
 #include "RNA_types.h"
 #include "BLI_threads.h"
 
 #include "RNA_types.h"
index 48bf65a841ba2022675227ce3044afa172bf4622..81d12e9d9a6b6451a17f4ac74924cfa964fff6af 100644 (file)
@@ -29,6 +29,7 @@
 #include <Python.h>
 #include <frameobject.h>
 
 #include <Python.h>
 #include <frameobject.h>
 
+#include "BLI_utildefines.h"
 #include "BLI_path_util.h"
 #include "BLI_string.h"
 
 #include "BLI_path_util.h"
 #include "BLI_string.h"