From ef472c756b09ba9b01a9627300ea1e3a1db33730 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 25 Apr 2006 21:24:23 +0000 Subject: Fix false variable.readonly match on continued lines. Thanks to Flameeyes for reporting. svn path=/main/trunk/; revision=3236 --- bin/repoman | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/repoman b/bin/repoman index 5c3b13193..f7f542a2d 100755 --- a/bin/repoman +++ b/bin/repoman @@ -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. -- cgit v1.2.3-65-gdbad