From 50014e35418ca00d25ea852fc4f94acf80be4df3 Mon Sep 17 00:00:00 2001 From: imp Date: Sat, 2 Feb 2002 06:48:10 +0000 Subject: o __P has been reoved o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. --- bin/ls/cmp.c | 24 +++++++------------- bin/ls/extern.h | 34 ++++++++++++++-------------- bin/ls/lomac.c | 11 ++++----- bin/ls/ls.c | 29 +++++++++--------------- bin/ls/print.c | 70 +++++++++++++++++++++------------------------------------ bin/ls/util.c | 12 ++++------ 6 files changed, 71 insertions(+), 109 deletions(-) (limited to 'bin/ls') diff --git a/bin/ls/cmp.c b/bin/ls/cmp.c index 91852ba..155edcc 100644 --- a/bin/ls/cmp.c +++ b/bin/ls/cmp.c @@ -53,57 +53,49 @@ static const char rcsid[] = #include "extern.h" int -namecmp(a, b) - const FTSENT *a, *b; +namecmp(const FTSENT *a, const FTSENT *b) { return (strcoll(a->fts_name, b->fts_name)); } int -revnamecmp(a, b) - const FTSENT *a, *b; +revnamecmp(const FTSENT *a, const FTSENT *b) { return (strcoll(b->fts_name, a->fts_name)); } int -modcmp(a, b) - const FTSENT *a, *b; +modcmp(const FTSENT *a, const FTSENT *b) { return (b->fts_statp->st_mtime - a->fts_statp->st_mtime); } int -revmodcmp(a, b) - const FTSENT *a, *b; +revmodcmp(const FTSENT *a, const FTSENT *b) { return (a->fts_statp->st_mtime - b->fts_statp->st_mtime); } int -acccmp(a, b) - const FTSENT *a, *b; +acccmp(const FTSENT *a, const FTSENT *b) { return (b->fts_statp->st_atime - a->fts_statp->st_atime); } int -revacccmp(a, b) - const FTSENT *a, *b; +revacccmp(const FTSENT *a, const FTSENT *b) { return (a->fts_statp->st_atime - b->fts_statp->st_atime); } int -statcmp(a, b) - const FTSENT *a, *b; +statcmp(const FTSENT *a, const FTSENT *b) { return (b->fts_statp->st_ctime - a->fts_statp->st_ctime); } int -revstatcmp(a, b) - const FTSENT *a, *b; +revstatcmp(const FTSENT *a, const FTSENT *b) { return (a->fts_statp->st_ctime - b->fts_statp->st_ctime); } diff --git a/bin/ls/extern.h b/bin/ls/extern.h index f758a23..ec147de 100644 --- a/bin/ls/extern.h +++ b/bin/ls/extern.h @@ -34,25 +34,25 @@ * $FreeBSD$ */ -int acccmp __P((const FTSENT *, const FTSENT *)); -int revacccmp __P((const FTSENT *, const FTSENT *)); -int modcmp __P((const FTSENT *, const FTSENT *)); -int revmodcmp __P((const FTSENT *, const FTSENT *)); -int namecmp __P((const FTSENT *, const FTSENT *)); -int revnamecmp __P((const FTSENT *, const FTSENT *)); -int statcmp __P((const FTSENT *, const FTSENT *)); -int revstatcmp __P((const FTSENT *, const FTSENT *)); +int acccmp(const FTSENT *, const FTSENT *); +int revacccmp(const FTSENT *, const FTSENT *); +int modcmp(const FTSENT *, const FTSENT *); +int revmodcmp(const FTSENT *, const FTSENT *); +int namecmp(const FTSENT *, const FTSENT *); +int revnamecmp(const FTSENT *, const FTSENT *); +int statcmp(const FTSENT *, const FTSENT *); +int revstatcmp(const FTSENT *, const FTSENT *); -void printcol __P((DISPLAY *)); -void printlong __P((DISPLAY *)); -void printscol __P((DISPLAY *)); -void usage __P((void)); -int len_octal __P((const char *, int)); -int prn_octal __P((const char *)); -int prn_printable __P((const char *)); +void printcol(DISPLAY *); +void printlong(DISPLAY *); +void printscol(DISPLAY *); +void usage(void); +int len_octal(const char *, int); +int prn_octal(const char *); +int prn_printable(const char *); #ifdef COLORLS -void parsecolors __P((const char *cs)); -void colorquit __P((int)); +void parsecolors(const char *cs); +void colorquit(int); extern char *ansi_fgcol; extern char *ansi_bgcol; diff --git a/bin/ls/lomac.c b/bin/ls/lomac.c index b92a08e..62fdc4e 100644 --- a/bin/ls/lomac.c +++ b/bin/ls/lomac.c @@ -68,8 +68,8 @@ struct lomac_fioctl2 ioctl_args; */ void -lomac_start(void) { - +lomac_start(void) +{ if ((devlomac = open(LOMAC_DEVICE, O_RDWR)) == -1) err(1, "cannot open %s", LOMAC_DEVICE); } @@ -84,8 +84,8 @@ lomac_start(void) { */ void -lomac_stop(void) { - +lomac_stop(void) +{ if (close(devlomac) == -1) err(1, "cannot close %s", LOMAC_DEVICE); } @@ -104,7 +104,8 @@ lomac_stop(void) { */ char * -get_lattr(FTSENT *ent) { +get_lattr(FTSENT *ent) +{ char *lattr; #ifdef NOT_NOW diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 1338841..ea0948e 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -79,13 +79,13 @@ static const char rcsid[] = */ #define STRBUF_SIZEOF(t) (1 + CHAR_BIT * sizeof(t) / 3 + 1) -static void display __P((FTSENT *, FTSENT *)); -static u_quad_t makenines __P((u_long)); -static int mastercmp __P((const FTSENT **, const FTSENT **)); -static void traverse __P((int, char **, int)); +static void display(FTSENT *, FTSENT *); +static u_quad_t makenines(u_long); +static int mastercmp(const FTSENT **, const FTSENT **); +static void traverse(int, char **, int); -static void (*printfcn) __P((DISPLAY *)); -static int (*sortfcn) __P((const FTSENT *, const FTSENT *)); +static void (*printfcn)(DISPLAY *); +static int (*sortfcn)(const FTSENT *, const FTSENT *); long blocksize; /* block size units */ int termwidth = 80; /* default terminal width */ @@ -129,9 +129,7 @@ char *enter_bold; /* ANSI sequence to set color to bold mode */ int rval; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { static char dot[] = ".", *dotav[] = {dot, NULL}; struct winsize win; @@ -409,9 +407,7 @@ static int output; /* If anything output. */ * a superset (may be exact set) of the files to be displayed. */ static void -traverse(argc, argv, options) - int argc, options; - char *argv[]; +traverse(int argc, char *argv[], int options) { FTS *ftsp; FTSENT *p, *chp; @@ -474,8 +470,7 @@ traverse(argc, argv, options) * points to the parent directory of the display list. */ static void -display(p, list) - FTSENT *p, *list; +display(FTSENT *p, FTSENT *list) { struct stat *sp; DISPLAY d; @@ -721,8 +716,7 @@ display(p, list) * All other levels use the sort function. Error entries remain unsorted. */ static int -mastercmp(a, b) - const FTSENT **a, **b; +mastercmp(const FTSENT **a, const FTSENT **b) { int a_info, b_info; @@ -751,8 +745,7 @@ mastercmp(a, b) * into a number that wide in decimal. */ static u_quad_t -makenines(n) - u_long n; +makenines(u_long n) { u_long i; u_quad_t reg; diff --git a/bin/ls/print.c b/bin/ls/print.c index 3b72c5a..82a609d 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -67,14 +67,14 @@ static const char rcsid[] = #include "ls.h" #include "extern.h" -static int printaname __P((FTSENT *, u_long, u_long)); -static void printlink __P((FTSENT *)); -static void printtime __P((time_t)); -static int printtype __P((u_int)); -static void printsize __P((size_t, off_t)); +static int printaname(FTSENT *, u_long, u_long); +static void printlink(FTSENT *); +static void printtime(time_t); +static int printtype(u_int); +static void printsize(size_t, off_t); #ifdef COLORLS -static void endcolor __P((int)); -static int colortype __P((mode_t)); +static void endcolor(int); +static int colortype(mode_t); #endif #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) @@ -97,7 +97,7 @@ unsigned long long vals_base2[] = {1, KILO_2_SZ, MEGA_2_SZ, GIGA_2_SZ, TERA_2_SZ typedef enum { NONE, KILO, MEGA, GIGA, TERA, PETA, UNIT_MAX } unit_t; -static unit_t unit_adjust __P((off_t *)); +static unit_t unit_adjust(off_t *); int unitp[] = {NONE, KILO, MEGA, GIGA, TERA, PETA}; @@ -130,8 +130,7 @@ static struct { #endif void -printscol(dp) - DISPLAY *dp; +printscol(DISPLAY *dp) { FTSENT *p; @@ -147,8 +146,7 @@ printscol(dp) * print name in current style */ static int -printname(name) - const char *name; +printname(const char *name) { if (f_octal || f_octal_escape) return prn_octal(name); @@ -159,8 +157,7 @@ printname(name) } void -printlong(dp) - DISPLAY *dp; +printlong(DISPLAY *dp) { struct stat *sp; FTSENT *p; @@ -228,8 +225,7 @@ printlong(dp) } void -printcol(dp) - DISPLAY *dp; +printcol(DISPLAY *dp) { extern int termwidth; static FTSENT **array; @@ -311,10 +307,7 @@ printcol(dp) * return # of characters printed, no trailing characters. */ static int -printaname(p, inodefield, sizefield) - FTSENT *p; - u_long inodefield; - u_long sizefield; +printaname(FTSENT *p, u_long inodefield, u_long sizefield) { struct stat *sp; int chcnt; @@ -344,8 +337,7 @@ printaname(p, inodefield, sizefield) } static void -printtime(ftime) - time_t ftime; +printtime(time_t ftime) { char longstring[80]; static time_t now; @@ -372,8 +364,7 @@ printtime(ftime) } static int -printtype(mode) - u_int mode; +printtype(u_int mode) { switch (mode & S_IFMT) { case S_IFDIR: @@ -401,16 +392,14 @@ printtype(mode) #ifdef COLORLS static int -putch(c) - int c; +putch(int c) { (void)putchar(c); return 0; } static int -writech(c) - int c; +writech(int c) { char tmp = c; @@ -419,8 +408,7 @@ writech(c) } static void -printcolor(c) - Colors c; +printcolor(Colors c) { char *ansiseq; @@ -440,16 +428,14 @@ printcolor(c) } static void -endcolor(sig) - int sig; +endcolor(int sig) { tputs(ansi_coloff, 1, sig ? writech : putch); tputs(attrs_off, 1, sig ? writech : putch); } static int -colortype(mode) - mode_t mode; +colortype(mode_t mode) { switch (mode & S_IFMT) { case S_IFDIR: @@ -490,8 +476,7 @@ colortype(mode) } void -parsecolors(cs) - const char *cs; +parsecolors(const char *cs) { int i; int j; @@ -541,8 +526,7 @@ parsecolors(cs) } void -colorquit(sig) - int sig; +colorquit(int sig) { endcolor(sig); @@ -553,8 +537,7 @@ colorquit(sig) #endif /* COLORLS */ static void -printlink(p) - FTSENT *p; +printlink(FTSENT *p) { int lnklen; char name[MAXPATHLEN + 1]; @@ -575,9 +558,7 @@ printlink(p) } static void -printsize(width, bytes) - size_t width; - off_t bytes; +printsize(size_t width, off_t bytes) { unit_t unit; @@ -600,8 +581,7 @@ printsize(width, bytes) * */ unit_t -unit_adjust(val) - off_t *val; +unit_adjust(off_t *val) { double abval; unit_t unit; diff --git a/bin/ls/util.c b/bin/ls/util.c index 668d8e4..39ee382 100644 --- a/bin/ls/util.c +++ b/bin/ls/util.c @@ -57,8 +57,7 @@ static const char rcsid[] = #include "extern.h" int -prn_printable(s) - const char *s; +prn_printable(const char *s) { unsigned char c; int n; @@ -85,9 +84,7 @@ prn_printable(s) */ int -len_octal(s, len) - const char *s; - int len; +len_octal(const char *s, int len) { int r = 0; @@ -97,8 +94,7 @@ len_octal(s, len) } int -prn_octal(s) - const char *s; +prn_octal(const char *s) { unsigned char ch; int len = 0; @@ -158,7 +154,7 @@ prn_octal(s) } void -usage() +usage(void) { (void)fprintf(stderr, #ifdef COLORLS -- cgit v1.1