Subject: testers for diffs wanted
To: None <current-users@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: current-users
Date: 06/18/1999 23:09:51
With my ongoing quest for everything in /usr/share to be machine
independant, I'm looking for some people with 64 bit machines and big
endian machines to test the following diffs to fortune(6).  The machines
will need to be 1.3J or later because the patches use <machine/bswap.h>
which was introduced in January this year.  Hopefully the md5's of the
resultant .dat files will match when I get on both a pmax and an i386
(both little endian):

	MD5 (datfiles/obj.pmax/fortunes-o.dat) = 79d3464d76e6fd2058254fcafc2861a4
	MD5 (datfiles/obj.pmax/fortunes.dat) = b710dd76ce65e198b1a867aa91fb278e
	MD5 (datfiles/obj.pmax/fortunes2-o.dat) = 512bf23d97db17690741ad8961fa4fa1
	MD5 (datfiles/obj.pmax/fortunes2.dat) = 2cf5bbb71ccc33fe595ea6ec74bdad26
	MD5 (datfiles/obj.pmax/limerick.dat) = 07fa1c13d92360a96ac83ed0239a9a50
	MD5 (datfiles/obj.pmax/startrek.dat) = 1eaf14f6344a99dadbf3f0e81a7f2a91
	MD5 (datfiles/obj.pmax/zippy.dat) = 265601548afa1328f08e215c5dbce49a

This shouldn't be the final form of the diffs, but I'm looking for proof
of concept at the moment.  Diffs below.

Many TIA,
Simon.
--

Index: fortune/fortune.c
===================================================================
RCS file: /cvsroot/basesrc/games/fortune/fortune/fortune.c,v
retrieving revision 1.14
diff -p -u -r1.14 fortune.c
--- fortune.c	1998/09/13 15:27:28	1.14
+++ fortune.c	1999/06/18 13:00:04
@@ -984,8 +984,8 @@ get_fort()
 	(void) lseek(fp->datfd,
 		     (off_t) (sizeof fp->tbl + fp->pos * sizeof Seekpts[0]), 0);
 	read(fp->datfd, Seekpts, sizeof Seekpts);
-	Seekpts[0] = ntohl(Seekpts[0]);
-	Seekpts[1] = ntohl(Seekpts[1]);
+	Seekpts[0] = ntoho(Seekpts[0]);
+	Seekpts[1] = ntoho(Seekpts[1]);
 }
 
 /*
Index: strfile/strfile.c
===================================================================
RCS file: /cvsroot/basesrc/games/fortune/strfile/strfile.c,v
retrieving revision 1.8
diff -p -u -r1.8 strfile.c
--- strfile.c	1998/09/13 15:27:28	1.8
+++ strfile.c	1999/06/18 13:00:04
@@ -252,7 +252,7 @@ main(ac, av)
 	(void) fwrite((char *) &Tbl, sizeof Tbl, 1, outf);
 	if (STORING_PTRS) {
 		for (p = Seekpts, cnt = Num_pts; cnt--; ++p)
-			*p = htonl(*p);
+			*p = htono(*p);
 		(void) fwrite((char *) Seekpts, sizeof *Seekpts, (int) Num_pts, outf);
 	}
 	(void) fclose(outf);
@@ -334,7 +334,7 @@ add_offset(fp, off)
 	off_t net;
 
 	if (!STORING_PTRS) {
-		net = htonl(off);
+		net = htono(off);
 		fwrite(&net, 1, sizeof net, fp);
 	} else {
 		ALLOC(Seekpts, Num_pts + 1);
Index: strfile/strfile.h
===================================================================
RCS file: /cvsroot/basesrc/games/fortune/strfile/strfile.h,v
retrieving revision 1.3
diff -p -u -r1.3 strfile.h
--- strfile.h	1995/03/23 08:28:49	1.3
+++ strfile.h	1999/06/18 13:00:04
@@ -38,19 +38,33 @@
  *	@(#)strfile.h	8.1 (Berkeley) 5/31/93
  */
 
+#include <sys/types.h>
+#include <machine/endian.h>
+#include <machine/bswap.h>
+
+/* host/network to off_t (off_t == 64bits) */
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define htono(x)	bswap64((x))
+#define ntoho(x)	bswap64((x))
+#else
+#define htono(x)	(x)
+#define ntoho(x)	(x)
+#endif
+
 #define	STR_ENDSTRING(line,tbl) \
 	((line)[0] == (tbl).str_delim && (line)[1] == '\n')
 
 typedef struct {				/* information table */
 #define	VERSION		1
-	unsigned long	str_version;		/* version number */
-	unsigned long	str_numstr;		/* # of strings in the file */
-	unsigned long	str_longlen;		/* length of longest string */
-	unsigned long	str_shortlen;		/* length of shortest string */
+	u_int32_t	str_version;		/* version number */
+	u_int32_t	str_numstr;		/* # of strings in the file */
+	u_int32_t	str_longlen;		/* length of longest string */
+	u_int32_t	str_shortlen;		/* length of shortest string */
 #define	STR_RANDOM	0x1			/* randomized pointers */
 #define	STR_ORDERED	0x2			/* ordered pointers */
 #define	STR_ROTATED	0x4			/* rot-13'd text */
-	unsigned long	str_flags;		/* bit field for flags */
+	u_int32_t	str_flags;		/* bit field for flags */
 	unsigned char	stuff[4];		/* long aligned space */
 #define	str_delim	stuff[0]		/* delimiting character */
 } STRFILE;
Index: unstr/unstr.c
===================================================================
RCS file: /cvsroot/basesrc/games/fortune/unstr/unstr.c,v
retrieving revision 1.4
diff -p -u -r1.4 unstr.c
--- unstr.c	1997/10/11 07:59:09	1.4
+++ unstr.c	1999/06/18 13:00:04
@@ -140,7 +140,7 @@ order_unstr(tbl)
 
 	for (i = 0; i < tbl->str_numstr; i++) {
 		(void) fread((char *) &pos, 1, sizeof pos, Dataf);
-		(void) fseek(Inf, ntohl(pos), 0);
+		(void) fseek(Inf, ntoho(pos), 0);
 		if (i != 0)
 			(void) printf("%c\n", Delimch);
 		for (;;) {