CVS commit: src/games/fortune/strfile

2020-07-26 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Jul 26 15:14:09 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Revert arc4random usage for now

this is a host tool and needs to be portable

future plans: add arc4random to libnbcompat


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.41 src/games/fortune/strfile/strfile.c:1.42
--- src/games/fortune/strfile/strfile.c:1.41	Tue Jul 21 03:05:40 2020
+++ src/games/fortune/strfile/strfile.c	Sun Jul 26 15:14:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.41 2020/07/21 03:05:40 nia Exp $	*/
+/*	$NetBSD: strfile.c,v 1.42 2020/07/26 15:14:09 nia Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.41 2020/07/21 03:05:40 nia Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.42 2020/07/26 15:14:09 nia Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -438,6 +438,8 @@ randomize(void)
 	off_t	tmp;
 	off_t	*sp;
 
+	srandom((int)(time(NULL) + getpid()));
+
 	Tbl.str_flags |= STR_RANDOM;
 	cnt = Tbl.str_numstr;
 
@@ -446,7 +448,7 @@ randomize(void)
 	 */
 
 	for (sp = Seekpts; cnt > 0; cnt--, sp++) {
-		i = arc4random_uniform(cnt);
+		i = random() % cnt;
 		tmp = sp[0];
 		sp[0] = sp[i];
 		sp[i] = tmp;



CVS commit: src/games/fortune/strfile

2020-07-26 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sun Jul 26 15:14:09 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Revert arc4random usage for now

this is a host tool and needs to be portable

future plans: add arc4random to libnbcompat


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 12:32:26 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Simplify, errors to stderr.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2020-04-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 30 12:32:26 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Simplify, errors to stderr.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.39 src/games/fortune/strfile/strfile.c:1.40
--- src/games/fortune/strfile/strfile.c:1.39	Wed Apr 29 16:45:05 2020
+++ src/games/fortune/strfile/strfile.c	Thu Apr 30 08:32:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $	*/
+/*	$NetBSD: strfile.c,v 1.40 2020/04/30 12:32:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.40 2020/04/30 12:32:26 christos Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -55,6 +55,7 @@ __RCSID("$NetBSD: strfile.c,v 1.39 2020/
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -131,7 +132,7 @@ static STR *Firstch;			/* first chars of
 
 static uint32_t h2nl(uint32_t h);
 static void getargs(int argc, char **argv);
-static void usage(void) __dead;
+static void usage(const char *, ...) __dead __printflike(1, 2);
 static void add_offset(FILE *fp, off_t off);
 static void do_order(void);
 static int cmp_str(const void *vp1, const void *vp2);
@@ -295,39 +296,39 @@ getargs(int argc, char **argv)
 			break;
 		case '?':
 		default:
-			usage();
+			usage(NULL);
 		}
 	argv += optind;
 
 	if (*argv) {
 		Infile = *argv;
 		if (*++argv) {
-			len = strlen(*argv);
+			len = strlcpy(Outfile, *argv, sizeof(Outfile));
 			if (len >= sizeof(Outfile)) {
-puts("Bad output filename");
-usage();
+usage("Too long output filename");
 			}
-			(void) memcpy(Outfile, *argv, len + 1);
 		}
 	}
 	if (!Infile) {
-		puts("No input file name");
-		usage();
+		usage("No input file name");
 	}
 	if (*Outfile == '\0') {
-		len = strlen(Infile) + sizeof(".dat");
-		if (len > sizeof(Outfile)) {
-			puts("Bad input filename");
-			usage();
+		len = snprintf(Outfile, sizeof(Outfile), "%s.dat", Infile);
+		if (len >= sizeof(Outfile)) {
+			usage("Too long input filename");
 		}
-		(void) strcpy(Outfile, Infile);
-		(void) strcat(Outfile, ".dat");
 	}
 }
 
 static void
-usage(void)
+usage(const char *fmt, ...)
 {
+	if (fmt) {
+		va_list ap;
+		va_start(ap, fmt);
+		vwarnx(fmt, ap);
+		va_end(ap);
+	}
 	(void) fprintf(stderr,
 	"Usage: %s [-iorsx] [-c char] sourcefile [datafile]\n",
 	getprogname());



CVS commit: src/games/fortune/strfile

2020-04-29 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Apr 29 20:45:05 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
strfile: Check that input/output filenames don't exceed the buffer size


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.38 src/games/fortune/strfile/strfile.c:1.39
--- src/games/fortune/strfile/strfile.c:1.38	Thu Sep 19 00:34:00 2013
+++ src/games/fortune/strfile/strfile.c	Wed Apr 29 20:45:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = "@(#)strfile.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $");
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -267,6 +267,7 @@ getargs(int argc, char **argv)
 	int	ch;
 	extern	int optind;
 	extern	char *optarg;
+	size_t	len;
 
 	while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
 		switch(ch) {
@@ -300,14 +301,25 @@ getargs(int argc, char **argv)
 
 	if (*argv) {
 		Infile = *argv;
-		if (*++argv)
-			(void) strcpy(Outfile, *argv);
+		if (*++argv) {
+			len = strlen(*argv);
+			if (len >= sizeof(Outfile)) {
+puts("Bad output filename");
+usage();
+			}
+			(void) memcpy(Outfile, *argv, len + 1);
+		}
 	}
 	if (!Infile) {
 		puts("No input file name");
 		usage();
 	}
 	if (*Outfile == '\0') {
+		len = strlen(Infile) + sizeof(".dat");
+		if (len > sizeof(Outfile)) {
+			puts("Bad input filename");
+			usage();
+		}
 		(void) strcpy(Outfile, Infile);
 		(void) strcat(Outfile, ".dat");
 	}



CVS commit: src/games/fortune/strfile

2020-04-29 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Apr 29 20:45:05 UTC 2020

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
strfile: Check that input/output filenames don't exceed the buffer size


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Sep 18 23:18:14 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
#include nbtool_config.h to pull in getprogname() declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.35 src/games/fortune/strfile/strfile.c:1.36
--- src/games/fortune/strfile/strfile.c:1.35	Sat Oct 13 20:42:56 2012
+++ src/games/fortune/strfile/strfile.c	Wed Sep 18 23:18:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.35 2012/10/13 20:42:56 dholland Exp $	*/
+/*	$NetBSD: strfile.c,v 1.36 2013/09/18 23:18:14 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -32,6 +32,10 @@
  * SUCH DAMAGE.
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include nbtool_config.h
+#endif
+
 #ifdef __NetBSD__
 #include sys/cdefs.h
 #ifndef lint
@@ -43,7 +47,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.35 2012/10/13 20:42:56 dholland Exp $);
+__RCSID($NetBSD: strfile.c,v 1.36 2013/09/18 23:18:14 uwe Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Sep 19 00:18:52 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Don't define TRUE/FALSE, which may conflict with host headers.
TRUE is unused anyway.  Replace all instances of FALSE with 0.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.36 src/games/fortune/strfile/strfile.c:1.37
--- src/games/fortune/strfile/strfile.c:1.36	Wed Sep 18 23:18:14 2013
+++ src/games/fortune/strfile/strfile.c	Thu Sep 19 00:18:52 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.36 2013/09/18 23:18:14 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.37 2013/09/19 00:18:52 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.36 2013/09/18 23:18:14 uwe Exp $);
+__RCSID($NetBSD: strfile.c,v 1.37 2013/09/19 00:18:52 uwe Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -102,9 +102,6 @@ __RCSID($NetBSD: strfile.c,v 1.36 2013/
  *	Added ordering options.
  */
 
-# define	TRUE	1
-# define	FALSE	0
-
 # define	STORING_PTRS	(Oflag || Rflag)
 # define	CHUNKSIZE	512
 
@@ -126,11 +123,11 @@ static char *Infile = NULL;		/* input fi
 static char Outfile[MAXPATHLEN] = ;	/* output file name */
 static char Delimch = '%';		/* delimiting character */
 
-static int Sflag	= FALSE;	/* silent run flag */
-static int Oflag	= FALSE;	/* ordering flag */
-static int Iflag	= FALSE;	/* ignore case flag */
-static int Rflag	= FALSE;	/* randomize order flag */
-static int Xflag	= FALSE;	/* set rotated bit */
+static int Sflag	= 0;		/* silent run flag */
+static int Oflag	= 0;		/* ordering flag */
+static int Iflag	= 0;		/* ignore case flag */
+static int Rflag	= 0;		/* randomize order flag */
+static int Xflag	= 0;		/* set rotated bit */
 static long Num_pts	= 0;		/* number of pointers/strings */
 
 static off_t *Seekpts;
@@ -223,7 +220,7 @@ main(int ac, char **av)
 			else
 fp-first = *nsp;
 			fp-pos = Seekpts[Num_pts - 1];
-			first = FALSE;
+			first = 0;
 		}
 	} while (sp != NULL);
 
