[Combi] Remove strchrnull

Issue: #1083
This commit is contained in:
Dave Davenport 2020-04-07 12:48:53 +02:00
parent f63da72ea6
commit 34a278f943
2 changed files with 11 additions and 3 deletions

View file

@ -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"))

View file

@ -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++ ) {