commit 603ce231d01a45d4f33eb78e23466c0e0c370601
parent 940b5eaad116232c20de7405bbb7ba4a2eb8e779
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 5 Apr 2022 12:40:45 +0200
tweaks: simplify a fragment of code, and fold two lines together
Diffstat:
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/src/browser.c b/src/browser.c
@@ -709,14 +709,10 @@ char *browse_in(const char *inpath)
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
- char *currentdir = nmalloc(PATH_MAX + 1);
-
- path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
+ path = free_and_assign(path, realpath(".", NULL));
if (path == NULL) {
- statusline(MILD, _("The working directory has disappeared"));
- free(currentdir);
- beep();
+ statusline(ALERT, _("The working directory has disappeared"));
napms(1200);
return NULL;
}
diff --git a/src/files.c b/src/files.c
@@ -358,8 +358,7 @@ bool has_valid_path(const char *filename)
statusline(ALERT, _("The working directory has disappeared"));
free(currentdir);
- } else
- if (stat(parentdir, &parentinfo) == -1) {
+ } else if (stat(parentdir, &parentinfo) == -1) {
if (errno == ENOENT)
/* TRANSLATORS: Keep the next ten messages at most 76 characters. */
statusline(ALERT, _("Directory '%s' does not exist"), parentdir);