- /* We expect the ccan dir to be two levels above module dir. */
- if (!ccan_dir) {
- char *p, *dir;
- dir = talloc_strdup(NULL, m->dir);
- p = strrchr(dir, '/');
- if (!p)
- errx(1, "I expect the ccan root directory in ../..");
- *p = '\0';
- p = strrchr(dir, '/');
- if (!p)
- errx(1, "I expect the ccan root directory in ../..");
- *p = '\0';
- ccan_dir = dir;
- }
+ assert(strstarts(m->dir, find_ccan_dir(m->dir)));
+ m->modname = m->dir + strlen(find_ccan_dir(m->dir)) + strlen("ccan/");