Browse Source

ccanlint: typo fix and fix errant description parsing.

"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.
Rusty Russell 15 years ago
parent
commit
ad3f309e3c

+ 2 - 2
tools/ccanlint/tests/has_info_documentation.c

@@ -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 = {

+ 1 - 1
tools/ccanlint/tests/trailing_whitespace.c

@@ -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);
 				}
 			}

+ 13 - 6
tools/doc_extract-core.c

@@ -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)