[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Make the redox script sorta work again.



commit c3dd2e3d9e1b307862313293f03554807649b5d5
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Mar 25 11:01:09 2014 -0400

    Make the redox script sorta work again.
---
 contrib/redox.py |   23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/contrib/redox.py b/contrib/redox.py
index e9914da..550f846 100755
--- a/contrib/redox.py
+++ b/contrib/redox.py
@@ -62,7 +62,7 @@ KINDS = [ "type", "field", "typedef", "define", "function", "variable",
 
 NODOC_LINE_RE = re.compile(r'^([^:]+):(\d+): (\w+): (.*) is not documented\.$')
 
-THING_RE = re.compile(r'^Member ([a-zA-Z0-9_]+).*\((typedef|define|function|variable|enumeration)\) of (file|class) ')
+THING_RE = re.compile(r'^Member ([a-zA-Z0-9_]+).*\((typedef|define|function|variable|enumeration|macro definition)\) of (file|class) ')
 
 SKIP_NAMES = [re.compile(s) for s in SKIP_NAME_PATTERNS]
 
@@ -105,9 +105,13 @@ def findline(lines, lineno, ident):
     """Given a list of all the lines in the file (adjusted so 1-indexing works),
        a line number that ident is alledgedly on, and ident, I figure out
        the line where ident was really declared."""
+    lno = lineno
     for lineno in xrange(lineno, 0, -1):
-        if ident in lines[lineno]:
-            return lineno
+        try:
+            if ident in lines[lineno]:
+                return lineno
+        except IndexError:
+            continue
 
     return None
 
@@ -126,8 +130,16 @@ def hascomment(lines, lineno, kind):
 def hasdocdoc(lines, lineno, kind):
     """I return true if it looks like there's already a docdoc comment about
        the thing on lineno of lines of type kind."""
-    if "DOCDOC" in lines[lineno] or "DOCDOC" in lines[lineno-1]:
-        return True
+    try:
+        if "DOCDOC" in lines[lineno]:
+            return True
+    except IndexError:
+        pass
+    try:
+        if "DOCDOC" in lines[lineno-1]:
+            return True
+    except IndexError:
+        pass
     if kind == 'function' and FUNC_PAT.match(lines[lineno]):
         if "DOCDOC" in lines[lineno-2]:
             return True
@@ -210,6 +222,7 @@ def applyComments(fn, entries):
 e = read()
 
 for fn, errs in e.iteritems():
+    print `(fn, errs)`
     comments = checkf(fn, errs)
     if comments:
         applyComments(fn, comments)

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits