Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
#include <stdio.h>
#include <err.h>
#include <ccan/str/str.h>
#include <stdio.h>
#include <err.h>
#include <ccan/str/str.h>
-
-static char *xstrdup(const char *s) {
- char * ret = strdup(s);
- if (ret == NULL) {
- perror("strdup");
- abort();
- }
- return ret;
-}
+#include <ccan/tal/str/str.h>
/**
* line_has_license_flavour - returns true if line contains a <flavour> license
/**
* line_has_license_flavour - returns true if line contains a <flavour> license
* @note ("LGPLv2.0","LGPL") returns true
* @note ("LGPLv2.0","GPL") returns false
*/
* @note ("LGPLv2.0","LGPL") returns true
* @note ("LGPLv2.0","GPL") returns false
*/
-static bool line_has_license_flavour(const char *line, const char *flavour) {
- char *strtok_line, *strtok_tmp, *token;
+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;
- const size_t flavour_len = strlen(flavour);
- strtok_line = strtok_tmp = xstrdup(line);
- while((token = strtok(strtok_tmp, " \t-:")) != NULL) {
- if (!strncmp(token, flavour, flavour_len)) {
+ for (i = 0; toks[i] != NULL; i++) {
+ if (strstarts(toks[i], shortname)) {