Fix false variable.readonly match on continued lines. Thanks to Flameeyes for reporting.
authorZac Medico <zmedico@gentoo.org>
Tue, 25 Apr 2006 21:24:23 +0000 (21:24 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 25 Apr 2006 21:24:23 +0000 (21:24 -0000)
svn path=/main/trunk/; revision=3236

bin/repoman

index 5c3b1319369e00b8304146292bc83f36f6201a4d..f7f542a2d720664d5d01dc234ca2515114c7791f 100755 (executable)
@@ -1219,6 +1219,7 @@ for x in scanlist:
                line_continuation_quoted = re.compile(r'(\"|\')(([\w ,:;#\[\]\.`=/|\$\^\*{}()\'-])|(\\.))*\1')
                line_continuation = re.compile(r'([^#]*\S)(\s+|\t)\\$')
                linenum=0
+               previous_line = None
                for line in input(checkdir+"/"+y+".ebuild"):
                        linenum += 1
                        # Gentoo copyright check
@@ -1262,7 +1263,9 @@ for x in scanlist:
                                                fails["ebuild.minorsyn"].append(x+"/"+y+".ebuild: %s" % myerrormsg)
                                        # Readonly variable assignment check
                                        match = readonly_assignment.match(line)
-                                       if match:
+                                       # The regex can give a false positive for continued lines,
+                                       # so we check the previous line to see if it was continued.
+                                       if match and (not previous_line or not line_continuation.match(previous_line)):
                                                # invalid assignment, very bad!
                                                myerrormsg = "Readonly variable assignment to %s on line %d" % (match.group(2), linenum)
                                                stats["variable.readonly"] += 1
@@ -1283,6 +1286,8 @@ for x in scanlist:
                                                                myerrormsg = "Line continuation (\"\\\") Syntax Error. Line %d" % linenum
                                                                stats["ebuild.majorsyn"] +=1
                                                                fails["ebuild.majorsyn"].append(x+"/"+y+".ebuild: %s" % myerrormsg)
+                       previous_line = line
+               del previous_line
 
        # Check for 'all unstable' or 'all masked' -- ACCEPT_KEYWORDS is stripped
        # XXX -- Needs to be implemented in dep code. Can't determine ~arch nicely.