src/common/string.c
/**
 * Strip the surrounding spaces from a string. The first nonspace and last
 * nonspace characters are found, the source string is then spliced and the
 * resulting characters are allocated into the supplied dest buffer.
 *
 * If there is an error during any step in the process that error is returned
 * to the caller and the dest pointer remains unchanged. If there are no issues
 * the stripped string is placed in the dest pointer and the resulting strlen
 * is placed in the length pointer.
 *
 * If no errors are encountered NO_ERROR is returned
 */
Strip the surrounding spaces from a string. The first nonspace and last
nonspace characters are found, the source string is then spliced and the
resulting characters are allocated into the supplied dest buffer.

If there is an error during any step in the process that error is returned
to the caller and the dest pointer remains unchanged. If there are no issues
the stripped string is placed in the dest pointer and the resulting strlen
is placed in the length pointer.

If no errors are encountered NO_ERROR is returned
Strip the surrounding spaces from a string . The first nonspace and last nonspace characters are found the source string is then spliced and the resulting characters are allocated into the supplied dest buffer . If there is an error during any step in the process that error is returned to the caller and the dest pointer remains unchanged . If there are no issues the stripped string is placed in the dest pointer and the resulting strlen is placed in the length pointer . If no errors are encountered NO_ERROR is returned
enum natwm_error string_strip_surrounding_spaces(const char *string, char **dest, size_t *length)
{
        size_t start = 0;
        size_t end = 0;
        size_t length_result = 0;
        enum natwm_error err = GENERIC_ERROR;
        err = string_find_first_nonspace(string, &start);
        if (err != NO_ERROR) {
                return err;
        }
        err = string_find_last_nonspace(string, &end);
        if (err != NO_ERROR) {
                return err;
        }
        err = string_splice(string, start, end + 1, dest, &length_result);
        SET_IF_NON_NULL(length, length_result);
        return err;
}
enum natwm_error string_strip_surrounding_spaces ( const char * string , char * * dest , size_t * length ) { size_t start = 0 ; size_t end = 0 ; size_t length_result = 0 ; enum natwm_error err = GENERIC_ERROR ; err = string_find_first_nonspace ( string , & start ) ; if ( err != NO_ERROR ) { return err ; } err = string_find_last_nonspace ( string , & end ) ; if ( err != NO_ERROR ) { return err ; } err = string_splice ( string , start , end + 1 , dest , & length_result ) ; SET_IF_NON_NULL ( length , length_result ) ; return err ; }
Strip the surrounding spaces from a string.
Strip the surrounding spaces from a string .