X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ffile_analysis.c;h=63d22b8f129513420101f618f459ed4878a34c54;hp=d8d2d3e936378218b0491a9cec940d203e8d09a5;hb=af5b1a18948345c5f9f9abf4eda3ab9fe0aa9a9f;hpb=061e359bfc50f006a08410d43527342025d498ad diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index d8d2d3e9..63d22b8f 100644 --- a/tools/ccanlint/file_analysis.c +++ b/tools/ccanlint/file_analysis.c @@ -1,3 +1,4 @@ +#include "config.h" #include "ccanlint.h" #include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include "../tools.h" #include #include @@ -38,7 +40,8 @@ static bool dir_cmp(const struct manifest *m, const char *dir) return strcmp(m->dir, dir) == 0; } -HTABLE_DEFINE_TYPE(struct manifest, manifest_name, dir_hash, dir_cmp, manifest); +HTABLE_DEFINE_TYPE(struct manifest, manifest_name, dir_hash, dir_cmp, + htable_manifest); static struct htable_manifest *manifests; const char *get_ccan_file_contents(struct ccan_file *f) @@ -73,6 +76,7 @@ struct list_head *get_ccan_file_docs(struct ccan_file *f) struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name) { struct ccan_file *f; + unsigned int i; assert(dir[0] == '/'); @@ -80,11 +84,12 @@ struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name) f->lines = NULL; f->line_info = NULL; f->doc_sections = NULL; - f->compiled = NULL; + for (i = 0; i < ARRAY_SIZE(f->compiled); i++) + f->compiled[i] = NULL; f->name = talloc_steal(f, name); f->fullname = talloc_asprintf(f, "%s/%s", dir, f->name); f->contents = NULL; - f->cov_compiled = NULL; + f->simplified = NULL; return f; } @@ -207,8 +212,10 @@ struct manifest *get_manifest(const void *ctx, const char *dir) unsigned int len; struct list_head *list; - if (!manifests) - manifests = htable_manifest_new(); + if (!manifests) { + manifests = talloc(NULL, struct htable_manifest); + htable_manifest_init(manifests); + } olddir = talloc_getcwd(NULL); if (!olddir) @@ -227,7 +234,7 @@ struct manifest *get_manifest(const void *ctx, const char *dir) m = talloc_linked(ctx, talloc(NULL, struct manifest)); m->info_file = NULL; - m->compiled = NULL; + m->compiled[COMPILE_NORMAL] = m->compiled[COMPILE_NOFEAT] = NULL; m->dir = talloc_steal(m, canon_dir); list_head_init(&m->c_files); list_head_init(&m->h_files); @@ -347,7 +354,7 @@ static char *remove_comments(const char *line, bool in_comment, static bool is_empty(const char *line) { - return strspn(line, " \t") == strlen(line); + return strspn(line, " \r\t") == strlen(line); } static bool continues(const char *line)