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 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/blenlib') 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; -- cgit v1.2.3