]> granicus.if.org Git - file/commitdiff
stylistic nits from pooka. use S_ISREG and count writable if it is writable
authorChristos Zoulas <christos@zoulas.com>
Tue, 23 Mar 2004 15:33:43 +0000 (15:33 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 23 Mar 2004 15:33:43 +0000 (15:33 +0000)
by anyone like we do in the executable case.

src/magic.c

index 3d5153ea3e8ffaf787f162a0bd1335ac86fff08d..d603296904fc2cf9c82d68ee2b68a85c9b537b5f 100644 (file)
@@ -65,7 +65,7 @@
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.19 2004/03/22 20:37:13 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.20 2004/03/23 15:33:43 christos Exp $")
 #endif /* lint */
 
 #ifdef __EMX__
@@ -234,13 +234,13 @@ magic_file(struct magic_set *ms, const char *inname)
                fd = STDIN_FILENO;
        else if ((fd = open(inname, O_RDONLY)) < 0) {
                /* We cannot open it, but we were able to stat it. */
-               if (sb.st_mode & 0002)
+               if (sb.st_mode & 0222)
                        if (file_printf(ms, "writable, ") == -1)
                                return NULL;
                if (sb.st_mode & 0111)
                        if (file_printf(ms, "executable, ") == -1)
                                return NULL;
-               if (sb.st_mode & 0100000)
+               if (S_ISREG(sb.st_mode))
                        if (file_printf(ms, "regular file, ") == -1)
                                return NULL;
                if (file_printf(ms, "no read permission") == -1)