tweaks: rename a parameter plus a variable, and reshuffle an assignment

Also improve the comment.
master
Benno Schulenberg 2018-11-19 16:38:54 +01:00
parent d3f0d32e16
commit 929e1b6809
1 changed files with 5 additions and 7 deletions

View File

@ -2417,18 +2417,16 @@ int diralphasort(const void *va, const void *vb)
#endif #endif
#ifdef ENABLE_TABCOMP #ifdef ENABLE_TABCOMP
/* Is the given path a directory? */ /* Return TRUE when the given path is a directory. */
bool is_dir(const char *buf) bool is_dir(const char *path)
{ {
char *dirptr; char *realpath = real_dir_from_tilde(path);
struct stat fileinfo; struct stat fileinfo;
bool retval; bool retval;
dirptr = real_dir_from_tilde(buf); retval = (stat(realpath, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
retval = (stat(dirptr, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode)); free(realpath);
free(dirptr);
return retval; return retval;
} }