diff options
author | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2023-04-03 16:20:09 +0200 |
---|---|---|
committer | Bartosz Golaszewski <bartosz.golaszewski@linaro.org> | 2023-04-04 09:03:56 +0200 |
commit | 8a864d669363308c43cc4a072c3911fc4bd933af (patch) | |
tree | 69dc34ddb9026af5be5010d5e05dcbac0cdd90ca | |
parent | 1147795bd140a563185b87a8c4411eacd4d61c08 (diff) | |
download | libgpiod-8a864d669363308c43cc4a072c3911fc4bd933af.tar.gz |
tools: replace alphasort() with versionsort()
Sorting chip names with alphasort() results in gpiochip2 coming after
gpiochip19 as it only find the lexicographic order of strings. Switching
to using versionsort() makes it look better and the order is more logical
with the numbering being taken into account.
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | tools/tools-common.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 7d72c247..c1005a92 100644 --- a/configure.ac +++ b/configure.ac @@ -119,7 +119,7 @@ AS_IF([test "x$with_tools" = xtrue], AC_CHECK_FUNC([daemon], [], [FUNC_NOT_FOUND_TOOLS([daemon])]) AC_CHECK_FUNC([asprintf], [], [FUNC_NOT_FOUND_LIB([asprintf])]) AC_CHECK_FUNC([scandir], [], [FUNC_NOT_FOUND_LIB([scandir])]) - AC_CHECK_FUNC([alphasort], [], [FUNC_NOT_FOUND_LIB([alphasort])]) + AC_CHECK_FUNC([versionsort], [], [FUNC_NOT_FOUND_LIB([versionsort])]) AS_IF([test "x$with_gpioset_interactive" = xtrue], [PKG_CHECK_MODULES([LIBEDIT], [libedit >= 3.1])]) ]) diff --git a/tools/tools-common.c b/tools/tools-common.c index e5f6fc1b..64592d32 100644 --- a/tools/tools-common.c +++ b/tools/tools-common.c @@ -469,7 +469,7 @@ int all_chip_paths(char ***paths_ptr) struct dirent **entries; char **paths; - num_chips = scandir("/dev/", &entries, chip_dir_filter, alphasort); + num_chips = scandir("/dev/", &entries, chip_dir_filter, versionsort); if (num_chips < 0) die_perror("unable to scan /dev"); |