|
|
1de6a77 |
From 2b099cc01701e784fa5b1c53f38fd592b0b3ae42 Mon Sep 17 00:00:00 2001
|
|
|
1de6a77 |
From: =?UTF-8?q?Matti=20Lehtim=C3=A4ki?= <matti.lehtimaki@gmail.com>
|
|
|
1de6a77 |
Date: Sun, 2 Dec 2012 18:03:29 +0200
|
|
|
1de6a77 |
Subject: [PATCH] Fix replacing at the end of string when using s///. Fix
|
|
|
1de6a77 |
variable name clash.
|
|
|
1de6a77 |
|
|
|
1de6a77 |
---
|
|
|
1de6a77 |
regexp.c | 28 ++++++++++++++--------------
|
|
|
1de6a77 |
1 file changed, 14 insertions(+), 14 deletions(-)
|
|
|
1de6a77 |
|
|
|
1de6a77 |
diff --git a/regexp.c b/regexp.c
|
|
|
1de6a77 |
index 4631cbd..8392586 100644
|
|
|
1de6a77 |
--- a/regexp.c
|
|
|
1de6a77 |
+++ b/regexp.c
|
|
|
1de6a77 |
@@ -221,7 +221,7 @@ bool cRegexp::Apply(cEvent *Event)
|
|
|
1de6a77 |
start_offset = ovector[1];
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
// replace EPG field if regexp matched
|
|
|
1de6a77 |
- if (last_match_end > 0 && (last_match_end < tmpstringlen - 1)) {
|
|
|
1de6a77 |
+ if (last_match_end > 0 && (last_match_end <= tmpstringlen)) {
|
|
|
1de6a77 |
resultstring = cString::sprintf("%s%s", *resultstring, tmpstring + last_match_end);
|
|
|
1de6a77 |
switch (source) {
|
|
|
1de6a77 |
case REGEXP_TITLE:
|
|
|
1de6a77 |
@@ -240,7 +240,7 @@ bool cRegexp::Apply(cEvent *Event)
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
else {// use backreferences
|
|
|
1de6a77 |
- const char *string;
|
|
|
1de6a77 |
+ const char *capturestring;
|
|
|
1de6a77 |
rc = pcre_exec(re, sd, *tmpstring, strlen(*tmpstring), 0, 0, ovector, OVECCOUNT);
|
|
|
1de6a77 |
if (rc == 0) {
|
|
|
1de6a77 |
error("maximum number of captured substrings is %d\n", OVECCOUNT / 3 - 1);
|
|
|
1de6a77 |
@@ -250,51 +250,51 @@ bool cRegexp::Apply(cEvent *Event)
|
|
|
1de6a77 |
// loop through all possible backreferences
|
|
|
1de6a77 |
// TODO allow duplicate backreference names?
|
|
|
1de6a77 |
while (i < 10) {
|
|
|
1de6a77 |
- if (pcre_get_named_substring(re, tmpstring, ovector, rc, strBackrefs[i], &string) != PCRE_ERROR_NOSUBSTRING) {
|
|
|
1de6a77 |
+ if (pcre_get_named_substring(re, tmpstring, ovector, rc, strBackrefs[i], &capturestring) != PCRE_ERROR_NOSUBSTRING) {
|
|
|
1de6a77 |
switch (i) {
|
|
|
1de6a77 |
case ATITLE:
|
|
|
1de6a77 |
case PTITLE:
|
|
|
1de6a77 |
if (Event->Title()) {
|
|
|
1de6a77 |
if (i == ATITLE)
|
|
|
1de6a77 |
- Event->SetTitle(*cString::sprintf("%s %s", Event->Title(), string));
|
|
|
1de6a77 |
+ Event->SetTitle(*cString::sprintf("%s %s", Event->Title(), capturestring));
|
|
|
1de6a77 |
else
|
|
|
1de6a77 |
- Event->SetTitle(*cString::sprintf("%s %s", string, Event->Title()));
|
|
|
1de6a77 |
+ Event->SetTitle(*cString::sprintf("%s %s", capturestring, Event->Title()));
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
case TITLE:
|
|
|
1de6a77 |
- Event->SetTitle(string);
|
|
|
1de6a77 |
+ Event->SetTitle(capturestring);
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
case ASHORTTEXT:
|
|
|
1de6a77 |
case PSHORTTEXT:
|
|
|
1de6a77 |
if (Event->ShortText()) {
|
|
|
1de6a77 |
if (i == ASHORTTEXT)
|
|
|
1de6a77 |
- Event->SetShortText(*cString::sprintf("%s %s", Event->ShortText(), string));
|
|
|
1de6a77 |
+ Event->SetShortText(*cString::sprintf("%s %s", Event->ShortText(), capturestring));
|
|
|
1de6a77 |
else
|
|
|
1de6a77 |
- Event->SetShortText(*cString::sprintf("%s %s", string, Event->ShortText()));
|
|
|
1de6a77 |
+ Event->SetShortText(*cString::sprintf("%s %s", capturestring, Event->ShortText()));
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
case SHORTTEXT:
|
|
|
1de6a77 |
- Event->SetShortText(string);
|
|
|
1de6a77 |
+ Event->SetShortText(capturestring);
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
case ADESCRIPTION:
|
|
|
1de6a77 |
case PDESCRIPTION:
|
|
|
1de6a77 |
if (Event->Description()) {
|
|
|
1de6a77 |
if (i == ADESCRIPTION)
|
|
|
1de6a77 |
- Event->SetDescription(*cString::sprintf("%s %s", Event->Description(), string));
|
|
|
1de6a77 |
+ Event->SetDescription(*cString::sprintf("%s %s", Event->Description(), capturestring));
|
|
|
1de6a77 |
else
|
|
|
1de6a77 |
- Event->SetDescription(*cString::sprintf("%s %s", string, Event->Description()));
|
|
|
1de6a77 |
+ Event->SetDescription(*cString::sprintf("%s %s", capturestring, Event->Description()));
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
case DESCRIPTION:
|
|
|
1de6a77 |
- Event->SetDescription(string);
|
|
|
1de6a77 |
+ Event->SetDescription(capturestring);
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
case RATING:
|
|
|
1de6a77 |
- Event->SetParentalRating(atoi(string));
|
|
|
1de6a77 |
+ Event->SetParentalRating(atoi(capturestring));
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
default:
|
|
|
1de6a77 |
break;
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
- pcre_free_substring(string);
|
|
|
1de6a77 |
+ pcre_free_substring(capturestring);
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
++i;
|
|
|
1de6a77 |
}
|
|
|
1de6a77 |
--
|
|
|
1de6a77 |
1.9.0
|
|
|
1de6a77 |
|