mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 19:22:40 +01:00
Improve text search in c99std/c11std modules
Regular expression special characters are now escaped. A trailing word-boundary is added to limit results to exact matches.
This commit is contained in:
parent
f9e2c3fb49
commit
4116afb86d
@ -86,7 +86,9 @@ if($list_only) {
|
|||||||
$result = "Sections containing '$search':\n ";
|
$result = "Sections containing '$search':\n ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$search =~ s/\s/\\s+/g;
|
my $qsearch = quotemeta $search;
|
||||||
|
$qsearch =~ s/\\ / /g;
|
||||||
|
$qsearch =~ s/\s+/\\s+/g;
|
||||||
|
|
||||||
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||||
$this_section = $1;
|
$this_section = $1;
|
||||||
@ -138,7 +140,7 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
|||||||
|
|
||||||
if(length $search) {
|
if(length $search) {
|
||||||
eval {
|
eval {
|
||||||
if($t =~ m/\b$search/mis or $section_title =~ m/\b$search/mis) {
|
if($t =~ m/\b$qsearch\b/mis or $section_title =~ m/\b$qsearch\b/mis) {
|
||||||
$matches++;
|
$matches++;
|
||||||
if($matches >= $match) {
|
if($matches >= $match) {
|
||||||
if($list_only) {
|
if($list_only) {
|
||||||
|
@ -86,7 +86,9 @@ if($list_only) {
|
|||||||
$result = "Sections containing '$search':\n ";
|
$result = "Sections containing '$search':\n ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$search =~ s/\s/\\s+/g;
|
my $qsearch = quotemeta $search;
|
||||||
|
$qsearch =~ s/\\ / /g;
|
||||||
|
$qsearch =~ s/\s+/\\s+/g;
|
||||||
|
|
||||||
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
||||||
$this_section = $1;
|
$this_section = $1;
|
||||||
@ -137,7 +139,7 @@ while($text =~ m/^\s{0,4}([0-9A-Z]+\.[0-9\.]*)/msg) {
|
|||||||
|
|
||||||
if(length $search) {
|
if(length $search) {
|
||||||
eval {
|
eval {
|
||||||
if($t =~ m/\b$search/mis or $section_title =~ m/\b$search/mis) {
|
if($t =~ m/\b$qsearch\b/mis or $section_title =~ m/\b$qsearch\b/mis) {
|
||||||
$matches++;
|
$matches++;
|
||||||
if($matches >= $match) {
|
if($matches >= $match) {
|
||||||
if($list_only) {
|
if($list_only) {
|
||||||
|
Loading…
Reference in New Issue
Block a user