src/libs/mpv/mpv.c
//
// Transform folder & filenames that might have double-quotes or
// back-quotes in them so that we can safely wrap the whole path in
// double-quotes.
//
Transform folder & filenames that might have double-quotes or
back-quotes in them so that we can safely wrap the whole path in
double-quotes.
Transform folder & filenames that might have double - quotes or back - quotes in them so that we can safely wrap the whole path in double - quotes .
static char* quotify(char* original, char** saved_replacement) {
  if (strchr(original, '"') == NULL && strchr(original, '\\') == NULL) {
    return original;
  }
  else {
    char* dst = *saved_replacement = malloc(strlen(original) * 2 + 1);
    char* src = original;
    while(*src) {
      if (*src == '"' || *src == '\\')
        *dst++ = '\\';
      *dst++ = *src++;
    }
    *dst++ = 0;
    return *saved_replacement;
  }
}
static char * quotify ( char * original , char * * saved_replacement ) { if ( strchr ( original , ' ' ) == NULL && strchr ( original , ' \\ ' ) == NULL ) { return original ; } else { char * dst = * saved_replacement = malloc ( strlen ( original ) * 2 + 1 ) ; char * src = original ; while ( * src ) { if ( * src == ' ' || * src == ' \\ ' ) * dst ++ = ' \\ ' ; * dst ++ = * src ++ ; } * dst ++ = 0 ; return * saved_replacement ; } }
Transform folder & filenames that might have double-quotes or
back-quotes in them so that we can safely wrap the whole path in
double-quotes.
Transform folder & filenames that might have double - quotes or back - quotes in them so that we can safely wrap the whole path in double - quotes .