- Use four space to indent continuation line.
- Put a space after the C language keyword ``switch''. - Put an empty line if a function doesn't have local variable. - Use do { } while (/*CONSTCOND*/ 0) instead of { } to protect a multi statement macro
This commit is contained in:
parent
e2923328ba
commit
b0d6c27ed1
16
bin/rm/rm.c
16
bin/rm/rm.c
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: rm.c,v 1.29 2001/12/20 20:10:34 soren Exp $ */
|
/* $NetBSD: rm.c,v 1.30 2002/05/02 13:25:09 enami Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993, 1994
|
* Copyright (c) 1990, 1993, 1994
|
||||||
|
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\n\
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)rm.c 8.8 (Berkeley) 4/27/95";
|
static char sccsid[] = "@(#)rm.c 8.8 (Berkeley) 4/27/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: rm.c,v 1.29 2001/12/20 20:10:34 soren Exp $");
|
__RCSID("$NetBSD: rm.c,v 1.30 2002/05/02 13:25:09 enami Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
Pflag = rflag = 0;
|
Pflag = rflag = 0;
|
||||||
while ((ch = getopt(argc, argv, "dfiPRrW")) != -1)
|
while ((ch = getopt(argc, argv, "dfiPRrW")) != -1)
|
||||||
switch(ch) {
|
switch (ch) {
|
||||||
case 'd':
|
case 'd':
|
||||||
dflag = 1;
|
dflag = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -169,7 +169,7 @@ rm_tree(char **argv)
|
||||||
if (Wflag)
|
if (Wflag)
|
||||||
flags |= FTS_WHITEOUT;
|
flags |= FTS_WHITEOUT;
|
||||||
if (!(fts = fts_open(argv, flags,
|
if (!(fts = fts_open(argv, flags,
|
||||||
(int (*) __P((const FTSENT **, const FTSENT **)))NULL)))
|
(int (*) __P((const FTSENT **, const FTSENT **)))NULL)))
|
||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
while ((p = fts_read(fts)) != NULL) {
|
while ((p = fts_read(fts)) != NULL) {
|
||||||
switch (p->fts_info) {
|
switch (p->fts_info) {
|
||||||
|
@ -331,14 +331,14 @@ rm_overwrite(char *file, struct stat *sbp)
|
||||||
if ((fd = open(file, O_WRONLY, 0)) == -1)
|
if ((fd = open(file, O_WRONLY, 0)) == -1)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
#define PASS(byte) { \
|
#define PASS(byte) do { \
|
||||||
memset(buf, byte, sizeof(buf)); \
|
memset(buf, byte, sizeof(buf)); \
|
||||||
for (len = sbp->st_size; len > 0; len -= wlen) { \
|
for (len = sbp->st_size; len > 0; len -= wlen) { \
|
||||||
wlen = len < sizeof(buf) ? len : sizeof(buf); \
|
wlen = len < sizeof(buf) ? len : sizeof(buf); \
|
||||||
if (write(fd, buf, wlen) != wlen) \
|
if (write(fd, buf, wlen) != wlen) \
|
||||||
goto err; \
|
goto err; \
|
||||||
} \
|
} \
|
||||||
}
|
} while (/* CONSTCOND */ 0)
|
||||||
PASS(0xff);
|
PASS(0xff);
|
||||||
if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
|
if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET))
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -353,7 +353,6 @@ err: eval = 1;
|
||||||
warn("%s", file);
|
warn("%s", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
check(char *path, char *name, struct stat *sp)
|
check(char *path, char *name, struct stat *sp)
|
||||||
{
|
{
|
||||||
|
@ -371,7 +370,7 @@ check(char *path, char *name, struct stat *sp)
|
||||||
* first because we may not have stat'ed the file.
|
* first because we may not have stat'ed the file.
|
||||||
*/
|
*/
|
||||||
if (!stdin_ok || S_ISLNK(sp->st_mode) ||
|
if (!stdin_ok || S_ISLNK(sp->st_mode) ||
|
||||||
!(access(name, W_OK) && (errno != ETXTBSY)))
|
!(access(name, W_OK) && (errno != ETXTBSY)))
|
||||||
return (1);
|
return (1);
|
||||||
strmode(sp->st_mode, modep);
|
strmode(sp->st_mode, modep);
|
||||||
(void)fprintf(stderr, "override %s%s%s/%s for %s? ",
|
(void)fprintf(stderr, "override %s%s%s/%s for %s? ",
|
||||||
|
@ -430,6 +429,7 @@ checkdot(char **argv)
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrW] file ...\n",
|
(void)fprintf(stderr, "usage: %s [-f|-i] [-dPRrW] file ...\n",
|
||||||
getprogname());
|
getprogname());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue