/[smecontribs]/rpms/perl-KinoSearch1/contribs10/KinoSearch1-1.01-Do-not-use-C-in-regexps.patch
ViewVC logotype

Contents of /rpms/perl-KinoSearch1/contribs10/KinoSearch1-1.01-Do-not-use-C-in-regexps.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Mar 16 05:37:04 2022 UTC (2 years, 8 months ago) by jpp
Branch: MAIN
CVS Tags: perl-KinoSearch1-1_01-36_el7_sme, HEAD
Error occurred while calculating annotation data.
Initial import

1 From 90b55f6267fa139df653147a106c8a58925fd451 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
3 Date: Thu, 19 May 2016 17:02:21 +0200
4 Subject: [PATCH] Do not use \C in regexps
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Pelr 5.24.0 removed support for \C (bytes positions). This patch
10 rewrites the tests for the ungreedy sequence of bytes with a miximum
11 size.
12
13 CPAN RT#105144
14
15 Signed-off-by: Petr Písař <ppisar@redhat.com>
16 ---
17 lib/KinoSearch1/Highlight/Highlighter.pm | 23 +++++++++++++++--------
18 1 file changed, 15 insertions(+), 8 deletions(-)
19
20 diff --git a/lib/KinoSearch1/Highlight/Highlighter.pm b/lib/KinoSearch1/Highlight/Highlighter.pm
21 index bb8f910..50faca7 100644
22 --- a/lib/KinoSearch1/Highlight/Highlighter.pm
23 +++ b/lib/KinoSearch1/Highlight/Highlighter.pm
24 @@ -84,32 +84,39 @@ sub generate_excerpt {
25 $text = bytes::substr( $text, $top );
26
27 # try to start the excerpt at a sentence boundary
28 - if ($text =~ s/
29 + if ($text =~ /
30 \A
31 (
32 - \C{0,$limit}?
33 + (.*?)
34 \.\s+
35 )
36 - //xsm
37 + /xsm
38 + and bytes::length($2) <= $limit
39 )
40 {
41 - $top += bytes::length($1);
42 + my $bytes_length = bytes::length($1);
43 + $text = bytes::substr($text, $bytes_length);
44 + $top += $bytes_length;
45 }
46 # no sentence boundary, so we'll need an ellipsis
47 else {
48 # skip past possible partial tokens, prepend an ellipsis
49 - if ($text =~ s/
50 + if ($text =~ /
51 \A
52 (
53 - \C{0,$limit}? # don't go outside the window
54 + (.*?) # don't go outside the window
55 $token_re # match possible partial token
56 .*? # ... and any junk following that token
57 )
58 (?=$token_re) # just before the start of a full token...
59 - /... /xsm # ... insert an ellipsis
60 + /xsm
61 + and bytes::length($2) <= $limit # don't go outside the window
62 )
63 {
64 - $top += bytes::length($1);
65 + my $bytes_length = bytes::length($1);
66 + # ... insert an ellipsis
67 + $text = '... ' . bytes::substr($text, $bytes_length);
68 + $top += $bytes_length;
69 $top -= 4 # three dots and a space
70 }
71 }
72 --
73 2.5.5
74

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed