summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2b7f1fc)
ccanlint would abort with 'Malformed line 53' if there was a bad header.
That's very poor, and deeply unhelpful.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
{
if (!f->doc_sections) {
get_ccan_file_lines(f);
{
if (!f->doc_sections) {
get_ccan_file_lines(f);
- f->doc_sections = extract_doc_sections(f->lines);
+ f->doc_sections = extract_doc_sections(f->lines, f->name);
}
return f->doc_sections;
}
}
return f->doc_sections;
}
#include "doc_extract.h"
#include "tools.h"
#include "doc_extract.h"
#include "tools.h"
-static char **grab_doc(char **lines, unsigned int **linemap)
+static char **grab_doc(char **lines, unsigned int **linemap,
+ const char *file)
{
char **ret;
unsigned int i, num;
{
char **ret;
unsigned int i, num;
ret[num++] = talloc_strdup(ret, lines[i]+3);
else if (strstarts(lines[i], " *"))
ret[num++] = talloc_strdup(ret, lines[i]+2);
ret[num++] = talloc_strdup(ret, lines[i]+3);
else if (strstarts(lines[i], " *"))
ret[num++] = talloc_strdup(ret, lines[i]+2);
- else
- errx(1, "Malformed line %u", i);
+ else {
+ /* Weird, malformed? */
+ static bool warned;
+ if (!warned) {
+ warnx("%s:%u:"
+ " Expected ' *' in comment.",
+ file, i+1);
+ warned++;
+ }
+ ret[num++] = talloc_strdup(ret, lines[i]);
+ if (strstr(lines[i], "*/"))
+ printing = false;
+ }
(*linemap)[num-1] = i;
}
}
(*linemap)[num-1] = i;
}
}
curr->num_lines = last_non_empty + 1;
}
curr->num_lines = last_non_empty + 1;
}
-struct list_head *extract_doc_sections(char **rawlines)
+struct list_head *extract_doc_sections(char **rawlines, const char *file)
- char **lines = grab_doc(rawlines, &linemap);
+ char **lines = grab_doc(rawlines, &linemap, file);
const char *function = NULL;
struct doc_section *curr = NULL;
unsigned int i;
const char *function = NULL;
struct doc_section *curr = NULL;
unsigned int i;
err(1, "Reading file %s", argv[i]);
lines = strsplit(file, file, "\n");
err(1, "Reading file %s", argv[i]);
lines = strsplit(file, file, "\n");
- list = extract_doc_sections(lines);
+ list = extract_doc_sections(lines, argv[i]);
if (list_empty(list))
errx(1, "No documentation in file %s", argv[i]);
talloc_free(file);
if (list_empty(list))
errx(1, "No documentation in file %s", argv[i]);
talloc_free(file);
-struct list_head *extract_doc_sections(char **rawlines);
+struct list_head *extract_doc_sections(char **rawlines, const char *file);
#endif /* _DOC_EXTRACT_CORE_H */
#endif /* _DOC_EXTRACT_CORE_H */