From 792857f38c02ad2f8c7be52803f00f03304d564e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= Date: Mon, 17 Sep 2012 19:21:38 +0300 Subject: Fix replacing with empty string at the beginning of a string when using s///. --- regexp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/regexp.c b/regexp.c index 919923d..e0529d3 100644 --- a/regexp.c +++ b/regexp.c @@ -129,6 +129,8 @@ void cRegexp::ParseRegexp(char *restring) regexp = strdup(&restring[2]); if (*(p+1) != '/') // replacement = strdup(p+1); + else + replacement = strdup(""); break; } } @@ -232,7 +234,7 @@ bool cRegexp::Apply(cEvent *Event) start_offset = ovector[1]; } // replace EPG field if regexp matched - if (**resultstring && (last_match_end < tmpstringlen-1)) { + if (last_match_end > 0 && (last_match_end < tmpstringlen-1)) { resultstring = cString::sprintf("%s%s", *resultstring, tmpstring+last_match_end); switch (source) { case REGEXP_TITLE: -- cgit v1.2.3