diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 863611267..946d7c5fd 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,6 +1,9 @@ 2002-01-21 Andrew V. Samoilov * vfs.h: Spelled. + * vfs.c (mc_return_cwd): Fix comment. Check whatever mc_stat + returns. Make mc_return_cwd static const char *. + Reorder if statement to eliminate unneeded mc_stat calls. 2002-01-17 Pavel Roskin diff --git a/vfs/vfs.c b/vfs/vfs.c index ffcaa04d9..3a609dcfe 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -625,10 +625,10 @@ int mc_fstat (int handle, struct stat *buf) { } /* - * You must g_strdup whatever this function returns, static buffers are in use + * You must g_strdup whatever this function returns. */ -static char * +static const char * mc_return_cwd (void) { char *p; @@ -640,11 +640,11 @@ mc_return_cwd (void) return current_dir; /* Otherwise check if it is O.K. to use the current_dir */ - mc_stat (p, &my_stat); - mc_stat (current_dir, &my_stat2); - if (my_stat.st_ino != my_stat2.st_ino || - my_stat.st_dev != my_stat2.st_dev || - !cd_symlinks){ + if (!cd_symlinks || + mc_stat (p, &my_stat) || + mc_stat (current_dir, &my_stat2) || + my_stat.st_ino != my_stat2.st_ino || + my_stat.st_dev != my_stat2.st_dev){ g_free (current_dir); current_dir = p; return p; @@ -657,7 +657,7 @@ mc_return_cwd (void) char * mc_get_current_wd (char *buffer, int size) { - char *cwd = mc_return_cwd(); + const char *cwd = mc_return_cwd(); strncpy (buffer, cwd, size); return buffer;