summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-04-07 12:48:53 +0200
committerDave Davenport <qball@gmpclient.org>2020-04-07 12:48:53 +0200
commit34a278f943042084ee318e0fb059040643b9965a (patch)
treec7a98d7bfae72c0124c12d1f10be2db112aa2c9a
parentf63da72ea6fab13279e0fe437929ce4434f63c9f (diff)
[Combi] Remove strchrnull
Issue: #1083
-rw-r--r--configure.ac1
-rw-r--r--source/dialogs/combi.c13
2 files changed, 11 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 9526b291..7f366d05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -99,7 +99,6 @@ AC_CHECK_FUNC([fcntl],, AC_MSG_ERROR("Could not find fcntl"))
AC_CHECK_FUNC([setlocale],,AC_MSG_ERROR("Could not find setlocale"))
AC_CHECK_FUNC([atexit],, AC_MSG_ERROR("Could not find atexit in c library"))
AC_CHECK_FUNC([glob],, AC_MSG_ERROR("Could not find glob in c library"))
-AC_CHECK_FUNC([strchrnul],,AC_MSG_ERROR("Could not find strchrnul function in c library (gnu extension)"))
AC_CHECK_HEADER([math.h],, AC_MSG_ERROR("Could not find math.h header file"))
AC_SEARCH_LIBS([floor],[m],, AC_MSG_ERROR("Could not find floor in math library"))
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index c7cc2d4f..691afce9 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -156,7 +156,11 @@ static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned
if ( input[0][0] == '!' ) {
int switcher = -1;
- char *eob = strchrnul ( input[0], ' ' );
+ // Implement strchrnul behaviour.
+ char *eob = g_utf8_strchr ( input[0], -1,' ' );
+ if ( eob == NULL ) {
+ eob = &(input[0][strlen(input[0])]);
+ }
ssize_t bang_len = g_utf8_pointer_to_offset ( input[0], eob ) - 1;
if ( bang_len > 0 ) {
for ( unsigned i = 0; switcher == -1 && i < pd->num_switchers; i++ ) {
@@ -277,7 +281,12 @@ static char * combi_preprocess_input ( Mode *sw, const char *input )
pd->switchers[i].disable = FALSE;
}
if ( input != NULL && input[0] == '!' ) {
- char *eob = strchrnul ( input, ' ' );
+ // Implement strchrnul behaviour.
+ const char *eob = g_utf8_strchr ( input, -1, ' ' );
+ if ( eob == NULL ) {
+ // Set it to end.
+ eob = &(input[strlen(input)]);
+ }
ssize_t bang_len = g_utf8_pointer_to_offset ( input, eob ) - 1;
if ( bang_len > 0 ) {
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {