[Midnightbsd-cvs] src [11892] trunk/games/number/number.c: reformat

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jul 17 20:55:52 EDT 2018


Revision: 11892
          http://svnweb.midnightbsd.org/src/?rev=11892
Author:   laffer1
Date:     2018-07-17 20:55:51 -0400 (Tue, 17 Jul 2018)
Log Message:
-----------
reformat

Modified Paths:
--------------
    trunk/games/number/Makefile
    trunk/games/number/number.6
    trunk/games/number/number.c

Property Changed:
----------------
    trunk/games/number/number.6

Modified: trunk/games/number/Makefile
===================================================================
--- trunk/games/number/Makefile	2018-07-18 00:55:31 UTC (rev 11891)
+++ trunk/games/number/Makefile	2018-07-18 00:55:51 UTC (rev 11892)
@@ -1,6 +1,6 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.1 (Berkeley) 5/31/93
-# $FreeBSD: src/games/number/Makefile,v 1.4 2001/03/26 14:20:58 ru Exp $
-# $MidnightBSD$
+# $FreeBSD: stable/10/games/number/Makefile 203923 2010-02-15 14:32:00Z uqs $
 
 PROG=	number
 MAN=	number.6

Modified: trunk/games/number/number.6
===================================================================
--- trunk/games/number/number.6	2018-07-18 00:55:31 UTC (rev 11891)
+++ trunk/games/number/number.6	2018-07-18 00:55:51 UTC (rev 11892)
@@ -1,38 +1,34 @@
-." Copyright (c) 1989, 1993, 1994
-."	The Regents of the University of California.  All rights reserved.
-."
-." Redistribution and use in source and binary forms, with or without
-." modification, are permitted provided that the following conditions
-." are met:
-." 1. Redistributions of source code must retain the above copyright
-."    notice, this list of conditions and the following disclaimer.
-." 2. Redistributions in binary form must reproduce the above copyright
-."    notice, this list of conditions and the following disclaimer in the
-."    documentation and/or other materials provided with the distribution.
-." 3. All advertising materials mentioning features or use of this software
-."    must display the following acknowledgement:
-."	This product includes software developed by the University of
-."	California, Berkeley and its contributors.
-." 4. Neither the name of the University nor the names of its contributors
-."    may be used to endorse or promote products derived from this software
-."    without specific prior written permission.
-."
-." THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-." IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-." ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-." FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-." DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-." OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-." HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-." LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-." OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-." SUCH DAMAGE.
-."
-."	@(#)number.6	8.2 (Berkeley) 3/31/94
-." $FreeBSD: src/games/number/number.6,v 1.6 2005/02/13 22:25:10 ru Exp $
-." $MidnightBSD$
-."
+.\" $MidnightBSD$
+.\" Copyright (c) 1989, 1993, 1994
+.\"	The Regents of the University of California.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"	@(#)number.6	8.2 (Berkeley) 3/31/94
+.\" $FreeBSD: stable/10/games/number/number.6 216239 2010-12-06 19:12:51Z uqs $
+.\"
 .Dd March 31, 1994
 .Dt NUMBER 6
 .Os
@@ -42,7 +38,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl l
-.Op Ar &# ...
+.Op Ar \&# ...
 .Sh DESCRIPTION
 The
 .Nm


Property changes on: trunk/games/number/number.6
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/games/number/number.c
===================================================================
--- trunk/games/number/number.c	2018-07-18 00:55:31 UTC (rev 11891)
+++ trunk/games/number/number.c	2018-07-18 00:55:51 UTC (rev 11892)
@@ -1,29 +1,28 @@
+/* $MidnightBSD$ */
 /*
- * Copyright (c) 1988, 1993, 1994 The Regents of the University of
- * California.  All rights reserved.
- * 
+ * Copyright (c) 1988, 1993, 1994
+ *	The Regents of the University of California.  All rights reserved.
+ *
  * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer. 2.
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution. 3. All advertising
- * materials mentioning features or use of this software must display the
- * following acknowledgement: This product includes software developed by the
- * University of California, Berkeley and its contributors. 4. Neither the
- * name of the University nor the names of its contributors may be used to
- * endorse or promote products derived from this software without specific
- * prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
@@ -31,19 +30,18 @@
 
 #ifndef lint
 static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994n	The Regents of the University of California.  All rights reserved.n";
-#endif				/* not lint */
+"@(#) Copyright (c) 1988, 1993, 1994\n\
+	The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
 
 #ifndef lint
 #if 0
-static char	sccsid[] = "@(#)number.c	8.3 (Berkeley) 5/4/95";
+static char sccsid[] = "@(#)number.c	8.3 (Berkeley) 5/4/95";
 #endif
 static const char rcsid[] =
-"$FreeBSD: src/games/number/number.c,v 1.15 2005/02/09 18:22:15 ru Exp $";
-#endif				/* not lint */
+ "$FreeBSD: stable/10/games/number/number.c 227101 2011-11-05 07:18:53Z ed $";
+#endif /* not lint */
 
-#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD");
 #include <sys/types.h>
 
 #include <ctype.h>
@@ -53,41 +51,43 @@
 #include <string.h>
 #include <unistd.h>
 
-#define	MAXNUM	65	/* Biggest number we handle. */
+#define	MAXNUM		65		/* Biggest number we handle. */
 
-static const char *name1[] = {
-	"", "one", "two", "three",
-	"four", "five", "six", "seven",
-	"eight", "nine", "ten", "eleven",
-	"twelve", "thirteen", "fourteen", "fifteen",
-	"sixteen", "seventeen", "eighteen", "nineteen",
-}, *name2[] = {
-	"", "ten", "twenty", "thirty",
-	"forty", "fifty", "sixty", "seventy",
-	"eighty", "ninety",
-}, *name3[] = {
-	"hundred", "thousand", "million", "billion",
-	"trillion", "quadrillion", "quintillion", "sextillion",
-	"septillion", "octillion", "nonillion", "decillion",
-	"undecillion", "duodecillion", "tredecillion", "quattuordecillion",
-	"quindecillion", "sexdecillion",
-	"septendecillion", "octodecillion",
-	"novemdecillion", "vigintillion",
+static const char	*name1[] = {
+	"",		"one",		"two",		"three",
+	"four",		"five",		"six",		"seven",
+	"eight",	"nine",		"ten",		"eleven",
+	"twelve",	"thirteen",	"fourteen",	"fifteen",
+	"sixteen",	"seventeen",	"eighteen",	"nineteen",
+},
+		*name2[] = {
+	"",		"ten",		"twenty",	"thirty",
+	"forty",	"fifty",	"sixty",	"seventy",
+	"eighty",	"ninety",
+},
+		*name3[] = {
+	"hundred",	"thousand",	"million",	"billion",
+	"trillion",	"quadrillion",	"quintillion",	"sextillion",
+	"septillion",	"octillion",	"nonillion",	"decillion",
+	"undecillion",	"duodecillion",	"tredecillion",	"quattuordecillion",
+	"quindecillion",		"sexdecillion",
+	"septendecillion",		"octodecillion",
+	"novemdecillion",		"vigintillion",
 };
 
 static void	convert(char *);
 static int	number(char *, int);
 static void	pfract(int);
-static int	unit (int, char *);
+static int	unit(int, char *);
 static void	usage(void);
 
-static int	lflag;
+static int lflag;
 
 int
 main(int argc, char *argv[])
 {
-	int	ch, first;
-	char	line[256];
+	int ch, first;
+	char line[256];
 
 	lflag = 0;
 	while ((ch = getopt(argc, argv, "l")) != -1)
@@ -104,17 +104,17 @@
 
 	if (*argv == NULL)
 		for (first = 1;
-		     fgets(line, sizeof(line), stdin) != NULL; first = 0) {
-			if (strchr(line, 'n') == NULL)
+		    fgets(line, sizeof(line), stdin) != NULL; first = 0) {
+			if (strchr(line, '\n') == NULL)
 				errx(1, "line too long.");
 			if (!first)
-				(void)printf("...n");
+				(void)printf("...\n");
 			convert(line);
 		}
 	else
 		for (first = 1; *argv != NULL; first = 0, ++argv) {
 			if (!first)
-				(void)printf("...n");
+				(void)printf("...\n");
 			convert(*argv);
 		}
 	exit(0);
@@ -123,12 +123,12 @@
 static void
 convert(char *line)
 {
-	int	flen, len, rval;
-	char	*p, *fraction;
+	int flen, len, rval;
+	char *p, *fraction;
 
 	flen = 0;
 	fraction = NULL;
-	for (p = line; *p != '0' && *p != 'n'; ++p) {
+	for (p = line; *p != '\0' && *p != '\n'; ++p) {
 		if (isblank(*p)) {
 			if (p == line) {
 				++line;
@@ -143,7 +143,7 @@
 			if (fraction != NULL)
 				goto badnum;
 			fraction = p + 1;
-			*p = '0';
+			*p = '\0';
 			break;
 		case '-':
 			if (p == line)
@@ -150,11 +150,11 @@
 				break;
 			/* FALLTHROUGH */
 		default:
-	badnum:	errx(1, "illegal number: %s", line);
+badnum:			errx(1, "illegal number: %s", line);
 			break;
 		}
 	}
-	*p = '0';
+	*p = '\0';
 
 	if ((len = strlen(line)) > MAXNUM ||
 	    (fraction != NULL && ((flen = strlen(fraction)) > MAXNUM)))
@@ -161,18 +161,19 @@
 		errx(1, "number too large, max %d digits.", MAXNUM);
 
 	if (*line == '-') {
-		(void)printf("minus%s", lflag ? " " : "n");
+		(void)printf("minus%s", lflag ? " " : "\n");
 		++line;
 		--len;
 	}
+
 	rval = len > 0 ? unit(len, line) : 0;
 	if (fraction != NULL && flen != 0)
-		for (p = fraction; *p != '0'; ++p)
+		for (p = fraction; *p != '\0'; ++p)
 			if (*p != '0') {
 				if (rval)
 					(void)printf("%sand%s",
-						     lflag ? " " : "",
-						     lflag ? " " : "n");
+					    lflag ? " " : "",
+					    lflag ? " " : "\n");
 				if (unit(flen, fraction)) {
 					if (lflag)
 						(void)printf(" ");
@@ -182,15 +183,15 @@
 				break;
 			}
 	if (!rval)
-		(void)printf("zero%s", lflag ? "" : ".n");
+		(void)printf("zero%s", lflag ? "" : ".\n");
 	if (lflag)
-		(void)printf("n");
+		(void)printf("\n");
 }
 
 static int
 unit(int len, char *p)
 {
-	int	off, rval;
+	int off, rval;
 
 	rval = 0;
 	if (len > 3) {
@@ -200,7 +201,7 @@
 			if (number(p, off)) {
 				rval = 1;
 				(void)printf(" %s%s",
-					name3[len / 3], lflag ? " " : ".n");
+				    name3[len / 3], lflag ? " " : ".\n");
 			}
 			p += off;
 		}
@@ -209,13 +210,13 @@
 			if (number(p, 3)) {
 				rval = 1;
 				(void)printf(" %s%s",
-					name3[len / 3], lflag ? " " : ".n");
+				    name3[len / 3], lflag ? " " : ".\n");
 			}
 		}
 	}
 	if (number(p, len)) {
 		if (!lflag)
-			(void)printf(".n");
+			(void)printf(".\n");
 		rval = 1;
 	}
 	return (rval);
@@ -224,7 +225,7 @@
 static int
 number(char *p, int len)
 {
-	int	val, rval;
+	int val, rval;
 
 	rval = 0;
 	switch (len) {
@@ -262,24 +263,24 @@
 static void
 pfract(int len)
 {
-	static char    *pref[] = {"", "ten-", "hundred-"};
+	static char const * const pref[] = { "", "ten-", "hundred-" };
 
-	switch (len) {
+	switch(len) {
 	case 1:
-		(void)printf("tenths.n");
+		(void)printf("tenths.\n");
 		break;
 	case 2:
-		(void)printf("hundredths.n");
+		(void)printf("hundredths.\n");
 		break;
 	default:
-		(void)printf("%s%sths.n", pref[len % 3], name3[len / 3]);
+		(void)printf("%s%sths.\n", pref[len % 3], name3[len / 3]);
 		break;
 	}
 }
 
 static void
-usage()
+usage(void)
 {
-	(void)fprintf(stderr, "usage: number [-l] [# ...]n");
+	(void)fprintf(stderr, "usage: number [-l] [# ...]\n");
 	exit(1);
 }



More information about the Midnightbsd-cvs mailing list