summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2013-11-25 19:37:05 +0100
committerSven Eden <yamakuzure@gmx.net>2013-11-25 19:37:05 +0100
commit5762ce745351658babc388cd62a7f9ed5dfcb5c3 (patch)
tree704c1221c59b27b22a783d3e4b7dc1a7bef924cd
parentufed.pl/Portage.pm: Parsing error messages from eval are now chomp'ed (diff)
downloadufed-5762ce745351658babc388cd62a7f9ed5dfcb5c3.tar.gz
ufed-5762ce745351658babc388cd62a7f9ed5dfcb5c3.tar.bz2
ufed-5762ce745351658babc388cd62a7f9ed5dfcb5c3.zip
Extended the regular expressions used to parse found files following
a hint I got from perlmonks.
-rw-r--r--Portage.pm19
-rw-r--r--ufed.pl.in31
2 files changed, 41 insertions, 9 deletions
diff --git a/Portage.pm b/Portage.pm
index d3bed35..fc8ddd7 100644
--- a/Portage.pm
+++ b/Portage.pm
@@ -941,9 +941,20 @@ sub _read_sh {
my $BLANK = qr{(?:[ \n\t]+|#.*)+}; # whitespace and comments
my $IDENT = qr{([^ \\\n\t'"{}=#]+)}; # identifiers
my $ASSIG = qr{=}; # assignment operator
- my $UQVAL = qr{((?:[^ \\\n\t'"#]+|\\.)+)}s;# unquoted value
- my $SQVAL = qr{'([^']*)'}; # singlequoted value
- my $DQVAL = qr{"((?:[^\\"]|\\.)*)"}s; # doublequoted value
+ my $UQVAL = qr{((?: # guard to extend the character limit
+ [^ \\\n\t'"#]{1,32766} | # max 32766 of regular characters or
+ \\. # one escaped character
+ ){1,32766} # extend by 32766 sub matches
+ )}sx; # unquoted value
+ my $SQVAL = qr{'((?: # guard to extend the character limit
+ [^']{0,32766} # 0 to 32766 characters ...
+ ){0,32766} # ... up to 32766 times
+ )'}x; # singlequoted value
+ my $DQVAL = qr{"((?: # guard to extend the character limit
+ [^\\"]{0,32766} | # max 32766 non-escaped characters or
+ \\. # one escaped character
+ ){0,32766} # extend by up to 32766 sub matches
+ )"}sx; # doublequoted value
my %env;
if(open my $file, '<', $fname) {
@@ -957,7 +968,7 @@ sub _read_sh {
my $name = $1;
/\G$BLANK/gc;
if($name ne 'source') {
- /\G$ASSIG/gc or die "Bare keyword $name detected.";
+ /\G$ASSIG/gc or die "Bare keyword $name (pos " . pos . ") detected.";
/\G$BLANK/gc;
}
pos == length and die "Bumped into unexpected EOF after $name.";
diff --git a/ufed.pl.in b/ufed.pl.in
index 3d1e354..17f4c7a 100644
--- a/ufed.pl.in
+++ b/ufed.pl.in
@@ -177,11 +177,32 @@ sub save_flags {
\#.*)+}x;
my $IDENT = qr{([^ \\\n\t'"{}=#]+)}; # identifiers
my $ASSIG = qr{=}; # assignment operator
- my $UQVAL = qr{(?:[^ \\\n\t'"#]+|\\.)+}s; # unquoted value
- my $SQVAL = qr{'[^']*'}; # singlequoted value
- my $DQVAL = qr{"(?:[^\\"]|\\.)*"}s; # doublequoted value
- my $BNUQV = qr{(?:[^ \\\n\t'"#]+|\\\n()|\\.)+}s;# unquoted value (scan for \\\n)
- my $BNDQV = qr{"(?:[^\\"]|\\\n()|\\.)*"}s; # doublequoted value (scan for \\\n)
+ my $UQVAL = qr{(?: # guard to extend the character limit
+ [^ \\\n\t'"#]{1,32766} | # max 32766 of regular characters or
+ \\. # one escaped character
+ ){1,32766} # extend by 32766 sub matches
+ }sx; # unquoted value
+ my $SQVAL = qr{'(?: # guard to extend the character limit
+ [^']{0,32766} # 0 to 32766 characters ...
+ ){0,32766} # ... up to 32766 times
+ '}x; # singlequoted value
+ my $DQVAL = qr{"(?: # guard to extend the character limit
+ [^\\"]{0,32766} | # max 32766 non-escaped characters or
+ \\. # one escaped character
+ ){0,32766} # extend by up to 32766 sub matches
+ "}sx; # doublequoted value
+ my $BNUQV = qr{(?:
+ [^ \\\n\t'"#]{1,32766} | # Anything but escapes, quotes and so on
+ \\\n() | # or a backslash followed by a newline
+ \\. # or any other escape sequence
+ ){1,32766} # extended like above
+ }sx; # unquoted value (scan for \\\n)
+ my $BNDQV = qr{"(?:(?: # double guard to extend more freely
+ [^\\"] | # Anything but a backslash or double quote
+ \\\n() | # or a backslash and a newline
+ \\. # or any other escaped value
+ ){0,32766}){0,32766} # max 32766*32766 matches.
+ "}sx; # doublequoted value (scan for \\\n)
my $contents;