@@ -397,8 +394,8 @@ cmp_str(const void *vp1, const void *vp2
 	(void) fseek(Sort_1, p1-pos, SEEK_SET);
 	(void) fseek(Sort_2, p2-pos, SEEK_SET);
 
-	n1 = FALSE;
-	n2 = FALSE;
+	n1 = 0;
+	n2 = 0;
 	while (!isalnum(c1 = getc(Sort_1))  c1 != '\0')
 		SET_N(n1, c1);
 	while (!isalnum(c2 = getc(Sort_2))  c2 != '\0')



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Sep 19 00:34:00 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Now that we use nbtool_config.h we can use __dead again and drop
local attempts to define its equivalent.

Also drop the comment that warns this file is a tool; use of
nbtool_config.h makes it evident.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.37 src/games/fortune/strfile/strfile.c:1.38
--- src/games/fortune/strfile/strfile.c:1.37	Thu Sep 19 00:18:52 2013
+++ src/games/fortune/strfile/strfile.c	Thu Sep 19 00:34:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.37 2013/09/19 00:18:52 uwe Exp $	*/
+/*	$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -47,13 +47,11 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.37 2013/09/19 00:18:52 uwe Exp $);
+__RCSID($NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
 
-/* n.b.: this file is used at build-time - i.e. during build.sh. */
-
 #include sys/types.h
 #include sys/param.h
 #include ctype.h
@@ -71,14 +69,6 @@ __RCSID($NetBSD: strfile.c,v 1.37 2013/
 #define	MAXPATHLEN	1024
 #endif	/* MAXPATHLEN */
 
-#if defined(__NetBSD__) || defined(__dead)
-#define NORETURN	__dead
-#elif defined __GNUC__
-#define NORETURN	__attribute__((__noreturn__))
-#else
-#define NORETURN
-#endif
-
 /*
  *	This program takes a file composed of strings separated by
  * lines starting with two consecutive delimiting character (default
@@ -141,7 +131,7 @@ static STR *Firstch;			/* first chars of
 
 static uint32_t h2nl(uint32_t h);
 static void getargs(int argc, char **argv);
-static void usage(void) NORETURN;
+static void usage(void) __dead;
 static void add_offset(FILE *fp, off_t off);
 static void do_order(void);
 static int cmp_str(const void *vp1, const void *vp2);



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Sep 18 23:18:14 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
#include nbtool_config.h to pull in getprogname() declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Sep 19 00:18:52 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Don't define TRUE/FALSE, which may conflict with host headers.
TRUE is unused anyway.  Replace all instances of FALSE with 0.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Sep 19 00:34:00 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Now that we use nbtool_config.h we can use __dead again and drop
local attempts to define its equivalent.

Also drop the comment that warns this file is a tool; use of
nbtool_config.h makes it evident.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Sep 19 00:53:55 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.8

Log Message:
Use .Fa instead of .Ar to refer to header fields.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/games/fortune/strfile/strfile.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2013-09-18 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Sep 19 00:58:11 UTC 2013

Modified Files:
src/games/fortune/strfile: strfile.8

Log Message:
Untabify the header definition to avoid misaligned comment on
str_delim in PostScript output.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/games/fortune/strfile/strfile.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2012-10-13 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Oct 13 20:42:56 UTC 2012

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Pass -Wstrict-overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.34 src/games/fortune/strfile/strfile.c:1.35
--- src/games/fortune/strfile/strfile.c:1.34	Wed Aug 31 16:24:55 2011
+++ src/games/fortune/strfile/strfile.c	Sat Oct 13 20:42:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.34 2011/08/31 16:24:55 plunky Exp $	*/
+/*	$NetBSD: strfile.c,v 1.35 2012/10/13 20:42:56 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1989, 19
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.34 2011/08/31 16:24:55 plunky Exp $);
+__RCSID($NetBSD: strfile.c,v 1.35 2012/10/13 20:42:56 dholland Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -162,11 +162,12 @@ main(int ac, char **av)
 {
 	char		*sp, dc;
 	FILE		*inf, *outf;
-	off_t		last_off, length, pos, *p;
-	int		first, cnt;
+	off_t		last_off, length, pos;
+	int		first;
 	char		*nsp;
 	STR		*fp;
 	static char	string[257];
+	long		i;
 
 	/* sanity test */
 	if (sizeof(uint32_t) != 4)
@@ -256,8 +257,8 @@ main(int ac, char **av)
 	Tbl.str_flags = h2nl(Tbl.str_flags);
 	(void) fwrite((char *) Tbl, sizeof Tbl, 1, outf);
 	if (STORING_PTRS) {
-		for (p = Seekpts, cnt = Num_pts; cnt--; ++p)
-			fwrite_be_offt(*p, outf);
+		for (i = 0; i  Num_pts; i++)
+			fwrite_be_offt(Seekpts[i], outf);
 	}
 	fflush(outf);
 	if (ferror(outf))



CVS commit: src/games/fortune/strfile

2012-10-13 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Oct 13 20:42:56 UTC 2012

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Pass -Wstrict-overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2011-08-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Aug 17 18:16:51 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Move some things around so declarations appear in a reasonable order.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.31 src/games/fortune/strfile/strfile.c:1.32
--- src/games/fortune/strfile/strfile.c:1.31	Tue Aug 16 19:53:03 2011
+++ src/games/fortune/strfile/strfile.c	Wed Aug 17 18:16:51 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.31 2011/08/16 19:53:03 dholland Exp $	*/
+/*	$NetBSD: strfile.c,v 1.32 2011/08/17 18:16:51 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.31 2011/08/16 19:53:03 dholland Exp $);
+__RCSID($NetBSD: strfile.c,v 1.32 2011/08/17 18:16:51 dholland Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -67,29 +67,13 @@
 #define	MAXPATHLEN	1024
 #endif	/* MAXPATHLEN */
 
-static uint32_t h2nl(uint32_t h);
-static void getargs(int argc, char **argv);
-static void usage(void) __dead;
-static void add_offset(FILE *fp, off_t off);
-static void do_order(void);
-static int cmp_str(const void *vp1, const void *vp2);
-static void randomize(void);
-static void fwrite_be_offt(off_t off, FILE *f);
-
-static uint32_t
-h2nl(uint32_t h)
-{
-unsigned char c[4];
-uint32_t rv;
-
-c[0] = (h  24)  0xff;
-c[1] = (h  16)  0xff;
-c[2] = (h   8)  0xff;
-c[3] = (h   0)  0xff;
-memcpy(rv, c, sizeof rv);
-
-return (rv);
-}
+#if defined(__NetBSD__) || defined(__dead)
+#define NORETURN	__dead
+#elif defined __GNUC__
+#define NORETURN	__attribute__((__noreturn__))
+#else
+#define NORETURN
+#endif
 
 /*
  *	This program takes a file composed of strings separated by
@@ -153,15 +137,15 @@
 
 static STR *Firstch;			/* first chars of each string */
 
-#ifdef __GNUC__
-#define NORETURN	__dead
-#else
-#define NORETURN
-#endif
 
-#ifndef __dead /* not NetBSD, presumably */
-#define __dead ;
-#endif
+static uint32_t h2nl(uint32_t h);
+static void getargs(int argc, char **argv);
+static void usage(void) NORETURN;
+static void add_offset(FILE *fp, off_t off);
+static void do_order(void);
+static int cmp_str(const void *vp1, const void *vp2);
+static void randomize(void);
+static void fwrite_be_offt(off_t off, FILE *f);
 
 void	add_offset(FILE *, off_t);
 int	cmp_str(const void *, const void *);
@@ -492,3 +476,18 @@
 	}
 	fwrite(c, sizeof(c), 1, f);
 }
