opt: only use termios if HAVE_SYS_TERMIOS_H is defined
[ccan] / tools / ccan_dir.c
index 561488686d34a61d672337d1681b83bb90080e11..6d95e064a5968d463b4528505406a37bd8995029 100644 (file)
@@ -1,5 +1,5 @@
-#include <ccan/talloc/talloc.h>
 #include <ccan/err/err.h>
+#include <ccan/tal/path/path.h>
 #include "tools.h"
 #include <assert.h>
 #include <string.h>
@@ -27,14 +27,13 @@ const char *find_ccan_dir(const char *base)
 
        if (!ccan_dir) {
                if (base[0] != '/') {
-                       const char *tmpctx = talloc_getcwd(NULL);
-                       find_ccan_dir(talloc_asprintf(tmpctx, "%s/%s",
-                                                     tmpctx, base));
-                       talloc_free(tmpctx);
+                       const char *tmpctx = path_cwd(NULL);
+                       find_ccan_dir(path_join(tmpctx, tmpctx, base));
+                       tal_free(tmpctx);
                } else {
                        unsigned int prefix = ccan_dir_prefix(base);
                        if (prefix)
-                               ccan_dir = talloc_strndup(NULL, base, prefix);
+                               ccan_dir = tal_strndup(NULL, base, prefix);
                }
        }
        return ccan_dir;