code-experiments/src/coco_string.c
/**
 * @brief Creates and returns a string with removed characters between from and to.
 *
 * If you wish to remove characters from the beginning of the string, set from to "".
 * If you wish to remove characters until the end of the string, set to to "".
 *
 * The caller is responsible for freeing the allocated memory using coco_free_memory().
 */
@brief Creates and returns a string with removed characters between from and to.
If you wish to remove characters from the beginning of the string, set from to "".
If you wish to remove characters until the end of the string, set to to "".

The caller is responsible for freeing the allocated memory using coco_free_memory().
@brief Creates and returns a string with removed characters between from and to . If you wish to remove characters from the beginning of the string set from to " " . If you wish to remove characters until the end of the string set to to " " . The caller is responsible for freeing the allocated memory using coco_free_memory () .
static char *coco_remove_from_string(const char *string, const char *from, const char *to) {
  char *result, *start, *stop;
  result = coco_strdup(string);
  if (strcmp(from, "") == 0) {
    start = result;
  } else
    start = strstr(result, from);
  if (strcmp(to, "") == 0) {
    stop = result + strlen(result);
  } else
    stop = strstr(result, to);
  if ((start == NULL) || (stop == NULL) || (stop < start)) {
    coco_error("coco_remove_from_string(): failed to remove characters between %s and %s from string %s",
        from, to, string);
    return NULL; 
  }
  memmove(start, stop, strlen(stop) + 1);
  return result;
}
static char * coco_remove_from_string ( const char * string , const char * from , const char * to ) { char * result , * start , * stop ; result = coco_strdup ( string ) ; if ( strcmp ( from , " " ) == 0 ) { start = result ; } else start = strstr ( result , from ) ; if ( strcmp ( to , " " ) == 0 ) { stop = result + strlen ( result ) ; } else stop = strstr ( result , to ) ; if ( ( start == NULL ) || ( stop == NULL ) || ( stop < start ) ) { coco_error ( " " , from , to , string ) ; return NULL ; } memmove ( start , stop , strlen ( stop ) + 1 ) ; return result ; }
@brief Creates and returns a string with removed characters between from and to.
@brief Creates and returns a string with removed characters between from and to .
/* Remove from the start */ /* Remove until the end */ /* Never reached */