+
+static uint32_t
+h2nl(uint32_t h)
+{
+unsigned char c[4];
+uint32_t rv;
+
+c[0] = (h  24)  0xff;
+c[1] = (h  16)  0xff;
+c[2] = (h   8)  0xff;
+c[3] = (h   0)  0xff;
+memcpy(rv, c, sizeof rv);
+
+return (rv);
+}



CVS commit: src/games/fortune/strfile

2011-08-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Aug 17 18:17:40 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Remove redundant set of prototypes for local functions, exposed by
previous.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.32 src/games/fortune/strfile/strfile.c:1.33
--- src/games/fortune/strfile/strfile.c:1.32	Wed Aug 17 18:16:51 2011
+++ src/games/fortune/strfile/strfile.c	Wed Aug 17 18:17:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.32 2011/08/17 18:16:51 dholland Exp $	*/
+/*	$NetBSD: strfile.c,v 1.33 2011/08/17 18:17:40 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.32 2011/08/17 18:16:51 dholland Exp $);
+__RCSID($NetBSD: strfile.c,v 1.33 2011/08/17 18:17:40 dholland Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -147,15 +147,6 @@
 static void randomize(void);
 static void fwrite_be_offt(off_t off, FILE *f);
 
-void	add_offset(FILE *, off_t);
-int	cmp_str(const void *, const void *);
-void	do_order(void);
-void	fwrite_be_offt(off_t, FILE *);
-void	getargs(int, char *[]);
-int	main(int, char *[]);
-void	randomize(void);
-void	usage(void) NORETURN;
-
 
 /*
  * main:



CVS commit: src/games/fortune/strfile

2011-08-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Aug 17 18:16:51 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Move some things around so declarations appear in a reasonable order.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2011-08-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Aug 17 18:17:40 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Remove redundant set of prototypes for local functions, exposed by
previous.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2011-08-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 16 11:06:34 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
kill homebrew error functions


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.29 src/games/fortune/strfile/strfile.c:1.30
--- src/games/fortune/strfile/strfile.c:1.29	Wed Aug 12 02:06:28 2009
+++ src/games/fortune/strfile/strfile.c	Tue Aug 16 07:06:34 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.29 2009/08/12 06:06:28 dholland Exp $	*/
+/*	$NetBSD: strfile.c,v 1.30 2011/08/16 11:06:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -43,34 +43,33 @@
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.29 2009/08/12 06:06:28 dholland Exp $);
+__RCSID($NetBSD: strfile.c,v 1.30 2011/08/16 11:06:34 christos Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
 
 /* n.b.: this file is used at build-time - i.e. during build.sh. */
 
