On 12 March 2012 21:27, Michał Górny <mgo...@gentoo.org> wrote: > And we could just use a good regex for that instead. > > Something like: [eE][aA][pP][iI] <whitespace-or-symbols> [a-z0-9-+]+ > > and just require users for this to be the first thing declared in > an ebuild. Of course, this could make problems with stuff like: > > # EAPI 4 because of foobarbaz > EAPI=4 > > (on the other hand, in this particular case it will fetch '4' anyway). > > And this will work as well with: > > <eapi>15-xml</eapi> > > and > > - eapi: 15-yaml >
Also, remember the proposal is to read it only from the first 10-30 lines of the file, and if you're *generating* YAML/XML , then this is not necessarily guaranteed. Some generation tools emit keys in alphanumeric ordering, others psuedo-randomly, and the EAPI declaration line in some formats could easily be on the very last line of the file. And then the regexp could falsely detect something in another key the original author had not intended as an EAPI definition, but merely a comment, ... ie: <generateddata> <comment> This is a user comment, hurr, I hate EAPI 5 </comment> <eapi value="15" /> </generateddata> -- Kent perl -e "print substr( \"edrgmaM SPA NOcomil.ic\\@tfrken\", \$_ * 3, 3 ) for ( 9,8,0,7,1,6,5,4,3,2 );"