X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Flicense_exists.c;h=09a9b7e68c7054fe010f19418511663f4021d1ef;hp=9cf86083e0f60df26a399dcd26e3d3d50d20988a;hb=4640e61b45d8d3cdfc5301bc58ef7c96a42077ec;hpb=8de1e8a6faef77773cbf8ed237eb4e330143d2f2 diff --git a/tools/ccanlint/tests/license_exists.c b/tools/ccanlint/tests/license_exists.c index 9cf86083..09a9b7e6 100644 --- a/tools/ccanlint/tests/license_exists.c +++ b/tools/ccanlint/tests/license_exists.c @@ -10,56 +10,6 @@ #include #include #include -#include - -static struct doc_section *find_license_tag(const struct manifest *m) -{ - struct doc_section *d; - - list_for_each(m->info_file->doc_sections, d, list) { - if (!streq(d->function, m->basename)) - continue; - if (streq(d->type, "license")) - return d; - } - return NULL; -} - -static enum license which_license(struct doc_section *d) -{ - if (strstarts(d->lines[0], "GPL")) { - if (strchr(d->lines[0], '3')) - return LICENSE_GPLv3; - else if (strchr(d->lines[0], '2')) { - if (strreg(NULL, d->lines[0], "or (any )?later", NULL)) - return LICENSE_GPLv2_PLUS; - else - return LICENSE_GPLv2; - } - return LICENSE_GPL; - } - - if (strstarts(d->lines[0], "LGPL")) { - if (strchr(d->lines[0], '3')) - return LICENSE_LGPLv3; - else if (strchr(d->lines[0], '2')) { - if (strreg(NULL, d->lines[0], "or (any )?later", NULL)) - return LICENSE_LGPLv2_PLUS; - else - return LICENSE_LGPLv2; - } - return LICENSE_LGPL; - } - if (streq(d->lines[0], "BSD-MIT") - || streq(d->lines[0], "MIT")) - return LICENSE_MIT; - if (streq(d->lines[0], "BSD (3 clause)")) - return LICENSE_BSD; - if (strreg(NULL, d->lines[0], "[Pp]ublic [Dd]omain")) - return LICENSE_PUBLIC_DOMAIN; - - return LICENSE_UNKNOWN; -} static const char *expected_link(enum license license) { @@ -129,6 +79,14 @@ static void check_has_license(struct manifest *m, } m->license = which_license(d); + if (m->license == LICENSE_UNKNOWN) { + score_file_error(score, m->info_file, d->srcline, + "WARNING: unknown License: in _info: %s", + d->lines[0]); + /* FIXME: For historical reasons, don't fail here. */ + score->pass = true; + return; + } /* If they have a license tag at all, we pass. */ score->pass = true;