-# include	sys/types.h
-# include	sys/param.h
-# include	ctype.h
-# include	stdio.h
-# include	stdlib.h
-# include	string.h
-# include	time.h
-# include	unistd.h
-# include	inttypes.h
-
-# include	strfile.h
-
-# ifndef MAXPATHLEN
-# define	MAXPATHLEN	1024
-# endif	/* MAXPATHLEN */
+#include sys/types.h
+#include sys/param.h
+#include ctype.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include time.h
+#include unistd.h
+#include inttypes.h
+#include err.h
+
+#include strfile.h
+
+#ifndef MAXPATHLEN
+#define	MAXPATHLEN	1024
+#endif	/* MAXPATHLEN */
 
 static uint32_t h2nl(uint32_t h);
 static void getargs(int argc, char **argv);
-static void usage(void);
-static void die(const char *str);
-static void dieperror(const char *fmt, char *file);
+static void usage(void) __attribute__((__noreturn__));
 static void add_offset(FILE *fp, off_t off);
 static void do_order(void);
 static int cmp_str(const void *vp1, const void *vp2);
@@ -127,7 +126,7 @@
 			else if (((sz) + 1) % CHUNKSIZE == 0) \
 ptr = realloc(ptr, ((sz) + CHUNKSIZE) * sizeof *ptr); \
 			if (ptr == NULL) \
-die(out of space); \
+err(1, out of space); \
 		} while (0)
 
 typedef struct {
@@ -166,8 +165,6 @@
 
 void	add_offset(FILE *, off_t);
 int	cmp_str(const void *, const void *);
-void	die(const char *) NORETURN;
-void	dieperror(const char *, char *) NORETURN;
 void	do_order(void);
 void	fwrite_be_offt(off_t, FILE *);
 void	getargs(int, char *[]);
@@ -198,15 +195,15 @@
 
 	/* sanity test */
 	if (sizeof(uint32_t) != 4)
-		die(sizeof(uint32_t) != 4);
+		errx(1, sizeof(uint32_t) != 4);
 
 	getargs(ac, av);		/* evalute arguments */
 	dc = Delimch;
 	if ((inf = fopen(Infile, r)) == NULL)
-		dieperror(open `%s', Infile);
+		err(1, open `%s', Infile);
 
 	if ((outf = fopen(Outfile, w)) == NULL)
-		dieperror(open `%s', Outfile);
+		err(1, open `%s', Outfile);
 	if (!STORING_PTRS)
 		(void) fseek(outf, sizeof Tbl, SEEK_SET);
 
@@ -289,7 +286,7 @@
 	}
 	fflush(outf);
 	if (ferror(outf))
-		dieperror(fwrite %s, Outfile);
+		err(1, fwrite %s, Outfile);
 	(void) fclose(outf);
 	exit(0);
 }
@@ -353,24 +350,8 @@
 usage(void)
 {
 	(void) fprintf(stderr,
-	strfile [-iorsx] [-c char] sourcefile [datafile]\n);
-	exit(1);
-}
-
-static void
-die(const char *str)
-{
-	fprintf(stderr, strfile: %s\n, str);
-	exit(1);
-}
-
-static void
-dieperror(const char *fmt, char *file)
-{
-	fprintf(stderr, strfile: );
-	fprintf(stderr, fmt, file);
-	fprintf(stderr, : );
-	perror(NULL);
+	Usage: %s [-iorsx] [-c char] sourcefile [datafile]\n,
+	getprogname());
 	exit(1);
 }
 



