Fix fortune-mod compilation on 64bits hosts (#2136)
authorFlorian Fainelli <florian@openwrt.org>
Fri, 27 Jul 2007 08:52:15 +0000 (08:52 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Fri, 27 Jul 2007 08:52:15 +0000 (08:52 +0000)
SVN-Revision: 8192

utils/fortune-mod/Makefile
utils/fortune-mod/patches/01-strfile-64bit-fix [new file with mode: 0644]

index aaee901..0815ffb 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fortune-mod
 PKG_VERSION:=1.2.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://freeware.sgi.com/source/fortune-mod
@@ -30,7 +30,7 @@ define Package/fortune-mod
 endef
 
 define Build/Compile
-       $(HOSTCC) -Wall -m32 -o $(PKG_BUILD_DIR)/util/strfile-host $(PKG_BUILD_DIR)/util/strfile.c -DVERSION=\"$(PKG_VERSION)\"
+       $(HOSTCC) -Wall -o $(PKG_BUILD_DIR)/util/strfile-host $(PKG_BUILD_DIR)/util/strfile.c -DVERSION=\"$(PKG_VERSION)\"
        $(PKG_BUILD_DIR)/util/strfile-host $(PKG_BUILD_DIR)/datfiles/fortunes $(PKG_BUILD_DIR)/datfiles/fortunes.dat
        $(MAKE) -C $(PKG_BUILD_DIR)/fortune
 endef
diff --git a/utils/fortune-mod/patches/01-strfile-64bit-fix b/utils/fortune-mod/patches/01-strfile-64bit-fix
new file mode 100644 (file)
index 0000000..9bd3da9
--- /dev/null
@@ -0,0 +1,156 @@
+--- fortune-mod-1.2.1/util/strfile.c.orig      2007-07-27 00:40:54.687140050 +0100
++++ fortune-mod-1.2.1/util/strfile.c   2007-07-27 00:41:14.184165656 +0100
+@@ -144,7 +135,7 @@
+ typedef struct
+ {
+     char first;
+-    off_t pos;
++    int32_t pos;
+ }
+ STR;
+@@ -159,7 +150,7 @@
+ int Xflag = FALSE;            /* set rotated bit */
+ long Num_pts = 0;             /* number of pointers/strings */
+-off_t *Seekpts;
++int32_t *Seekpts;
+ FILE *Sort_1, *Sort_2;                /* pointers for sorting */
+@@ -237,9 +228,9 @@
+  * add_offset:
+  *      Add an offset to the list, or write it out, as appropriate.
+  */
+-void add_offset(FILE * fp, off_t off)
++void add_offset(FILE * fp, int32_t off)
+ {
+-    off_t net;
++    int32_t net;
+     if (!STORING_PTRS)
+     {
+@@ -258,9 +249,9 @@
+  * fix_last_offset:
+  *     Used when we have two separators in a row.
+  */
+-void fix_last_offset(FILE * fp, off_t off)
++void fix_last_offset(FILE * fp, int32_t off)
+ {
+-    off_t net;
++    int32_t net;
+     if (!STORING_PTRS)
+     {
+@@ -333,7 +324,7 @@
+   do_order(void)
+ {
+     register long i;
+-    register off_t *lp;
++    register int32_t *lp;
+     register STR *fp;
+     Sort_1 = fopen(Infile, "r");
+@@ -384,8 +375,8 @@
+ void randomize(void)
+ {
+     register int cnt, i;
+-    register off_t tmp;
+-    register off_t *sp;
++    register int32_t tmp;
++    register int32_t *sp;
+     extern time_t time(time_t *);
+     srandom((int) (time((time_t *) NULL) + getpid()));
+@@ -422,7 +413,7 @@
+ {
+     register unsigned char *sp;
+     register FILE *inf, *outf;
+-    register off_t last_off, length, pos, *p;
++    register int32_t last_off, length, pos, *p;
+     register int first, cnt;
+     register char *nsp;
+     register STR *fp;
+@@ -514,14 +505,19 @@
+     if (!Sflag)
+     {
+       printf("\"%s\" created\n", Outfile);
+-      if (Num_pts == 2)
+-          puts("There was 1 string");
++      if (Num_pts == 1)
++          puts("There was no string");
+       else
+-          printf("There were %ld strings\n", Num_pts - 1);
+-      printf("Longest string: %lu byte%s\n", Tbl.str_longlen,
+-             Tbl.str_longlen == 1 ? "" : "s");
+-      printf("Shortest string: %lu byte%s\n", Tbl.str_shortlen,
+-             Tbl.str_shortlen == 1 ? "" : "s");
++      {
++          if (Num_pts == 2)
++              puts("There was 1 string");
++          else
++              printf("There were %ld strings\n", Num_pts - 1);
++          printf("Longest string: %lu byte%s\n", Tbl.str_longlen, 
++              Tbl.str_longlen == 1 ? "" : "s");
++          printf("Shortest string: %lu byte%s\n", Tbl.str_shortlen,
++              Tbl.str_shortlen == 1 ? "" : "s");
++      }
+     }
+     fseek(outf, (off_t) 0, 0);
+@@ -533,12 +529,19 @@
+     Tbl.str_longlen = htonl(Tbl.str_longlen);
+     Tbl.str_shortlen = htonl(Tbl.str_shortlen);
+     Tbl.str_flags = htonl(Tbl.str_flags);
+-    fwrite((char *) &Tbl, sizeof Tbl, 1, outf);
++    fwrite(&Tbl.str_version,  sizeof Tbl.str_version,  1, outf);
++    fwrite(&Tbl.str_numstr,   sizeof Tbl.str_numstr,   1, outf);
++    fwrite(&Tbl.str_longlen,  sizeof Tbl.str_longlen,  1, outf);
++    fwrite(&Tbl.str_shortlen, sizeof Tbl.str_shortlen, 1, outf);
++    fwrite(&Tbl.str_flags,    sizeof Tbl.str_flags,    1, outf);
++    fwrite( Tbl.stuff,        sizeof Tbl.stuff,        1, outf);
+     if (STORING_PTRS)
+     {
+       for (p = Seekpts, cnt = Num_pts; cnt--; ++p)
++      {
+           *p = htonl(*p);
+-      fwrite((char *) Seekpts, sizeof *Seekpts, (int) Num_pts, outf);
++          fwrite(p, sizeof *p, 1, outf);
++      }
+     }
+     fclose(outf);
+     exit(0);
+--- fortune-mod-1.2.1/util/strfile.h   2000-01-29 11:14:34.000000000 +0000
++++ fortune-mod-1.2.1/util/strfile.h   2007-07-27 00:25:46.825640014 +0100
+@@ -38,24 +38,19 @@
+  *    @(#)strfile.h   8.1 (Berkeley) 5/31/93
+  */
+-/* Modified Jan 2000, Chris Ausbrooks <weed@bucket.pp.ualr.edu>
+- *  + Changed VERSION to FILE_VERSION to avoid warnings caused by
+- *    automake/autoconf.
+- */
+-
+ #define       STR_ENDSTRING(line,tbl) \
+       ((line)[0] == (tbl).str_delim && (line)[1] == '\n')
+ typedef struct {                              /* information table */
+-#define       FILE_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 */
++#define       FILE_VERSION            2
++      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 */
+-      unsigned char   stuff[4];               /* long aligned space */
++      u_int32_t       str_flags;              /* bit field for flags */
++      u_int8_t        stuff[4];               /* long aligned space */
+ #define       str_delim       stuff[0]                /* delimiting character */
+ } STRFILE;