src/common/string.c
/**
 * Search a string for the last non whitespace character and place the index
 * of the character in the provided pointer.
 *
 * If no non-whitespace character is found in the supplied string return
 * NOT_FOUND_ERROR otherwise NO_ERROR
 */
Search a string for the last non whitespace character and place the index
of the character in the provided pointer.

If no non-whitespace character is found in the supplied string return
NOT_FOUND_ERROR otherwise NO_ERROR
Search a string for the last non whitespace character and place the index of the character in the provided pointer . If no non - whitespace character is found in the supplied string return NOT_FOUND_ERROR otherwise NO_ERROR
enum natwm_error string_find_last_nonspace(const char *string, size_t *index_result)
{
        if (string == NULL) {
                return INVALID_INPUT_ERROR;
        }
        char ch = '\0';
        size_t i = 0;
        size_t index = 0;
        bool found = false;
        while ((ch = string[i]) != '\0') {
                if (!isspace(ch)) {
                        index = i;
                        if (!found) {
                                found = true;
                        }
                }
                ++i;
        }
        *index_result = index;
        if (!found) {
                return NOT_FOUND_ERROR;
        }
        return NO_ERROR;
}
enum natwm_error string_find_last_nonspace ( const char * string , size_t * index_result ) { if ( string == NULL ) { return INVALID_INPUT_ERROR ; } char ch = ' \0 ' ; size_t i = 0 ; size_t index = 0 ; bool found = false ; while ( ( ch = string [ i ] ) != ' \0 ' ) { if ( ! isspace ( ch ) ) { index = i ; if ( ! found ) { found = true ; } } ++ i ; } * index_result = index ; if ( ! found ) { return NOT_FOUND_ERROR ; } return NO_ERROR ; }
Search a string for the last non whitespace character and place the index
 of the character in the provided pointer.
Search a string for the last non whitespace character and place the index of the character in the provided pointer .