Commit 276ab2c8 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: reshuffle code and frob comments, to reduce the number of lines

parent 80686bb5
Showing with 11 additions and 19 deletions
+11 -19
...@@ -1411,12 +1411,9 @@ char *safe_tempfile(FILE **f) ...@@ -1411,12 +1411,9 @@ char *safe_tempfile(FILE **f)
} }
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
/* Initialize full_operating_dir based on operating_dir. */ /* Change to the specified operating directory, when it's valid. */
void init_operating_dir(void) void init_operating_dir(void)
{ {
if (operating_dir == NULL)
return;
full_operating_dir = get_full_path(operating_dir); full_operating_dir = get_full_path(operating_dir);
/* If the operating directory is inaccessible, fail. */ /* If the operating directory is inaccessible, fail. */
...@@ -1493,17 +1490,13 @@ int prompt_failed_backupwrite(const char *filename) ...@@ -1493,17 +1490,13 @@ int prompt_failed_backupwrite(const char *filename)
return response; return response;
} }
/* Transform the specified backup directory to an absolute path. */
void init_backup_dir(void) void init_backup_dir(void)
{ {
char *full_backup_dir; char *full_backup_dir = get_full_path(backup_dir);
if (backup_dir == NULL)
return;
full_backup_dir = get_full_path(backup_dir);
/* If get_full_path() failed or the backup directory is /* When we can't get an absolute path, or it's not a directory,
* inaccessible, unset backup_dir. */ * cancel the making of backups. */
if (full_backup_dir == NULL || if (full_backup_dir == NULL ||
full_backup_dir[strlen(full_backup_dir) - 1] != '/') { full_backup_dir[strlen(full_backup_dir) - 1] != '/') {
free(full_backup_dir); free(full_backup_dir);
......
...@@ -2374,19 +2374,18 @@ int main(int argc, char **argv) ...@@ -2374,19 +2374,18 @@ int main(int argc, char **argv)
#endif /* !DISABLE_HISTORIES */ #endif /* !DISABLE_HISTORIES */
#ifndef NANO_TINY #ifndef NANO_TINY
/* Set up the backup directory (unless we're using restricted mode, /* If a backup directory was specified and we're not in restricted mode,
* in which case backups are disabled, since they would allow * make sure the path exists and is a directory, so that backup files can
* reading from or writing to files not specified on the command * be saved there. */
* line). This entails making sure it exists and is a directory, so if (backup_dir != NULL && !ISSET(RESTRICTED))
* that backup files will be saved there. */
if (!ISSET(RESTRICTED))
init_backup_dir(); init_backup_dir();
#endif #endif
#ifndef DISABLE_OPERATINGDIR #ifndef DISABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there, /* Set up the operating directory. This entails chdir()ing there,
* so that file reads and writes will be based there. */ * so that file reads and writes will be based there. */
init_operating_dir(); if (operating_dir != NULL)
init_operating_dir();
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment