1 |
On Sun, Sep 30, 2012 at 11:13:31AM +0200, Ulrich Mueller wrote: |
2 |
> >>>>> On Sun, 30 Sep 2012, Brian Harring wrote: |
3 |
> |
4 |
> > The example regex allowed for |
5 |
> > EAPI= |
6 |
> |
7 |
> > Which isn't used, alloewd, nor desired; at best, that's short hand |
8 |
> > for EAPI=0. |
9 |
> |
10 |
> The regexp was never meant to match exactly what is allowed. |
11 |
> It matches a superset, and if the matched substring turns out to be an |
12 |
> illegal or unknown EAPI, then the PM can catch it after parsing. |
13 |
> |
14 |
> Otherwise, an empty EAPI is already forbidden by section 3.1 |
15 |
> "Restrictions upon Names". |
16 |
|
17 |
Going by the fact this sort of scenario has come up before for me, I |
18 |
guess I just do things differently. |
19 |
|
20 |
The rules are such that "either an EAPI is matched, or EAPI=0 if the |
21 |
first non blank/non comment isn't a matching EAPI assignment". |
22 |
|
23 |
You want the rules to be left as: |
24 |
|
25 |
"Here's this regex you use to find the EAPI. The actual rules of the |
26 |
EAPI value are off in another part of the doc that we're not going to |
27 |
refer to, but you need to make sure it still is valid despite this |
28 |
regex allowing invalid EAPI's in." |
29 |
|
30 |
Respectfully, that is daft since it's going to result in anyone who |
31 |
tries to write a PM, likely fucking that up. If what you were saying |
32 |
was the actual intention behind it, that assignment would've just been |
33 |
along the lines of EAPI=("[^"]*"|'[^']*'|[^\t ]); aka "here's how you |
34 |
grab what looks like an EAPI assignment". |
35 |
|
36 |
Either way, I strongly disagree with your counterargument of leaving |
37 |
the spec as it is. |
38 |
|
39 |
The following is saner: |
40 |
|
41 |
^[ \t]*EAPI=(['"]?)([A-Za-z0-9_][A-Za-z0-9+_.-]*)\1[ \t]*([ \t]#.*)?$ |
42 |
|
43 |
And the following multiline match covers the rules in full (ie, ready |
44 |
to go meaning people aren't likely to fuck it up): |
45 |
|
46 |
r"(?:^[ \t]*(?:#[^\n]*)?(?:$|\n))*^[ \t]*EAPI=(['\"]?)([A-Za-z0-9][A-Za-z0-9+_.-]*)\1" |
47 |
|
48 |
Roughly, if the spec is left the way you intend it, |
49 |
|
50 |
EAPI=-1 will get picked up, then it's reliant on the PM to spot |
51 |
it/explode; which in a quick check of portages source, it doesn't |
52 |
do. |
53 |
|
54 |
Now, if a QA tool wants to use a looser version to spot EAPI |
55 |
assignments of an invalid EAPI, have at it; but the core spec's "find |
56 |
an eapi via this" should block invalid EAPI's from being picked up, |
57 |
period. |
58 |
|
59 |
~harring |