cgmnlm

colorful gemini line mode browser
git clone https://git.clttr.info/cgmnlm.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 78cfe1b669fad6b7a3638d371ed9825e2ee53243
parent dbc726616e6675ae82d9bb55be5693371255ed2f
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Tue, 16 Mar 2021 00:07:27 -0400

all: use posix_dirname rather than dirname

Diffstat:
Msrc/gmnlm.c | 6++----
Msrc/tofu.c | 13++++---------
2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/gmnlm.c b/src/gmnlm.c @@ -179,8 +179,7 @@ save_bookmark(struct browser *browser) n = snprintf(path, sizeof(path), path_fmt, "bookmarks.gmi"); free(path_fmt); assert(n < sizeof(path)); - strncpy(dname, path, sizeof(dname)-1); - dirname(dname); + posix_dirname(path, dname); if (mkdirs(dname, 0755) != 0) { fprintf(stderr, "Error creating directory %s: %s\n", dname, strerror(errno)); @@ -262,8 +261,7 @@ open_bookmarks(struct browser *browser) free(path_fmt); assert(n < sizeof(path)); - strncpy(dname, path, sizeof(dname)-1); - dirname(dname); + posix_dirname(path, dname); if (mkdirs(dname, 0755) != 0) { fprintf(stderr, "Error creating directory %s: %s\n", dname, strerror(errno)); diff --git a/src/tofu.c b/src/tofu.c @@ -177,21 +177,16 @@ gemini_tofu_init(struct gemini_tofu *tofu, tofu_callback_t *cb, void *cb_data) n = snprintf(tofu->known_hosts_path, sizeof(tofu->known_hosts_path), path_fmt, "known_hosts"); + free(path_fmt); assert(n < sizeof(tofu->known_hosts_path)); - strncpy(dname, dirname(tofu->known_hosts_path), sizeof(dname)-1); + posix_dirname(tofu->known_hosts_path, dname); if (mkdirs(dname, 0755) != 0) { - snprintf(tofu->known_hosts_path, sizeof(tofu->known_hosts_path), - path_fmt, "known_hosts"); - fprintf(stderr, "Error creating directory %s: %s\n", - dirname(tofu->known_hosts_path), strerror(errno)); + fprintf(stderr, "Error creating directory %s: %s\n", dname, + strerror(errno)); return; } - snprintf(tofu->known_hosts_path, sizeof(tofu->known_hosts_path), - path_fmt, "known_hosts"); - free(path_fmt); - tofu->callback = cb; tofu->cb_data = cb_data;