Commit 3d486d0d authored by Robert Griesemer's avatar Robert Griesemer

- do not collect BUG comments w/o bug description

R=rsc
DELTA=17  (8 added, 0 deleted, 9 changed)
OCL=31670
CL=31674
parent 8d824562
...@@ -174,14 +174,20 @@ func copyCommentList(list []*ast.Comment) []*ast.Comment { ...@@ -174,14 +174,20 @@ func copyCommentList(list []*ast.Comment) []*ast.Comment {
} }
var bug_markers *regexp.Regexp; // Regexp constructor needs threads - cannot use init expression var (
// Regexp constructor needs threads - cannot use init expressions
bug_markers *regexp.Regexp;
bug_content *regexp.Regexp;
)
// AddProgram adds the AST for a source file to the DocReader. // AddProgram adds the AST for a source file to the DocReader.
// Adding the same AST multiple times is a no-op. // Adding the same AST multiple times is a no-op.
// //
func (doc *DocReader) AddProgram(prog *ast.Program) { func (doc *DocReader) AddProgram(prog *ast.Program) {
if bug_markers == nil { if bug_markers == nil {
bug_markers = makeRex("^/[/*][ \t]*BUG(\\([^)]*\\))?:?[ \t]*"); bug_markers = makeRex("^/[/*][ \t]*BUG\\(.*\\):[ \t]*"); // BUG(uid):
bug_content = makeRex("[^ \n\r\t]+"); // at least one non-whitespace char
} }
if doc.name != prog.Name.Value { if doc.name != prog.Name.Value {
...@@ -202,13 +208,15 @@ func (doc *DocReader) AddProgram(prog *ast.Program) { ...@@ -202,13 +208,15 @@ func (doc *DocReader) AddProgram(prog *ast.Program) {
// collect BUG(...) comments // collect BUG(...) comments
for _, c := range prog.Comments { for _, c := range prog.Comments {
text := c.List[0].Text; text := c.List[0].Text;
m := bug_markers.Execute(string(text)); cstr := string(text);
if len(m) > 0 { if m := bug_markers.Execute(cstr); len(m) > 0 {
// found a BUG comment; // found a BUG comment; maybe empty
// push a copy of the comment w/o the BUG prefix if bstr := cstr[m[1] : len(cstr)]; bug_content.Match(bstr) {
list := copyCommentList(c.List); // non-empty BUG comment; collect comment without BUG prefix
list[0].Text = text[m[1] : len(text)]; list := copyCommentList(c.List);
doc.bugs.Push(&ast.CommentGroup{list, c.EndLine}); list[0].Text = text[m[1] : len(text)];
doc.bugs.Push(&ast.CommentGroup{list, c.EndLine});
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment