From 326750158e8fbb77ddf60b35cd08edcfe173732a Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Tue, 18 Feb 2020 07:21:20 -0800 Subject: [PATCH] cleanup libdirutils --- ke/TODO | 5 ++++- libdirutils/Makefile.in | 4 ++-- libdirutils/dirutils.c | 23 +++++++++++++---------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/ke/TODO b/ke/TODO index 2885985..b98660c 100644 --- a/ke/TODO +++ b/ke/TODO @@ -1,10 +1,13 @@ [X] goto-line -[ ] text-corruption bug +[X] text-corruption bug [ ] alt-modifiers [ ] refresh-screen [ ] functions -> keymapping? [X] rendering: need to skip over control characters like we do with tabs [X] control-d -> delete +[ ] control-g -> exit buf prompt +[ ] load-file prompt on dirty buffer +[ ] multiple files What would it take for ke to be your daily drives? + C-u diff --git a/libdirutils/Makefile.in b/libdirutils/Makefile.in index b9c4266..530b8bc 100644 --- a/libdirutils/Makefile.in +++ b/libdirutils/Makefile.in @@ -10,8 +10,8 @@ MANDIR ?= $MANDIR CFLAGS += -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align CFLAGS += -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -CFLAGS += -Wnested-externs -Winline -Wno-long-long -Wunused-variable -CFLAGS += -Wstrict-prototypes -Werror -std=c99 -I. -I/usr/local/include +CFLAGS += -Wnested-externs -Winline -Wno-long-long -Wunused-variable -g +CFLAGS += -Wstrict-prototypes -Werror -std=c99 -I. -I/usr/local/include -O0 CFLAGS += OS_CFLAGS all: $(TARGET) diff --git a/libdirutils/dirutils.c b/libdirutils/dirutils.c index 433789a..a7666a3 100644 --- a/libdirutils/dirutils.c +++ b/libdirutils/dirutils.c @@ -32,8 +32,8 @@ #include "kst/dirlist.h" -static int _parent_exists(const char *); -static int _rmdirs(const char *); +int _parent_exists(const char *); +int _rmdirs(const char *); /* * Determines whether a directory exists. @@ -144,11 +144,12 @@ _parent_exists(const char *path) int _rmdirs(const char *path) { - char child[FILENAME_MAX + 1]; - struct dirent *dp; - DIR *dirp; - int fail = EXIT_FAILURE; + char child[FILENAME_MAX + 1]; + struct dirent *dp; + DIR *dirp; + int fail = EXIT_SUCCESS; + printf("_rmdirs(%s)\n", path); if (NULL == (dirp = opendir(path))) { return EXIT_FAILURE; } @@ -162,8 +163,6 @@ _rmdirs(const char *path) continue; } - - snprintf(child, FILENAME_MAX, "%s/%s", path, dp->d_name); if (DT_DIR == dp->d_type) { fail = _rmdirs(child); if (EXIT_FAILURE == fail) { @@ -178,12 +177,16 @@ _rmdirs(const char *path) } } } - if (-1 == closedir(dirp)) + + if (-1 == closedir(dirp)) { return EXIT_FAILURE; + } + if (EXIT_FAILURE == fail) { return EXIT_FAILURE; } - else if (-1 == rmdir(path)) { + + if (-1 == rmdir(path)) { return EXIT_FAILURE; } else {