From 503c803b8d97e7997bc2a5c42eb6a2014d013528 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 26 Jan 2002 12:04:32 +0100 Subject: Fixed handling file names that contain single quotes or dollar signs in calls to external commands --- tools.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'tools.c') diff --git a/tools.c b/tools.c index de21af50..b18c0ef5 100644 --- a/tools.c +++ b/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) { -- cgit v1.2.3