From 46d6a6def297615cb65bc96c921def6777c51747 Mon Sep 17 00:00:00 2001 From: Tom Hebb Date: Wed, 3 Jun 2020 11:57:21 -0700 Subject: [PATCH] Replace index() call with strchr() call According to glibc documentation[1], "index is another name for strchr; they are exactly the same. New code should always use strchr." The use of index() breaks compilation for Android targets, which use Bionic instead of glibc and don't have index(). [1] https://www.gnu.org/software/libc/manual/html_node/Search-Functions.html#index-index --- common.c | 2 +- tests/12.0.1/common.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.c b/common.c index bf55e05..c30bdc8 100644 --- a/common.c +++ b/common.c @@ -1478,7 +1478,7 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char strncpy(range, t, 16); range[15] = '\0'; valstr = t; - if ((s = index(range, '-')) != NULL) { + if ((s = strchr(range, '-')) != NULL) { /* Possible range of values */ *s = '\0'; if (parse_valstr(range, max_val, &val_low) || (val_low < 0)) diff --git a/tests/12.0.1/common.c b/tests/12.0.1/common.c index 25ab1fc..b623a4c 100644 --- a/tests/12.0.1/common.c +++ b/tests/12.0.1/common.c @@ -1403,7 +1403,7 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char strncpy(range, t, 16); range[15] = '\0'; valstr = t; - if ((s = index(range, '-')) != NULL) { + if ((s = strchr(range, '-')) != NULL) { /* Possible range of values */ *s = '\0'; if (parse_valstr(range, max_val, &val_low) || (val_low < 0)) -- 2.40.0