Subject: bin/13691: More stylish bin/date
To: None <gnats-bugs@gnats.netbsd.org>
From: Petri Koistinen <thoron@mb-u10ip031.mbnet.fi>
List: netbsd-bugs
Date: 08/12/2001 04:55:43
>Number:         13691
>Category:       bin
>Synopsis:       More stylish bin/date
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 11 18:51:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Petri Koistinen
>Release:        NetBSD-current Sat Aug 11 2001
>Organization:
>Environment:
System: NetBSD mb-u10ip031.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:
	Patches for bin/date to make it stylistically more correct.
>How-To-Repeat:
>Fix:
Index: date.c
===================================================================
RCS file: /cvsroot/basesrc/bin/date/date.c,v
retrieving revision 1.33
diff -u -r1.33 date.c
--- date.c	2001/07/08 05:24:50	1.33
+++ date.c	2001/08/12 01:50:08
@@ -1,4 +1,4 @@
-/*	$NetBSD: date.c,v 1.33 2001/07/08 05:24:50 gmcgarry Exp $	*/
+/* $NetBSD: date.c,v 1.33 2001/07/08 05:24:50 gmcgarry Exp $ */
 
 /*
  * Copyright (c) 1985, 1987, 1988, 1993
@@ -54,10 +54,10 @@
 #include <ctype.h>
 #include <err.h>
 #include <fcntl.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <locale.h>
 #include <syslog.h>
 #include <time.h>
 #include <tzfile.h>
@@ -69,20 +69,18 @@
 time_t tval;
 int retval, nflag;
 
-int main __P((int, char *[]));
-static void setthetime __P((const char *));
-static void badformat __P((void));
-static void badtime __P((void));
-static void usage __P((void));
+int main(int, char *[]);
+static void badformat(void);
+static void badtime(void);
+static void setthetime(const char *);
+static void usage(void);
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
+	char buf[1024], *format;
 	int ch, rflag;
-	char *format, buf[1024];
-
+	
 	(void)setlocale(LC_ALL, "");
 
 	rflag = 0;
@@ -129,16 +127,28 @@
 	/* NOTREACHED */
 }
 
-#define	ATOI2(s)	((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
+static void
+badformat(void)
+{
+	warnx("illegal time format");
+	usage();
+}
 
 static void
-setthetime(p)
-	const char *p;
+badtime(void)
 {
-	struct tm *lt;
+	errx(1, "illegal time");
+}
+
+#define ATOI2(s) ((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
+
+static void
+setthetime(const char *p)
+{
 	struct timeval tv;
+	struct tm *lt;
 	const char *dot, *t;
-	int yearset, len;
+	int len, yearset;
 
 	for (t = p, dot = NULL; *t; ++t) {
 		if (isdigit((unsigned char)*t))
@@ -220,25 +230,12 @@
 	syslog(LOG_AUTH | LOG_NOTICE, "date set by %s", p);
 }
 
-static void
-badformat()
-{
-	warnx("illegal time format");
-	usage();
-}
-
-static void
-badtime()
-{
-	errx(1, "illegal time");
-}
-
 static void
-usage()
+usage(void)
 {
 	(void)fprintf(stderr,
-	    "usage: date [-nu] [-r seconds] [+format]\n");
-	(void)fprintf(stderr, "       date [[[[[cc]yy]mm]dd]hh]mm[.ss]\n");
+	    "usage: %s [-nu] [-r seconds] [+format]\n", getprogname());
+	(void)fprintf(stderr, "       %s [[[[[cc]yy]mm]dd]hh]mm[.ss]\n", getprogname());
 	exit(1);
 	/* NOTREACHED */
 }
Index: extern.h
===================================================================
RCS file: /cvsroot/basesrc/bin/date/extern.h,v
retrieving revision 1.3
diff -u -r1.3 extern.h
--- extern.h	1995/03/21 09:03:52	1.3
+++ extern.h	2001/08/12 01:50:08
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.3 1995/03/21 09:03:52 cgd Exp $	*/
+/* $NetBSD: extern.h,v 1.3 1995/03/21 09:03:52 cgd Exp $ */
 
 /*-
  * Copyright (c) 1993
@@ -35,4 +35,9 @@
  *	@(#)extern.h	8.1 (Berkeley) 5/31/93
  */
 
-int	netsettime __P((time_t));
+#ifndef _EXTERN_H_
+#define _EXTERN_H_
+
+int netsettime(time_t);
+
+#endif /* !_EXTERN_H_ */
Index: netdate.c
===================================================================
RCS file: /cvsroot/basesrc/bin/date/netdate.c,v
retrieving revision 1.19
diff -u -r1.19 netdate.c
--- netdate.c	2001/07/08 05:26:03	1.19
+++ netdate.c	2001/08/12 01:50:08
@@ -1,4 +1,4 @@
-/*	$NetBSD: netdate.c,v 1.19 2001/07/08 05:26:03 gmcgarry Exp $	*/
+/* $NetBSD: netdate.c,v 1.19 2001/07/08 05:26:03 gmcgarry Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -72,21 +72,20 @@
  * Returns 0 on success.  Returns > 0 on failure, setting retval to 2;
  */
 int
-netsettime(tval)
-	time_t tval;
+netsettime(time_t tval)
 {
+	struct sockaddr_in dest, from, sin;
 	struct timeval tout;
-	struct servent *sp;
 	struct tsp msg;
-	struct sockaddr_in sin, dest, from;
+	char hostname[MAXHOSTNAMELEN];
+	struct servent *sp;
 	fd_set ready;
 	long waittime;
-	int s, timed_ack, found, error;
+	int error, found, s, timed_ack;
 	socklen_t length;
 #ifdef IP_PORTRANGE
 	int on;
 #endif
-	char hostname[MAXHOSTNAMELEN];
 
 	if ((sp = getservbyname("timed", "udp")) == NULL) {
 		warnx("udp/timed: unknown service");
>Release-Note:
>Audit-Trail:
>Unformatted: