Author: kevans
Date: Sat Apr 21 01:02:35 2018
New Revision: 332850
URL: https://svnweb.freebsd.org/changeset/base/332850

Log:
  bsdgrep: Some light cleanup
  
  There's no point checking for a bunch of file modes if we're not a
  practicing believer of DIR_SKIP or DEV_SKIP.
  
  This also reduces some style violations that were particularly ugly looking
  when browsing through.

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==============================================================================
--- head/usr.bin/grep/util.c    Sat Apr 21 00:34:46 2018        (r332849)
+++ head/usr.bin/grep/util.c    Sat Apr 21 01:02:35 2018        (r332850)
@@ -308,14 +308,14 @@ procfile(const char *fn)
                fn = label != NULL ? label : getstr(1);
                f = grep_open(NULL);
        } else {
-               if (!stat(fn, &sb)) {
+               if (stat(fn, &sb) == 0) {
                        /* Check if we need to process the file */
                        s = sb.st_mode & S_IFMT;
-                       if (s == S_IFDIR && dirbehave == DIR_SKIP)
+                       if (dirbehave == DIR_SKIP && s == S_IFDIR)
                                return (0);
-                       if ((s == S_IFIFO || s == S_IFCHR || s == S_IFBLK
-                               || s == S_IFSOCK) && devbehave == DEV_SKIP)
-                                       return (0);
+                       if (devbehave == DEV_SKIP && (s == S_IFIFO ||
+                           s == S_IFCHR || s == S_IFBLK || s == S_IFSOCK))
+                               return (0);
                }
                f = grep_open(fn);
        }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to