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)
id_len = strspn(line, IDENT_CHARS" ");
if (id_len == 0)
return 0;
+ if (strspn(line, " ") == id_len)
+ return 0;
if (!strstarts(line + id_len-1, " - "))
return 0;
-
return id_len - 1;
}