ccanlint: typo fix and fix errant description parsing.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 10 Nov 2010 11:38:15 +0000 (22:08 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 10 Nov 2010 11:38:15 +0000 (22:08 +1030)
"C has fairly weak typing:" from check_type/_info is not a new section heading!
Enforce that each word in multi-word sections must be caps.

tools/ccanlint/tests/has_info_documentation.c
tools/ccanlint/tests/trailing_whitespace.c
tools/doc_extract-core.c

index 6ecbf84247acf4a21bbe7e05f38fb84a325c8770..ee89df9fc12398473ae24c059fd6724d0159205f 100644 (file)
@@ -82,12 +82,12 @@ static void check_has_info_documentation(struct manifest *m,
                "CCAN modules use /**-style comments for documentation: the\n"
                "overall documentation belongs in the _info metafile.\n";
                has_info_documentation.handle = create_info_template_doc;
-       }
-       else if (!description) 
+       } else if (!description)  {
                score->error = "_info file has no module description.\n\n"
                "The lines after the first summary line in the _info file\n"
                "documentation should describe the purpose and use of the\n"
                "overall package\n";
+       }
 }
 
 struct ccanlint has_info_documentation = {
index 2d344435e9ff908233f9d82babb08a801e5fa4ca..ea8b5787982c2914541133642b3460682a52a4ee 100644 (file)
@@ -37,7 +37,7 @@ static void check_trailing_whitespace(struct manifest *m,
                                char *err = get_trailing_whitespace(lines[i]);
                                if (err) {
                                        score->error = "Trailing whitespace"
-                                               "found";
+                                               " found";
                                        score_file_error(score, f, i+1, err);
                                }
                        }
index 583328a16c6ea5797f6dfebd5789c71d206dcf5b..2862eedc3b91a839749e34fe2f0ac516532a1eb6 100644 (file)
@@ -52,13 +52,20 @@ static bool is_blank(const char *line)
 
 static bool is_section(const char *line, bool one_liner)
 {
-       unsigned int len;
+       unsigned int len = 0;
 
-       if (!isupper(line[0]))
-               return false;
-       len = strspn(line, IDENT_CHARS" ");
-       if (line[len] != ':')
-               return false;
+       /* Any number of upper case words separated by spaces, ending in : */
+       for (;;) {
+               if (!isupper(line[len]))
+                       return false;
+               len += strspn(line+len, IDENT_CHARS);
+               if (line[len] == ':')
+                       break;
+
+               if (line[len] != ' ')
+                       return false;
+               len++;
+       }
 
        /* If it can be a one-liner, a space is sufficient.*/
        if (one_liner)