]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/file_analysis.c
likely: use htable_type
[ccan] / tools / ccanlint / file_analysis.c
index d8d2d3e936378218b0491a9cec940d203e8d09a5..63d22b8f129513420101f618f459ed4878a34c54 100644 (file)
@@ -1,3 +1,4 @@
+#include "config.h"
 #include "ccanlint.h"
 #include <ccan/talloc/talloc.h>
 #include <ccan/str/str.h>
@@ -9,6 +10,7 @@
 #include <ccan/noerr/noerr.h>
 #include <ccan/foreach/foreach.h>
 #include <ccan/asort/asort.h>
+#include <ccan/array_size/array_size.h>
 #include "../tools.h"
 #include <unistd.h>
 #include <sys/types.h>
@@ -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)