X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Flicense_comment.c;h=abe0204e9c32c2ea9aa7d0142d243d4585a57ee9;hp=9548d87cbb17af759c5e173e8ab0966990168b54;hb=9e207bca5bf5e0a1e3653a91649414fab793c801;hpb=2ea90b45cf37292aba7c81b34736661c080497de diff --git a/tools/ccanlint/tests/license_comment.c b/tools/ccanlint/tests/license_comment.c index 9548d87c..abe0204e 100644 --- a/tools/ccanlint/tests/license_comment.c +++ b/tools/ccanlint/tests/license_comment.c @@ -10,6 +10,30 @@ #include #include #include +#include + +/** + * line_has_license_flavour - returns true if line contains a license + * @line: line to look for license in + * @shortname: license to find + * @note ("LGPLv2.0","LGPL") returns true + * @note ("LGPLv2.0","GPL") returns false + */ +static bool line_has_license_flavour(const char *line, const char *shortname) +{ + char **toks = tal_strsplit(NULL, line, " \t-:", STR_NO_EMPTY); + size_t i; + bool ret = false; + + for (i = 0; toks[i] != NULL; i++) { + if (strstarts(toks[i], shortname)) { + ret = true; + break; + } + } + tal_free(toks); + return ret; +} static void check_license_comment(struct manifest *m, unsigned int *timeleft, struct score *score) @@ -38,8 +62,8 @@ static void check_license_comment(struct manifest *m, break; if (strstr(lines[i], "LICENSE")) found_license = true; - if (strstr(lines[i], - licenses[m->license].shortname)) + if (line_has_license_flavour(lines[i], + licenses[m->license].shortname)) found_flavor = true; } if ((!found_license || !found_flavor)