Subject: bin/13681: More stylish bin/cp
To: None <gnats-bugs@gnats.netbsd.org>
From: Petri Koistinen <thoron@mb-u10ip108.mbnet.fi>
List: netbsd-bugs
Date: 08/11/2001 16:16:38
>Number: 13681
>Category: bin
>Synopsis: More stylish bin/cp
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Aug 11 06:13:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Petri Koistinen
>Release: NetBSD-current Sat Aug 11 2001
>Organization:
>Environment:
System: NetBSD mb-u10ip108.mbnet.fi 1.5W NetBSD 1.5W (MUURAHAISKEKO) #5: Sat Jul 21 08:56:11 EEST 2001 thoron@legoland:/usr/src/sys/arch/amiga/compile/MUURAHAISKEKO amiga
Architecture: m68k
Machine: amiga
>Description:
More stylish bin/cp.
>How-To-Repeat:
>Fix:
Index: cp.c
===================================================================
RCS file: /cvsroot/basesrc/bin/cp/cp.c,v
retrieving revision 1.30
diff -u -r1.30 cp.c
--- cp.c 2000/07/07 12:50:15 1.30
+++ cp.c 2001/08/11 13:09:46
@@ -1,4 +1,4 @@
-/* $NetBSD: cp.c,v 1.30 2000/07/07 12:50:15 itojun Exp $ */
+/* $NetBSD: cp.c,v 1.30 2000/07/07 12:50:15 itojun Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -88,19 +88,17 @@
PATH_T to = { to.p_path, "" };
uid_t myuid;
-int Rflag, iflag, pflag, rflag, fflag;
+int Rflag, fflag, iflag, pflag, rflag;
mode_t myumask;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
-int main __P((int, char *[]));
-int copy __P((char *[], enum op, int));
-int mastercmp __P((const FTSENT **, const FTSENT **));
+int main(int, char *[]);
+int copy(char *[], enum op, int);
+int mastercmp(const FTSENT **, const FTSENT **);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
struct stat to_stat, tmp_stat;
enum op type;
@@ -250,15 +248,12 @@
type = FILE_TO_DIR;
}
- exit (copy(argv, type, fts_options));
+ exit(copy(argv, type, fts_options));
/* NOTREACHED */
}
int
-copy(argv, type, fts_options)
- char *argv[];
- enum op type;
- int fts_options;
+copy(char *argv[], enum op type, int fts_options)
{
struct stat to_stat;
FTS *ftsp;
@@ -472,8 +467,7 @@
* files first reduces seeking.
*/
int
-mastercmp(a, b)
- const FTSENT **a, **b;
+mastercmp(const FTSENT **a, const FTSENT **b)
{
int a_info, b_info;
Index: extern.h
===================================================================
RCS file: /cvsroot/basesrc/bin/cp/extern.h,v
retrieving revision 1.5
diff -u -r1.5 extern.h
--- extern.h 1998/10/08 17:43:24 1.5
+++ extern.h 2001/08/11 13:10:12
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.5 1998/10/08 17:43:24 wsanchez Exp $ */
+/* $NetBSD: extern.h,v 1.5 1998/10/08 17:43:24 wsanchez Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -35,6 +35,9 @@
* @(#)extern.h 8.2 (Berkeley) 4/1/94
*/
+#ifndef _EXTERN_H_
+#define _EXTERN_H_
+
typedef struct {
char *p_end; /* pointer to NULL at end of path */
char *target_end; /* pointer to end of target base */
@@ -43,17 +46,19 @@
extern PATH_T to;
extern uid_t myuid;
-extern int iflag, pflag, fflag;
+extern int iflag, fflag, pflag;
extern mode_t myumask;
#include <sys/cdefs.h>
__BEGIN_DECLS
-int copy_fifo __P((struct stat *, int));
-int copy_file __P((FTSENT *, int));
-int copy_link __P((FTSENT *, int));
-int copy_special __P((struct stat *, int));
-int set_utimes __P((const char *, struct stat *));
-int setfile __P((struct stat *, int));
-void usage __P((void));
+int copy_fifo(struct stat *, int);
+int copy_file(FTSENT *, int);
+int copy_link(FTSENT *, int);
+int copy_special(struct stat *, int);
+int set_utimes(const char *, struct stat *);
+int setfile(struct stat *, int);
+void usage(void);
__END_DECLS
+
+#endif /* !_EXTERN_H_ */
Index: utils.c
===================================================================
RCS file: /cvsroot/basesrc/bin/cp/utils.c,v
retrieving revision 1.18
diff -u -r1.18 utils.c
--- utils.c 2001/07/18 11:01:54 1.18
+++ utils.c 2001/08/11 13:10:28
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.18 2001/07/18 11:01:54 tron Exp $ */
+/* $NetBSD: utils.c,v 1.18 2001/07/18 11:01:54 tron Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -42,9 +42,9 @@
#endif
#endif /* not lint */
+#include <sys/mman.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include <sys/mman.h>
#include <sys/time.h>
#include <err.h>
@@ -59,9 +59,7 @@
#include "extern.h"
int
-set_utimes(file, fs)
- const char * file;
- struct stat * fs;
+set_utimes(const char *file, struct stat *fs)
{
static struct timeval tv[2];
@@ -76,9 +74,7 @@
}
int
-copy_file(entp, dne)
- FTSENT *entp;
- int dne;
+copy_file(FTSENT *entp, int dne)
{
static char buf[MAXBSIZE];
struct stat to_stat, *fs;
@@ -220,9 +216,7 @@
}
int
-copy_link(p, exists)
- FTSENT *p;
- int exists;
+copy_link(FTSENT *p, int exists)
{
int len;
char target[MAXPATHLEN];
@@ -244,9 +238,7 @@
}
int
-copy_fifo(from_stat, exists)
- struct stat *from_stat;
- int exists;
+copy_fifo(struct stat *from_stat, int exists)
{
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
@@ -260,9 +252,7 @@
}
int
-copy_special(from_stat, exists)
- struct stat *from_stat;
- int exists;
+copy_special(struct stat *from_stat, int exists)
{
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
@@ -286,9 +276,7 @@
* itself after close(fd).
*/
int
-setfile(fs, fd)
- struct stat *fs;
- int fd;
+setfile(struct stat *fs, int fd)
{
int rval, islink;
@@ -339,11 +327,12 @@
}
void
-usage()
+usage(void)
{
- (void)fprintf(stderr, "%s\n%s\n",
- "usage: cp [-R [-H | -L | -P]] [-f | -i] [-p] src target",
- " cp [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory");
+ (void)fprintf(stderr,
+ "usage: %s [-R [-H | -L | -P]] [-f | -i] [-p] src target\n"
+ " %s [-R [-H | -L | -P]] [-f | -i] [-p] src1 ... srcN directory\n",
+ getprogname(), getprogname());
exit(1);
/* NOTREACHED */
}
>Release-Note:
>Audit-Trail:
>Unformatted: