From f5ad44b6ac462d6cae608fdcbf367d9d4a36cc90 Mon Sep 17 00:00:00 2001 From: mycroft Date: Mon, 30 Jan 1995 19:30:13 +0000 Subject: [PATCH] Use S_IS*(). --- bin/csh/csh.c | 4 ++-- bin/csh/csh.h | 4 ++-- bin/df/df.c | 6 +++--- bin/rcp/rcp.c | 6 +++--- bin/sh/cd.c | 7 +++---- bin/sh/exec.c | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/bin/csh/csh.c b/bin/csh/csh.c index 57972f9800d3..cf525fd50fc0 100644 --- a/bin/csh/csh.c +++ b/bin/csh/csh.c @@ -39,7 +39,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)csh.c 8.2 (Berkeley) 10/12/93";*/ -static char *rcsid = "$Id: csh.c,v 1.10 1995/01/20 18:23:34 mycroft Exp $"; +static char *rcsid = "$Id: csh.c,v 1.11 1995/01/30 19:37:23 mycroft Exp $"; #endif /* not lint */ #include @@ -1312,7 +1312,7 @@ defaultpath() blkp = blk = (Char **) xmalloc((size_t) sizeof(Char *) * 10); #define DIRAPPEND(a) \ - if (stat(ptr = a, &stb) == 0 && (stb.st_mode & S_IFMT) == S_IFDIR) \ + if (stat(ptr = a, &stb) == 0 && S_ISDIR(stb.st_mode)) \ *blkp++ = SAVE(ptr) DIRAPPEND(_PATH_BIN); diff --git a/bin/csh/csh.h b/bin/csh/csh.h index f8810964a535..99ad27357971 100644 --- a/bin/csh/csh.h +++ b/bin/csh/csh.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)csh.h 8.1 (Berkeley) 5/31/93 - * $Id: csh.h,v 1.7 1994/09/23 11:16:30 mycroft Exp $ + * $Id: csh.h,v 1.8 1995/01/30 19:37:25 mycroft Exp $ */ /* @@ -94,7 +94,7 @@ typedef void *ptr_t; #include FILE *cshin, *cshout, *csherr; -#define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR) +#define isdir(d) (S_ISDIR(d.st_mode)) typedef int bool; diff --git a/bin/df/df.c b/bin/df/df.c index 19beb6269a8b..f7d661fe9375 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -44,7 +44,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)df.c 8.7 (Berkeley) 4/2/94";*/ -static char rcsid[] = "$Id: df.c,v 1.17 1995/01/30 18:10:51 mycroft Exp $"; +static char rcsid[] = "$Id: df.c,v 1.18 1995/01/30 19:30:13 mycroft Exp $"; #endif /* not lint */ #include @@ -127,11 +127,11 @@ main(argc, argv) warn("%s", *argv); continue; } - } else if ((stbuf.st_mode & S_IFMT) == S_IFCHR) { + } else if (S_ISCHR(stbuf.st_mode)) { if (!ufs_df(*argv, &mntbuf[mntsize])) ++mntsize; continue; - } else if ((stbuf.st_mode & S_IFMT) == S_IFBLK) { + } else if (S_ISBLK(stbuf.st_mode)) { if ((mntpt = getmntpt(*argv)) == 0) { mntpt = mktemp(strdup("/tmp/df.XXXXXX")); mdev.fspec = *argv; diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index f3508b63cf18..c8919e2df91b 100644 --- a/bin/rcp/rcp.c +++ b/bin/rcp/rcp.c @@ -39,7 +39,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)rcp.c 5.32 (Berkeley) 2/25/91";*/ -static char rcsid[] = "$Id: rcp.c,v 1.6 1994/12/04 07:12:00 cgd Exp $"; +static char rcsid[] = "$Id: rcp.c,v 1.7 1995/01/30 19:37:34 mycroft Exp $"; #endif /* not lint */ /* @@ -407,7 +407,7 @@ verifydir(cp) struct stat stb; if (stat(cp, &stb) >= 0) { - if ((stb.st_mode & S_IFMT) == S_IFDIR) + if (S_ISDIR(stb.st_mode)) return; errno = ENOTDIR; } @@ -493,7 +493,7 @@ source(argc, argv) } if (fstat(f, &stb) < 0) goto notreg; - switch (stb.st_mode&S_IFMT) { + switch (stb.st_mode & S_IFMT) { case S_IFREG: break; diff --git a/bin/sh/cd.c b/bin/sh/cd.c index 229dcf6d425d..9bc4cf4d857f 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -36,7 +36,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)cd.c 8.1 (Berkeley) 5/31/93";*/ -static char *rcsid = "$Id: cd.c,v 1.10 1994/12/05 19:07:32 cgd Exp $"; +static char *rcsid = "$Id: cd.c,v 1.11 1995/01/30 19:38:04 mycroft Exp $"; #endif /* not lint */ #include @@ -99,8 +99,7 @@ cdcmd(argc, argv) if (*dest == '/' || (path = bltinlookup("CDPATH", 1)) == NULL) path = nullstr; while ((p = padvance(&path, dest)) != NULL) { - if (stat(p, &statb) >= 0 - && (statb.st_mode & S_IFMT) == S_IFDIR) { + if (stat(p, &statb) >= 0 && S_ISDIR(statb.st_mode)) { if (!print) { /* * XXX - rethink @@ -186,7 +185,7 @@ top: STACKSTRNUL(p); if (lstat(stackblock(), &statb) < 0) error("lstat %s failed", stackblock()); - if ((statb.st_mode & S_IFMT) != S_IFLNK) + if (!S_ISLNK(statb.st_mode)) continue; /* Hit a symbolic link. We have to start all over again. */ diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 524bc2ea4fdd..d381365ddf96 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -36,7 +36,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)exec.c 8.1 (Berkeley) 5/31/93";*/ -static char *rcsid = "$Id: exec.c,v 1.13 1995/01/15 09:29:16 mycroft Exp $"; +static char *rcsid = "$Id: exec.c,v 1.14 1995/01/30 19:38:05 mycroft Exp $"; #endif /* not lint */ /* @@ -487,7 +487,7 @@ loop: goto loop; } e = EACCES; /* if we fail, this will be the error */ - if ((statb.st_mode & S_IFMT) != S_IFREG) + if (!S_ISREG(statb.st_mode)) goto loop; if (pathopt) { /* this is a %func directory */ stalloc(strlen(fullname) + 1);