diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-04 22:36:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-04 22:36:37 +0400 |
commit | 013a176c52e5821dd28ff0c5d3506600399b3050 (patch) | |
tree | 49b4722001644858312f116263d77cc6fa344da3 /source | |
parent | 495aa863aeb54886a7f5ddc5c2716828fac53856 (diff) |
patch [#34103] use booleans for extensions testing.
bli_testextensie.patch - from Lawrence D'Oliveiro (ldo)
Diffstat (limited to 'source')
20 files changed, 34 insertions, 39 deletions
diff --git a/source/blender/blenlib/BLI_path_util.h b/source/blender/blenlib/BLI_path_util.h index 8c51c925d97..b4a5e19d33b 100644 --- a/source/blender/blenlib/BLI_path_util.h +++ b/source/blender/blenlib/BLI_path_util.h @@ -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); -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); diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 5265d862ab8..f521672630b 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -41,11 +41,11 @@ #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_utildefines.h" #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); } -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])) { - return 1; + return true; } i++; } - return 0; + return false; } /* 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]; @@ -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) { - return 1; + return true; } ext_step += len_ext; } - return 0; + return false; } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 0c9a5aab537..25560b3a33d 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -36,6 +36,7 @@ #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" diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 8b6682ff1c9..c723113aae7 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -35,10 +35,10 @@ #include "DNA_userdef_types.h" +#include "BLI_utildefines.h" #include "BLI_fileops.h" #include "BLI_path_util.h" #include "BLI_string.h" -#include "BLI_utildefines.h" #include "BLF_translation.h" diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index dfb69be6f18..6d1cc335a26 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -36,8 +36,8 @@ #include "DNA_userdef_types.h" #include "DNA_scene_types.h" /* min/max frames */ -#include "BLI_path_util.h" #include "BLI_utildefines.h" +#include "BLI_path_util.h" #include "BLI_math.h" #include "BLI_rect.h" diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 8d79482ed18..381e0b8c57c 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -64,9 +64,9 @@ #include <io.h> #endif +#include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_path_util.h" -#include "BLI_utildefines.h" #include "BLI_math_base.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 4d47d883444..d73fa9a7ab7 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -43,12 +43,11 @@ #endif #include <stdlib.h> +#include "BLI_utildefines.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" diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index c1d80ad9067..bdf24766085 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -34,6 +34,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_string.h" #include "BLI_path_util.h" #include "BLI_fileops.h" diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 549a95e383d..68d1c906a1f 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -41,9 +41,9 @@ #include <stdlib.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_fileops.h" -#include "BLI_utildefines.h" #include "BLI_string.h" #include "DNA_userdef_types.h" diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 84ff53ee68f..9ff83daa2f8 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -28,6 +28,7 @@ #include "DNA_object_fluidsim.h" +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "RNA_define.h" diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 04b8d2fa3df..75b7655006f 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "RNA_define.h" diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 7175c8eab78..4d5d4d4a7cd 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -36,8 +36,8 @@ #include "DNA_ID.h" #include "DNA_modifier_types.h" -#include "BLI_path_util.h" #include "BLI_utildefines.h" +#include "BLI_path_util.h" #include "RNA_define.h" #include "RNA_access.h" diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index e2e373d8beb..437518af5ee 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -28,6 +28,7 @@ #include "DNA_scene_types.h" +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "RNA_define.h" diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index b3619330e7a..54b008d0787 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -32,6 +32,7 @@ #include <stdlib.h> #include <stdio.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "RNA_define.h" diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index 218fda361fa..10ac5a9548a 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <string.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "RNA_define.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index dff09b93845..dc5619ae10c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -31,6 +31,7 @@ #include <string.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "node_composite_util.h" diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index c4d68290da3..71f85af8255 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -35,10 +35,10 @@ #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_utildefines.h" #include "bpy.h" #include "bpy_util.h" diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 5195f821d56..f2ad2398e99 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -41,9 +41,8 @@ #include "bpy_app_handlers.h" #include "bpy_driver.h" -#include "BLI_path_util.h" #include "BLI_utildefines.h" - +#include "BLI_path_util.h" #include "BKE_blender.h" #include "BKE_global.h" diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 90199a403dc..1b3d4cd870d 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -39,13 +39,13 @@ #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_utildefines.h" #include "BLI_threads.h" #include "RNA_types.h" diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index 48bf65a841b..81d12e9d9a6 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -29,6 +29,7 @@ #include <Python.h> #include <frameobject.h> +#include "BLI_utildefines.h" #include "BLI_path_util.h" #include "BLI_string.h" |