tweaks: elide a comment, and improve a couple of others

master
Benno Schulenberg 2017-11-13 19:58:29 +01:00
parent 169da09424
commit f6e83438da
1 changed files with 8 additions and 11 deletions

View File

@ -931,13 +931,10 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
{ {
struct stat fileinfo, fileinfo2; struct stat fileinfo, fileinfo2;
int fd; int fd;
char *full_filename; char *full_filename = get_full_path(filename);
/* Get the specified file's full path. */ /* If the full path is unusable (due to some component's permissions),
full_filename = get_full_path(filename); * but the relative path is okay, then just use that one. */
/* Okay, if we can't stat the path due to a component's
* permissions, just try the relative one. */
if (full_filename == NULL || (stat(full_filename, &fileinfo) == -1 && if (full_filename == NULL || (stat(full_filename, &fileinfo) == -1 &&
stat(filename, &fileinfo2) != -1)) stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(full_filename, filename); full_filename = mallocstrcpy(full_filename, filename);
@ -1168,18 +1165,18 @@ void do_insertfile(void)
if (has_old_position(answer, &priorline, &priorcol)) if (has_old_position(answer, &priorline, &priorcol))
do_gotolinecolumn(priorline, priorcol, FALSE, FALSE); do_gotolinecolumn(priorline, priorcol, FALSE, FALSE);
} }
#endif /* ENABLE_HISTORIES */ #endif
/* Update stuff to account for the current buffer. */ /* Update title bar and color info for this new buffer. */
prepare_for_display(); prepare_for_display();
} else } else
#endif /* ENABLE_MULTIBUFFER */ #endif /* ENABLE_MULTIBUFFER */
{ {
/* Mark the file as modified if it changed. */ /* If the file actually changed, mark it as modified. */
if (openfile->current->lineno != was_current_lineno || if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x) openfile->current_x != was_current_x)
set_modified(); set_modified();
#ifndef NANO_TINY #ifndef NANO_TINY
/* Don't change the format of the current file. */ /* Ensure that the buffer retains the format that it had. */
openfile->fmt = original_fmt; openfile->fmt = original_fmt;
#endif #endif
refresh_needed = TRUE; refresh_needed = TRUE;