From 9821dd72bac89053ce0213e68116855910c681e9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 31 Aug 2019 17:28:48 +1000 Subject: Cleanup: rename natural string comparison --- source/blender/blenlib/BLI_string.h | 2 +- source/blender/blenlib/intern/BLI_filelist.c | 2 +- source/blender/blenlib/intern/string.c | 7 +++++-- source/blender/collada/AnimationImporter.cpp | 2 +- source/blender/editors/object/object_vgroup.c | 2 +- source/blender/editors/space_file/filelist.c | 8 ++++---- source/blender/editors/space_node/node_templates.c | 2 +- source/blender/editors/space_outliner/outliner_tree.c | 6 +++--- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 70ffb46e952..cab2e68ca2b 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -100,7 +100,7 @@ char *BLI_strncasestr(const char *s, const char *find, size_t len) ATTR_WARN_UNU int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); int BLI_strncasecmp(const char *s1, const char *s2, size_t len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -int BLI_natstrcmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); int BLI_strcmp_ignore_pad(const char *str1, const char *str2, const char pad) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c index 91f16ca9b7b..a93632cca08 100644 --- a/source/blender/blenlib/intern/BLI_filelist.c +++ b/source/blender/blenlib/intern/BLI_filelist.c @@ -107,7 +107,7 @@ static int bli_compare(struct direntry *entry1, struct direntry *entry2) return 1; } - return (BLI_natstrcmp(entry1->relname, entry2->relname)); + return (BLI_strcasecmp_natural(entry1->relname, entry2->relname)); } struct BuildDirCtx { diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index c3947cb8158..4059e0401c0 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -663,8 +663,11 @@ static int left_number_strcmp(const char *s1, const char *s2, int *tiebreaker) return 0; } -/* natural string compare, keeping numbers in order */ -int BLI_natstrcmp(const char *s1, const char *s2) +/** + * Case insensitive, *natural* string comparison, + * keeping numbers in order. + */ +int BLI_strcasecmp_natural(const char *s1, const char *s2) { register int d1 = 0, d2 = 0; register char c1, c2; diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 54177560eb5..79593f07383 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -733,7 +733,7 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi * Reason: old blender versions stored spot_size in radians (was a bug) */ if (this->import_from_version == "" || - BLI_natstrcmp(this->import_from_version.c_str(), "2.69.10") != -1) { + BLI_strcasecmp_natural(this->import_from_version.c_str(), "2.69.10") != -1) { fcurve_deg_to_rad(fcu); } } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 08fe5e818b2..ce385b12608 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -3794,7 +3794,7 @@ static int vgroup_sort_name(const void *def_a_ptr, const void *def_b_ptr) const bDeformGroup *def_a = def_a_ptr; const bDeformGroup *def_b = def_b_ptr; - return BLI_natstrcmp(def_a->name, def_b->name); + return BLI_strcasecmp_natural(def_a->name, def_b->name); } /** diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index f7dda1defe8..ee86a583974 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -434,7 +434,7 @@ static int compare_name(void *UNUSED(user_data), const void *a1, const void *a2) name1 = entry1->name; name2 = entry2->name; - return BLI_natstrcmp(name1, name2); + return BLI_strcasecmp_natural(name1, name2); } static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2) @@ -461,7 +461,7 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2) name1 = entry1->name; name2 = entry2->name; - return BLI_natstrcmp(name1, name2); + return BLI_strcasecmp_natural(name1, name2); } static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2) @@ -488,7 +488,7 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2) name1 = entry1->name; name2 = entry2->name; - return BLI_natstrcmp(name1, name2); + return BLI_strcasecmp_natural(name1, name2); } static int compare_extension(void *UNUSED(user_data), const void *a1, const void *a2) @@ -546,7 +546,7 @@ static int compare_extension(void *UNUSED(user_data), const void *a1, const void name1 = entry1->name; name2 = entry2->name; - return BLI_natstrcmp(name1, name2); + return BLI_strcasecmp_natural(name1, name2); } void filelist_sort(struct FileList *filelist) diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 8cc57a82fe0..423dec13c69 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -441,7 +441,7 @@ static int ui_node_item_name_compare(const void *a, const void *b) { const bNodeType *type_a = *(const bNodeType **)a; const bNodeType *type_b = *(const bNodeType **)b; - return BLI_natstrcmp(type_a->ui_name, type_b->ui_name); + return BLI_strcasecmp_natural(type_a->ui_name, type_b->ui_name); } static bool ui_node_item_special_poll(const bNodeTree *UNUSED(ntree), const bNodeType *ntype) diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 41958656688..fd6a052b84d 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1627,7 +1627,7 @@ static int treesort_alpha_ob(const void *v1, const void *v2) return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; } - comp = BLI_natstrcmp(x1->name, x2->name); + comp = BLI_strcasecmp_natural(x1->name, x2->name); if (comp > 0) { return 1; @@ -1659,7 +1659,7 @@ static int treesort_alpha(const void *v1, const void *v2) const tTreeSort *x1 = v1, *x2 = v2; int comp; - comp = BLI_natstrcmp(x1->name, x2->name); + comp = BLI_strcasecmp_natural(x1->name, x2->name); if (comp > 0) { return 1; @@ -1697,7 +1697,7 @@ static int treesort_obtype_alpha(const void *v1, const void *v2) } } else { - int comp = BLI_natstrcmp(x1->name, x2->name); + int comp = BLI_strcasecmp_natural(x1->name, x2->name); if (comp > 0) { return 1; -- cgit v1.2.3