2011-03-04 Chris Allegretta <chrisa@asty.org>

* color.c (color_update): Add check for whether the file even exists
	  before we try to run the magic check on it.  Fixes error messages to stderr
	  when reading in files that don't exist, reported by Mike Frysinger.




git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4540 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2011-03-05 05:01:13 +00:00
parent bccf2fa1c9
commit fda622c0cd
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-03-04 Chris Allegretta <chrisa@asty.org>
* color.c (color_update): Add check for whether the file even exists
before we try to run the magic check on it. Fixes error messages to stderr
when reading in files that don't exist, reported by Mike Frysinger.
2011-03-03 Chris Allegretta <chrisa@asty.org> 2011-03-03 Chris Allegretta <chrisa@asty.org>
* color.c (color_update): Remove unneeded debugging message from * color.c (color_update): Remove unneeded debugging message from
libmagic commit. Fixed extra messages going to stderr reported by Mike Frysinger. libmagic commit. Fixed extra messages going to stderr reported by Mike Frysinger.

View File

@ -131,6 +131,7 @@ void color_update(void)
const char *magicstring = NULL; const char *magicstring = NULL;
const char *magicerr = NULL; const char *magicerr = NULL;
magic_t m; magic_t m;
struct stat fileinfo;
#endif /* HAVE_LIBMAGIC */ #endif /* HAVE_LIBMAGIC */
@ -160,7 +161,7 @@ void color_update(void)
#ifdef HAVE_LIBMAGIC #ifdef HAVE_LIBMAGIC
if (strcmp(openfile->filename,"")) { if (strcmp(openfile->filename,"") && stat(openfile->filename, &fileinfo) == 0) {
m = magic_open(MAGIC_SYMLINK | m = magic_open(MAGIC_SYMLINK |
#ifdef DEBUG #ifdef DEBUG
MAGIC_DEBUG | MAGIC_CHECK | MAGIC_DEBUG | MAGIC_CHECK |