mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Fixed handling file names that contain single quotes or dollar signs in calls to external commands
This commit is contained in:
25
tools.c
25
tools.c
@@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: tools.c 1.51 2002/01/20 15:43:35 kls Exp $
|
||||
* $Id: tools.c 1.52 2002/01/26 12:04:32 kls Exp $
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
@@ -136,6 +136,29 @@ char *compactspace(char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
const char *strescape(const char *s, const char *chars)
|
||||
{
|
||||
static char *buffer = NULL;
|
||||
const char *p = s;
|
||||
char *t = NULL;
|
||||
while (*p) {
|
||||
if (strchr(chars, *p)) {
|
||||
if (!t) {
|
||||
buffer = (char *)realloc(buffer, 2 * strlen(s) + 1);
|
||||
t = buffer + (p - s);
|
||||
s = strcpy(buffer, s);
|
||||
}
|
||||
*t++ = '\\';
|
||||
}
|
||||
if (t)
|
||||
*t++ = *p;
|
||||
p++;
|
||||
}
|
||||
if (t)
|
||||
*t = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
bool startswith(const char *s, const char *p)
|
||||
{
|
||||
while (*p) {
|
||||
|
||||
Reference in New Issue
Block a user