X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ffile_analysis.c;h=d55e2b8c12bebd7b4d4062ed93b1d7350ae8216e;hp=530416e368cb1fd17a48f93fa7c9bc220b0f1a20;hb=1c92b49f17c58ebad46ba8a4f628ddd3a09d46e7;hpb=3b200f895cb7884c72d9e2409f047284027abc68 diff --git a/tools/ccanlint/file_analysis.c b/tools/ccanlint/file_analysis.c index 530416e3..d55e2b8c 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 @@ -85,6 +86,7 @@ struct ccan_file *new_ccan_file(const void *ctx, const char *dir, char *name) f->fullname = talloc_asprintf(f, "%s/%s", dir, f->name); f->contents = NULL; f->cov_compiled = NULL; + f->simplified = NULL; return f; } @@ -347,7 +349,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) @@ -404,6 +406,17 @@ static bool parse_hash_if(struct pp_conditions *cond, const char **line) return false; if (!defined) cond->type = PP_COND_IF; + + /* FIXME: We just chain them, ignoring operators. */ + if (get_token(line, "||") || get_token(line, "&&")) { + struct pp_conditions *sub = talloc(cond, struct pp_conditions); + + sub->parent = cond->parent; + sub->type = PP_COND_IFDEF; + if (parse_hash_if(sub, line)) + cond->parent = sub; + } + return true; }