diff --git a/src/path.c b/src/path.c index 409b114..5c7f3b8 100644 --- a/src/path.c +++ b/src/path.c @@ -21,27 +21,6 @@ static char path_null = '\0'; -/* - * allocates and initilizes a path - */ -static char* alloc_path(size_t s) { - - char *ptr; - - if (s < 1) - return NULL; - - ptr = malloc(s+1); - - if (ptr == NULL) - return NULL; - - *ptr = '/'; - memset(ptr+1, 0, s); - - return ptr; -} - static const char* path_clear(const char *path) { while(*path == '/') @@ -58,33 +37,6 @@ static inline int has_delim(const char *str) { return strchr(str, '/') != NULL; } -/* - * copy a clean path to buf - * NOTE: buffer should be atleast of size pathlen(path)+1 - */ -static char* cpy_path(char *buf, const char *path) { - - if (*path == 0) - return buf; - - while(*path) { - - *(buf++) = *path; - - if (*path == '/') - path = path_clear(path); - else - path++; - } - - if (*(buf-1) != '/') - *(buf++) = '/'; - - dassert(*buf == 0); - - return buf; -} - int is_abspath(const char *path) { if (path == NULL || *path != '/') @@ -104,23 +56,6 @@ int is_abspath(const char *path) { return 1; } -size_t pathlen(const char *path) { - - size_t size = 0; - - while(*path) { - - size++; - - if (*path == '/') - path = path_clear(path); - else - path++; - } - - return size; -} - static char* expand_home() { char *home = getenv("HOME"); diff --git a/src/path.h b/src/path.h index 8b2337a..483e86b 100644 --- a/src/path.h +++ b/src/path.h @@ -16,8 +16,6 @@ int is_abspath(const char *path); -size_t pathlen(const char *path); - char* path_normalize(const char *base, const char *name, unsigned char dir); #endif /* __PATH_H */ diff --git a/test/t_path.c b/test/t_path.c index 45811ba..f9c5186 100644 --- a/test/t_path.c +++ b/test/t_path.c @@ -37,15 +37,6 @@ void test_normalize() { free(ptr); } -void test_pathlen() { - - assert(pathlen("/usr/src/linux-2.6.30-r5/drivers") == 32); - assert(pathlen("/usr///src/") == 9); - assert(pathlen("/usr//include/sys//") == 17); - assert(pathlen("///var/lib/misc") == 13); - assert(pathlen("dir") == 3); -} - void test_isabspath() { assert(is_abspath("file") == 0); @@ -108,7 +99,6 @@ int main(int argc, char *argv[]) { test_isabspath(); test_normalize(); - test_pathlen(); test_basename(); test_dirname();