1 |
commit: 5762ce745351658babc388cd62a7f9ed5dfcb5c3 |
2 |
Author: Sven Eden <yamakuzure <AT> gmx <DOT> net> |
3 |
AuthorDate: Mon Nov 25 18:37:05 2013 +0000 |
4 |
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de> |
5 |
CommitDate: Mon Nov 25 18:37:05 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=5762ce74 |
7 |
|
8 |
Extended the regular expressions used to parse found files following |
9 |
a hint I got from perlmonks. |
10 |
|
11 |
--- |
12 |
Portage.pm | 19 +++++++++++++++---- |
13 |
ufed.pl.in | 31 ++++++++++++++++++++++++++----- |
14 |
2 files changed, 41 insertions(+), 9 deletions(-) |
15 |
|
16 |
diff --git a/Portage.pm b/Portage.pm |
17 |
index d3bed35..fc8ddd7 100644 |
18 |
--- a/Portage.pm |
19 |
+++ b/Portage.pm |
20 |
@@ -941,9 +941,20 @@ sub _read_sh { |
21 |
my $BLANK = qr{(?:[ \n\t]+|#.*)+}; # whitespace and comments |
22 |
my $IDENT = qr{([^ \\\n\t'"{}=#]+)}; # identifiers |
23 |
my $ASSIG = qr{=}; # assignment operator |
24 |
- my $UQVAL = qr{((?:[^ \\\n\t'"#]+|\\.)+)}s;# unquoted value |
25 |
- my $SQVAL = qr{'([^']*)'}; # singlequoted value |
26 |
- my $DQVAL = qr{"((?:[^\\"]|\\.)*)"}s; # doublequoted value |
27 |
+ my $UQVAL = qr{((?: # guard to extend the character limit |
28 |
+ [^ \\\n\t'"#]{1,32766} | # max 32766 of regular characters or |
29 |
+ \\. # one escaped character |
30 |
+ ){1,32766} # extend by 32766 sub matches |
31 |
+ )}sx; # unquoted value |
32 |
+ my $SQVAL = qr{'((?: # guard to extend the character limit |
33 |
+ [^']{0,32766} # 0 to 32766 characters ... |
34 |
+ ){0,32766} # ... up to 32766 times |
35 |
+ )'}x; # singlequoted value |
36 |
+ my $DQVAL = qr{"((?: # guard to extend the character limit |
37 |
+ [^\\"]{0,32766} | # max 32766 non-escaped characters or |
38 |
+ \\. # one escaped character |
39 |
+ ){0,32766} # extend by up to 32766 sub matches |
40 |
+ )"}sx; # doublequoted value |
41 |
|
42 |
my %env; |
43 |
if(open my $file, '<', $fname) { |
44 |
@@ -957,7 +968,7 @@ sub _read_sh { |
45 |
my $name = $1; |
46 |
/\G$BLANK/gc; |
47 |
if($name ne 'source') { |
48 |
- /\G$ASSIG/gc or die "Bare keyword $name detected."; |
49 |
+ /\G$ASSIG/gc or die "Bare keyword $name (pos " . pos . ") detected."; |
50 |
/\G$BLANK/gc; |
51 |
} |
52 |
pos == length and die "Bumped into unexpected EOF after $name."; |
53 |
|
54 |
diff --git a/ufed.pl.in b/ufed.pl.in |
55 |
index 3d1e354..17f4c7a 100644 |
56 |
--- a/ufed.pl.in |
57 |
+++ b/ufed.pl.in |
58 |
@@ -177,11 +177,32 @@ sub save_flags { |
59 |
\#.*)+}x; |
60 |
my $IDENT = qr{([^ \\\n\t'"{}=#]+)}; # identifiers |
61 |
my $ASSIG = qr{=}; # assignment operator |
62 |
- my $UQVAL = qr{(?:[^ \\\n\t'"#]+|\\.)+}s; # unquoted value |
63 |
- my $SQVAL = qr{'[^']*'}; # singlequoted value |
64 |
- my $DQVAL = qr{"(?:[^\\"]|\\.)*"}s; # doublequoted value |
65 |
- my $BNUQV = qr{(?:[^ \\\n\t'"#]+|\\\n()|\\.)+}s;# unquoted value (scan for \\\n) |
66 |
- my $BNDQV = qr{"(?:[^\\"]|\\\n()|\\.)*"}s; # doublequoted value (scan for \\\n) |
67 |
+ my $UQVAL = qr{(?: # guard to extend the character limit |
68 |
+ [^ \\\n\t'"#]{1,32766} | # max 32766 of regular characters or |
69 |
+ \\. # one escaped character |
70 |
+ ){1,32766} # extend by 32766 sub matches |
71 |
+ }sx; # unquoted value |
72 |
+ my $SQVAL = qr{'(?: # guard to extend the character limit |
73 |
+ [^']{0,32766} # 0 to 32766 characters ... |
74 |
+ ){0,32766} # ... up to 32766 times |
75 |
+ '}x; # singlequoted value |
76 |
+ my $DQVAL = qr{"(?: # guard to extend the character limit |
77 |
+ [^\\"]{0,32766} | # max 32766 non-escaped characters or |
78 |
+ \\. # one escaped character |
79 |
+ ){0,32766} # extend by up to 32766 sub matches |
80 |
+ "}sx; # doublequoted value |
81 |
+ my $BNUQV = qr{(?: |
82 |
+ [^ \\\n\t'"#]{1,32766} | # Anything but escapes, quotes and so on |
83 |
+ \\\n() | # or a backslash followed by a newline |
84 |
+ \\. # or any other escape sequence |
85 |
+ ){1,32766} # extended like above |
86 |
+ }sx; # unquoted value (scan for \\\n) |
87 |
+ my $BNDQV = qr{"(?:(?: # double guard to extend more freely |
88 |
+ [^\\"] | # Anything but a backslash or double quote |
89 |
+ \\\n() | # or a backslash and a newline |
90 |
+ \\. # or any other escaped value |
91 |
+ ){0,32766}){0,32766} # max 32766*32766 matches. |
92 |
+ "}sx; # doublequoted value (scan for \\\n) |
93 |
|
94 |
my $contents; |