[vlc-commits] directory: fix compare between digit and nondigit
Thomas Guillem
git at videolan.org
Fri Mar 10 18:50:17 CET 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Mar 10 15:10:27 2017 +0100| [df8468293c7a4783a1cd6ea90fef4a8625f25689] | committer: Thomas Guillem
directory: fix compare between digit and nondigit
strcoll should be used if a or b are nondigit.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=df8468293c7a4783a1cd6ea90fef4a8625f25689
---
src/input/access.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/input/access.c b/src/input/access.c
index ed3e40f..bf5a22c 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -345,7 +345,7 @@ static int compar_filename(const void *a, const void *b)
return i_ret;
size_t i;
- char c;
+ char ca, cb;
/* Attempt to guess if the sorting algorithm should be alphabetic
* (i.e. collation) or numeric:
@@ -358,11 +358,11 @@ static int compar_filename(const void *a, const void *b)
* - Otherwise, the comparands are numerical values, and might not be
* aligned (i.e. not same order of magnitude). If so, collation would
* fail. So numerical comparison is performed. */
- for (i = 0; (c = ia->psz_name[i]) == ib->psz_name[i]; i++)
- if (c == '\0')
+ for (i = 0; (ca = ia->psz_name[i]) == (cb = ib->psz_name[i]); i++)
+ if (ca == '\0')
return 0; /* strings are exactly identical */
- if ((unsigned)(c - '0') > 9)
+ if ((unsigned)(ca - '0') > 9 || (unsigned)(cb - '0') > 9)
return strcoll(ia->psz_name, ib->psz_name);
unsigned long long ua = strtoull(ia->psz_name + i, NULL, 10);
More information about the vlc-commits
mailing list