]> git.ozlabs.org Git - ccan/blobdiff - tools/namespacize.c
some bug fix in scripts
[ccan] / tools / namespacize.c
index 3e656c84a4346344bd7b90749c1f0aa50c7a798d..3b7113c4302a7a6fc50eaf8524d388c20fb65ba2 100644 (file)
@@ -10,7 +10,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include "talloc/talloc.h"
+#include "ccan/string/string.h"
+#include "ccan/talloc/talloc.h"
 #include "tools.h"
 
 #define IDENT_CHARS    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
@@ -29,16 +30,6 @@ static int indent = 0;
 #define verbose_indent() (indent += 2)
 #define verbose_unindent() (indent -= 2)
 
-#define strstarts(str,prefix) (strncmp((str),(prefix),strlen(prefix)) == 0)
-
-static inline bool strends(const char *str, const char *postfix)
-{
-       if (strlen(str) < strlen(postfix))
-               return false;
-
-       return streq(str + strlen(str) - strlen(postfix), postfix);
-}
-
 static int unlink_no_errno(const char *filename)
 {
        int ret = 0, serrno = errno;
@@ -465,7 +456,7 @@ static struct replace *read_replacement_file(const char *depdir)
                return NULL;
        }
 
-       for (line = split(file, file, "\n", NULL); *line; line++)
+       for (line = strsplit(file, file, "\n", NULL); *line; line++)
                add_replace(&repl, *line);
        return repl;
 }
@@ -485,7 +476,7 @@ static char *parent_dir(const void *ctx, const char *dir)
 
 static void adjust_dir(const char *dir)
 {
-       char *parent = parent_dir(NULL, dir);
+       char *parent = parent_dir(talloc_autofree_context(), dir);
        char **deps;
 
        verbose("Adjusting %s\n", dir);
@@ -506,6 +497,7 @@ static void adjust_dir(const char *dir)
                talloc_free(depdir);
        }
        verbose_unindent();
+       talloc_free(parent);
 }
 
 static void adjust_dependents(const char *dir)