$NetBSD: patch-ac,v 1.4 2017/02/18 13:57:37 joerg Exp $

--- same.c.orig	2004-07-16 17:30:01.000000000 +0000
+++ same.c
@@ -106,10 +106,9 @@
  * - There is a 1024 (BUFSIZE) character limit to pathnames when using 
  *   symlinks.
  *
- * - The same source is not exactly 32kbytes long.  However this comment 
- *   seems to fix that.
  * */
 
+#define _FILE_OFFSET_BITS	64
 
 #include <assert.h>
 #include <stdio.h>
@@ -123,16 +122,8 @@
 #include <sys/times.h>
 #include <zlib.h>
 #include <limits.h>
-
-#define __USE_LARGEFILE64
 #include <sys/stat.h>
 
-#if 1
-/* Why the *&^#$ doesn't sys/stat define this??? */
-extern int lstat64 (__const char *__restrict __file,
-                    struct stat64 *__restrict __buf) __THROW;
-#endif
-
 #ifdef __linux__
 #include <asm/page.h>
 #else /* !__linux__ */
@@ -157,6 +148,11 @@ extern int lstat64 (__const char *__rest
 #define true		1
 #define false		0
 
+#if defined(__GNUC__)
+#  define attribute_unused __attribute__((__unused__))
+#else
+#  define attribute_unused /**/
+#endif
 
 static volatile int stop;
 static volatile int doing_input;
@@ -184,7 +180,7 @@ static const char *o_cache;
 
 struct name_entry {
     struct name_entry *next;
-    char name[0];
+    char name[1];
 };
 
 #define F_CRC_VALID		(1 << 0)
@@ -196,7 +192,7 @@ struct inode_entry {
     struct name_entry *names;
     int flags;			/* See F_* definitions above */
     /* The two fields below may have been read from the cache */
-    loff_t size;
+    off_t size;
     unsigned int crc;		/* valid if flags & F_CRC_VALID only */
     /* The four fields below are valid if flags & F_STAT_VALID only */
     dev_t device;
@@ -265,7 +261,7 @@ static void dump_inode_entry(const struc
 static void dump_hashtable(void);
 static void load_cache(void);
 static void save_cache(void);
-static void save_entry(gzFile *out, const struct inode_entry *entry);
+static void save_entry(gzFile out, const struct inode_entry *entry);
 static void *p_malloc(unsigned int hash, size_t size);
 static struct inode_entry *alloc_inode_entry(unsigned int hash, int is_new);
 static void delete_inode_entry(struct inode_entry *entry);
@@ -288,7 +284,7 @@ static void read_list(void);
 static const char *get_fname(void);
 static struct inode_entry *get_entry(void);
 static int __get_stat(struct inode_entry *entry);
-static unsigned int calc_hash(const struct stat64 *sb);
+static unsigned int calc_hash(const struct stat *sb);
 static int __get_crc(struct inode_entry *entry);
 static int cmp(const struct inode_entry *entry1,
 	       const struct inode_entry *entry2);
@@ -379,7 +375,7 @@ static void dump_inode_entry(const struc
 
     printf("%sentry %p size %lu crc %08x device %lx inode %lx nlink %d uid "
 	   "%lx\n",
-	   indent, entry, (unsigned long)entry->size, entry->crc,
+	   indent, (void *)entry, (unsigned long)entry->size, entry->crc,
 	   (unsigned long)entry->device, (unsigned long)entry->inode,
 	   entry->nlink, (unsigned long)entry->uid);
     for (names = entry->names; names; names = names->next)
@@ -426,10 +422,10 @@ static inline int is_new(const struct in
 static void load_cache(void)
 {
     static char buf[BUFSIZE];
-    gzFile *in;
+    gzFile in;
     unsigned long line = 0;
     char *s;
-    loff_t size;
+    off_t size;
     unsigned int crc;
     const char *name;
     unsigned int hash = 0;
@@ -505,7 +501,7 @@ static void *Malloc (size_t size)
 static void save_cache(void)
 {
     struct stat sb;
-    gzFile *out;
+    gzFile out;
     unsigned int i;
     struct inode_entry *entry;
     char backup[PATH_MAX+1], tmpname[PATH_MAX+1];
@@ -563,7 +559,7 @@ static void save_cache(void)
      *  Save a cache entry
      */
 
-static void save_entry(gzFile *out, const struct inode_entry *entry)
+static void save_entry(gzFile out, const struct inode_entry *entry)
 {
     const struct name_entry *names;
 
@@ -587,7 +583,7 @@ static void *p_malloc(unsigned int hash,
     void *data;
 
     if (size > sizeof(pool->data)) {
-	fprintf(stderr, "Warning: p_malloc() of size %u\n", size);
+	fprintf(stderr, "Warning: p_malloc() of size %zu\n", size);
 	return malloc(size);
     }
 
@@ -659,7 +655,7 @@ static struct name_entry *alloc_name_ent
     return entry;
 }
 
-static void delete_name_entry(struct name_entry *entry __attribute__((__unused__)))
+static void delete_name_entry(struct name_entry *entry attribute_unused)
 {
     /*
      *  We don't free names allocated from the pool
@@ -1168,7 +1164,7 @@ static struct inode_entry *get_entry(voi
 {
     const char *buf;
     struct inode_entry *entry;
-    struct stat64 sb;
+    struct stat sb;
     unsigned int hash;
 
     do {
@@ -1176,7 +1172,7 @@ static struct inode_entry *get_entry(voi
 	if (buf == NULL)
 	    return NULL;
 	stat_stat++;
-	if (lstat64(buf, &sb) < 0) {
+	if (lstat(buf, &sb) < 0) {
 	    fprintf(stderr, "stat %s: %s\n", buf, strerror(errno));
 	    exit(1);
 	}
@@ -1204,13 +1200,13 @@ static struct inode_entry *get_entry(voi
 
 static int __get_stat(struct inode_entry *entry)
 {
-    struct stat64 sb;
+    struct stat sb;
     struct name_entry *name;
 
     /* Loop until we find a file that does exist */
     while ((name = entry->names) != 0) {
 	stat_stat++;
-	if (lstat64(name->name, &sb) < 0)
+	if (lstat(name->name, &sb) < 0)
 	    fprintf(stderr, "stat %s: %s\n", name->name, strerror(errno));
 	else if (S_ISREG(sb.st_mode)) {
 	    entry->device = sb.st_dev;
@@ -1231,7 +1227,7 @@ static int __get_stat(struct inode_entry
      *  Calculate the Hash Value for an Inode Entry
      */
 
-static unsigned int calc_hash(const struct stat64 *sb)
+static unsigned int calc_hash(const struct stat *sb)
 {
     return (sb->st_size) % MAXHASH;
 }
@@ -1256,7 +1252,7 @@ static int __get_crc(struct inode_entry 
     }
 
     while ((n = read(f1, b1, BUFSIZE)) > 0)
-	crc = crc32(crc, b1, n);
+	crc = crc32(crc, (void *)b1, n);
     close(f1);
     if (n < 0) {
 	fprintf(stderr, "read %s: %s\n", entry->names->name, strerror(errno));
