tweaks: simplify a fragment of code, and fold two lines together

This commit is contained in:
Benno Schulenberg 2022-04-05 12:40:45 +02:00
parent 940b5eaad1
commit 603ce231d0
2 changed files with 3 additions and 8 deletions

View File

@ -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;
}

View File

@ -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);