[Fai-commit] r4000 - trunk/bin
fai-commit at lists.alioth.debian.org
fai-commit at lists.alioth.debian.org
Thu Sep 21 15:40:28 UTC 2006
Author: lange
Date: 2006-09-21 15:40:28 +0000 (Thu, 21 Sep 2006)
New Revision: 4000
Modified:
trunk/bin/ainsl
Log:
escape ( and ) in pattern
Modified: trunk/bin/ainsl
===================================================================
--- trunk/bin/ainsl 2006-09-21 13:49:41 UTC (rev 3999)
+++ trunk/bin/ainsl 2006-09-21 15:40:28 UTC (rev 4000)
@@ -27,7 +27,7 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#*********************************************************************
-my $version = "Version 0.1, 21-september-2006";
+my $version = "Version 0.2, 21-september-2006";
use Getopt::Std;
@@ -64,21 +64,25 @@
$found = 0;
usage() unless defined $line;
-print "FILE: $filename LINE: $line PATTERN $pattern\n";
+print "FILE: $filename\nLINE: $line\nPATTERN $pattern\n" if $debug;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$pattern = (defined $optpattern) ? $optpattern: $line;
# process pattern and line
-$opt_s && $pattern=~ s/\s+/\\s+/;
+$opt_s && $pattern=~ s/\s+/\\s+/g;
# remove ^ and $ in line (only at start and end), but still use it for pattern
# in no explicit pattern was given
unless (defined $optpattern) {
+# remove special chars ^ and $ from line
$line =~ s/^\^//;
$line =~ s/\$$//;
+# escape '(' and ')' if no pattern was given and line is used
+ $pattern =~s/\(/\\(/g;
+ $pattern =~s/\)/\\)/g;
}
-print "newpattern: $pattern\n" if $debug;
+print "newpattern: $pattern XXX $pat\n" if $debug;
print "newline: $line\n" if $debug;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# check if pattern already included in file
More information about the Fai-commit
mailing list