Added dependency libraries to ensure configure can find and use librrd.so
[openwrt/svn-archive/archive.git] / utils / fortune-mod / patches / 01-strfile-64bit-fix
1 --- fortune-mod-1.2.1/util/strfile.c.orig 2007-07-27 00:40:54.687140050 +0100
2 +++ fortune-mod-1.2.1/util/strfile.c 2007-07-27 00:41:14.184165656 +0100
3 @@ -144,7 +135,7 @@
4 typedef struct
5 {
6 char first;
7 - off_t pos;
8 + int32_t pos;
9 }
10 STR;
11
12 @@ -159,7 +150,7 @@
13 int Xflag = FALSE; /* set rotated bit */
14 long Num_pts = 0; /* number of pointers/strings */
15
16 -off_t *Seekpts;
17 +int32_t *Seekpts;
18
19 FILE *Sort_1, *Sort_2; /* pointers for sorting */
20
21 @@ -237,9 +228,9 @@
22 * add_offset:
23 * Add an offset to the list, or write it out, as appropriate.
24 */
25 -void add_offset(FILE * fp, off_t off)
26 +void add_offset(FILE * fp, int32_t off)
27 {
28 - off_t net;
29 + int32_t net;
30
31 if (!STORING_PTRS)
32 {
33 @@ -258,9 +249,9 @@
34 * fix_last_offset:
35 * Used when we have two separators in a row.
36 */
37 -void fix_last_offset(FILE * fp, off_t off)
38 +void fix_last_offset(FILE * fp, int32_t off)
39 {
40 - off_t net;
41 + int32_t net;
42
43 if (!STORING_PTRS)
44 {
45 @@ -333,7 +324,7 @@
46 do_order(void)
47 {
48 register long i;
49 - register off_t *lp;
50 + register int32_t *lp;
51 register STR *fp;
52
53 Sort_1 = fopen(Infile, "r");
54 @@ -384,8 +375,8 @@
55 void randomize(void)
56 {
57 register int cnt, i;
58 - register off_t tmp;
59 - register off_t *sp;
60 + register int32_t tmp;
61 + register int32_t *sp;
62 extern time_t time(time_t *);
63
64 srandom((int) (time((time_t *) NULL) + getpid()));
65 @@ -422,7 +413,7 @@
66 {
67 register unsigned char *sp;
68 register FILE *inf, *outf;
69 - register off_t last_off, length, pos, *p;
70 + register int32_t last_off, length, pos, *p;
71 register int first, cnt;
72 register char *nsp;
73 register STR *fp;
74 @@ -514,14 +505,19 @@
75 if (!Sflag)
76 {
77 printf("\"%s\" created\n", Outfile);
78 - if (Num_pts == 2)
79 - puts("There was 1 string");
80 + if (Num_pts == 1)
81 + puts("There was no string");
82 else
83 - printf("There were %ld strings\n", Num_pts - 1);
84 - printf("Longest string: %lu byte%s\n", Tbl.str_longlen,
85 - Tbl.str_longlen == 1 ? "" : "s");
86 - printf("Shortest string: %lu byte%s\n", Tbl.str_shortlen,
87 - Tbl.str_shortlen == 1 ? "" : "s");
88 + {
89 + if (Num_pts == 2)
90 + puts("There was 1 string");
91 + else
92 + printf("There were %ld strings\n", Num_pts - 1);
93 + printf("Longest string: %lu byte%s\n", Tbl.str_longlen,
94 + Tbl.str_longlen == 1 ? "" : "s");
95 + printf("Shortest string: %lu byte%s\n", Tbl.str_shortlen,
96 + Tbl.str_shortlen == 1 ? "" : "s");
97 + }
98 }
99
100 fseek(outf, (off_t) 0, 0);
101 @@ -533,12 +529,19 @@
102 Tbl.str_longlen = htonl(Tbl.str_longlen);
103 Tbl.str_shortlen = htonl(Tbl.str_shortlen);
104 Tbl.str_flags = htonl(Tbl.str_flags);
105 - fwrite((char *) &Tbl, sizeof Tbl, 1, outf);
106 + fwrite(&Tbl.str_version, sizeof Tbl.str_version, 1, outf);
107 + fwrite(&Tbl.str_numstr, sizeof Tbl.str_numstr, 1, outf);
108 + fwrite(&Tbl.str_longlen, sizeof Tbl.str_longlen, 1, outf);
109 + fwrite(&Tbl.str_shortlen, sizeof Tbl.str_shortlen, 1, outf);
110 + fwrite(&Tbl.str_flags, sizeof Tbl.str_flags, 1, outf);
111 + fwrite( Tbl.stuff, sizeof Tbl.stuff, 1, outf);
112 if (STORING_PTRS)
113 {
114 for (p = Seekpts, cnt = Num_pts; cnt--; ++p)
115 + {
116 *p = htonl(*p);
117 - fwrite((char *) Seekpts, sizeof *Seekpts, (int) Num_pts, outf);
118 + fwrite(p, sizeof *p, 1, outf);
119 + }
120 }
121 fclose(outf);
122 exit(0);
123 --- fortune-mod-1.2.1/util/strfile.h 2000-01-29 11:14:34.000000000 +0000
124 +++ fortune-mod-1.2.1/util/strfile.h 2007-07-27 00:25:46.825640014 +0100
125 @@ -38,24 +38,19 @@
126 * @(#)strfile.h 8.1 (Berkeley) 5/31/93
127 */
128
129 -/* Modified Jan 2000, Chris Ausbrooks <weed@bucket.pp.ualr.edu>
130 - * + Changed VERSION to FILE_VERSION to avoid warnings caused by
131 - * automake/autoconf.
132 - */
133 -
134 #define STR_ENDSTRING(line,tbl) \
135 ((line)[0] == (tbl).str_delim && (line)[1] == '\n')
136
137 typedef struct { /* information table */
138 -#define FILE_VERSION 1
139 - unsigned long str_version; /* version number */
140 - unsigned long str_numstr; /* # of strings in the file */
141 - unsigned long str_longlen; /* length of longest string */
142 - unsigned long str_shortlen; /* length of shortest string */
143 +#define FILE_VERSION 2
144 + u_int32_t str_version; /* version number */
145 + u_int32_t str_numstr; /* # of strings in the file */
146 + u_int32_t str_longlen; /* length of longest string */
147 + u_int32_t str_shortlen; /* length of shortest string */
148 #define STR_RANDOM 0x1 /* randomized pointers */
149 #define STR_ORDERED 0x2 /* ordered pointers */
150 #define STR_ROTATED 0x4 /* rot-13'd text */
151 - unsigned long str_flags; /* bit field for flags */
152 - unsigned char stuff[4]; /* long aligned space */
153 + u_int32_t str_flags; /* bit field for flags */
154 + u_int8_t stuff[4]; /* long aligned space */
155 #define str_delim stuff[0] /* delimiting character */
156 } STRFILE;