diff --git a/lib_util/cmdl_tools.c b/lib_util/cmdl_tools.c index bec772ce42f96eb8373d44aebc6cba944cdb288e..625db1273342f1b56eb20e12c5e31ffbf5ec7bc5 100644 --- a/lib_util/cmdl_tools.c +++ b/lib_util/cmdl_tools.c @@ -185,16 +185,16 @@ void convert_backslash( void remove_cr( char *str ) { - char *pos; + int32_t n, p = 0; /* remove all \r characters from the string */ - pos = strchr( str, '\r' ); - while ( pos != NULL ) + for ( n = 0; str[n] != 0; n++ ) { - strcpy( pos, pos + 1 ); - pos = strchr( pos, '\r' ); + char c = str[n]; + str[p] = c; + p += ( c == '\r' ) ? 0 : 1; } - + str[p] = 0; return; }