]> git.deb.at Git - pkg/abook.git/commitdiff
abook_fopen() bugfix
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Tue, 2 Apr 2002 21:12:44 +0000 (21:12 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Tue, 2 Apr 2002 21:12:44 +0000 (21:12 +0000)
abook.c

diff --git a/abook.c b/abook.c
index 101dd69d6b41fe787c2cce462e844163a8f612d9..7bc654dc35271e72d21f1a080b88f6e3fceaf453 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -605,17 +605,18 @@ FILE *
 abook_fopen (const char *path, const char *mode)
 {      
        struct stat s;
+       bool stat_ok;
 
-       if((stat(path, &s)) == -1)
-               return NULL;
+       stat_ok = (stat(path, &s) != -1);
        
        if(strchr(mode, 'r'))
-               return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL;
+               return (stat_ok && S_ISREG(s.st_mode)) ?
+                       fopen(path, mode) : NULL;
        else
-               return S_ISDIR(s.st_mode) ? NULL : fopen(path, mode);
+               return (stat_ok && S_ISDIR(s.st_mode)) ?
+                       NULL : fopen(path, mode);
 }
 
-
 static void
 convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile)
 {