Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/cp ANSIfication and some KNF fixes by Petri Koistinen fr...



details:   https://anonhg.NetBSD.org/src/rev/90104ecddd70
branches:  trunk
changeset: 514886:90104ecddd70
user:      wiz <wiz%NetBSD.org@localhost>
date:      Thu Sep 13 09:53:59 2001 +0000

description:
ANSIfication and some KNF fixes by Petri Koistinen from bin/13681.

diffstat:

 bin/cp/cp.c     |  26 ++++++++++----------------
 bin/cp/extern.h |  23 ++++++++++++++---------
 bin/cp/utils.c  |  39 ++++++++++++++-------------------------
 3 files changed, 38 insertions(+), 50 deletions(-)

diffs (226 lines):

diff -r 10997e19ef3b -r 90104ecddd70 bin/cp/cp.c
--- a/bin/cp/cp.c       Thu Sep 13 06:30:57 2001 +0000
+++ b/bin/cp/cp.c       Thu Sep 13 09:53:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cp.c,v 1.30 2000/07/07 12:50:15 itojun Exp $   */
+/* $NetBSD: cp.c,v 1.31 2001/09/13 09:53:59 wiz Exp $ */
 
 /*
  * Copyright (c) 1988, 1993, 1994
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)cp.c       8.5 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: cp.c,v 1.30 2000/07/07 12:50:15 itojun Exp $");
+__RCSID("$NetBSD: cp.c,v 1.31 2001/09/13 09:53:59 wiz Exp $");
 #endif
 #endif /* not lint */
 
@@ -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;
 
diff -r 10997e19ef3b -r 90104ecddd70 bin/cp/extern.h
--- a/bin/cp/extern.h   Thu Sep 13 06:30:57 2001 +0000
+++ b/bin/cp/extern.h   Thu Sep 13 09:53:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.5 1998/10/08 17:43:24 wsanchez Exp $      */
+/* $NetBSD: extern.h,v 1.6 2001/09/13 09:53:59 wiz 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 fflag, iflag, 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_ */
diff -r 10997e19ef3b -r 90104ecddd70 bin/cp/utils.c
--- a/bin/cp/utils.c    Thu Sep 13 06:30:57 2001 +0000
+++ b/bin/cp/utils.c    Thu Sep 13 09:53:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: utils.c,v 1.19 2001/08/30 04:45:56 chs Exp $   */
+/* $NetBSD: utils.c,v 1.20 2001/09/13 09:53:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,13 +38,13 @@
 #if 0
 static char sccsid[] = "@(#)utils.c    8.3 (Berkeley) 4/1/94";
 #else
-__RCSID("$NetBSD: utils.c,v 1.19 2001/08/30 04:45:56 chs Exp $");
+__RCSID("$NetBSD: utils.c,v 1.20 2001/09/13 09:53:59 wiz Exp $");
 #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 */
 }



Home | Main Index | Thread Index | Old Index