From 8e2106f0cb067ed2265e8537a2b8bcc6e0b6ac3c Mon Sep 17 00:00:00 2001 From: Xin LI Date: Sun, 5 Feb 2017 08:51:41 +0000 Subject: [PATCH] Restore r312404: Use S_ISREG instead of manual & (also it's better to compare the result from & and the pattern instead of just assuming it's one bit value). Pointed out by Tianjie Mao . MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4827 --- usr.bin/sed/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 742881b649ba..572e837b799a 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -391,7 +391,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) if (inplace != NULL) { if (lstat(fname, &sb) != 0) err(1, "%s", fname); - if (!(sb.st_mode & S_IFREG)) + if (!S_ISREG(sb.st_mode)) errx(1, "%s: %s %s", fname, "in-place editing only", "works for regular files");