CVS commit: src/games/fortune/strfile

2011-08-16 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Aug 16 19:53:04 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Use __dead instead of __attribute__((__noreturn__)).


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.c
diff -u src/games/fortune/strfile/strfile.c:1.30 src/games/fortune/strfile/strfile.c:1.31
--- src/games/fortune/strfile/strfile.c:1.30	Tue Aug 16 11:06:34 2011
+++ src/games/fortune/strfile/strfile.c	Tue Aug 16 19:53:03 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: strfile.c,v 1.30 2011/08/16 11:06:34 christos Exp $	*/
+/*	$NetBSD: strfile.c,v 1.31 2011/08/16 19:53:03 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1989, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = @(#)strfile.c	8.1 (Berkeley) 5/31/93;
 #else
-__RCSID($NetBSD: strfile.c,v 1.30 2011/08/16 11:06:34 christos Exp $);
+__RCSID($NetBSD: strfile.c,v 1.31 2011/08/16 19:53:03 dholland Exp $);
 #endif
 #endif /* not lint */
 #endif /* __NetBSD__ */
@@ -69,7 +69,7 @@
 
 static uint32_t h2nl(uint32_t h);
 static void getargs(int argc, char **argv);
-static void usage(void) __attribute__((__noreturn__));
+static void usage(void) __dead;
 static void add_offset(FILE *fp, off_t off);
 static void do_order(void);
 static int cmp_str(const void *vp1, const void *vp2);



CVS commit: src/games/fortune/strfile

2011-08-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 16 11:06:34 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
kill homebrew error functions


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2011-08-16 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Aug 16 19:53:04 UTC 2011

Modified Files:
src/games/fortune/strfile: strfile.c

Log Message:
Use __dead instead of __attribute__((__noreturn__)).


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/games/fortune/strfile/strfile.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2010-01-17 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Sun Jan 17 13:35:00 UTC 2010

Modified Files:
src/games/fortune/strfile: strfile.8

Log Message:
The default output file extension is '.dat', not '.out'.
From Lars Nooden via OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/games/fortune/strfile/strfile.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/games/fortune/strfile

2010-01-17 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Sun Jan 17 13:35:00 UTC 2010

Modified Files:
src/games/fortune/strfile: strfile.8

Log Message:
The default output file extension is '.dat', not '.out'.
From Lars Nooden via OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/games/fortune/strfile/strfile.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/fortune/strfile/strfile.8
diff -u src/games/fortune/strfile/strfile.8:1.12 src/games/fortune/strfile/strfile.8:1.13
--- src/games/fortune/strfile/strfile.8:1.12	Thu Sep  9 22:03:21 2004
+++ src/games/fortune/strfile/strfile.8	Sun Jan 17 13:35:00 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: strfile.8,v 1.12 2004/09/09 22:03:21 wiz Exp $
+.\	$NetBSD: strfile.8,v 1.13 2010/01/17 13:35:00 mbalmer Exp $
 .\
 .\ Copyright (c) 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\
 .\ @(#)strfile.8	8.1 (Berkeley) 6/9/93
 .\
-.Dd June 9, 1993
+.Dd January 17, 2010
 .Dt STRFILE 8
 .Os
 .Sh NAME
@@ -57,7 +57,7 @@
 This allows random access of the strings.
 .Pp
 The output file, if not specified on the command line, is named
-.Ar source_file Ns Sy .out .
+.Ar source_file Ns Sy .dat .
 .Pp
 The options are as follows:
 .Bl -tag -width -c char
@@ -130,7 +130,7 @@
 to dump them out in the table order.
 .Sh FILES
 .Bl -tag -width strfile.out -compact
-.It Pa strfile.out
+.It Pa strfile.dat
 default output file.
 .El
 .Sh SEE ALSO