Fixed handling file names that contain single quotes or dollar signs in calls to external commands

This commit is contained in:
Klaus Schmidinger
2002-01-26 12:04:32 +01:00
parent fe7b03d6b5
commit 503c803b8d
5 changed files with 35 additions and 8 deletions

25
tools.c
View File

@@ -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) {