summaryrefslogtreecommitdiffstats
path: root/extra/source/xv/xv-3.10a-enhancements.20070520-20081216.diff
blob: c9b5528f51eedc17d595b5d9efd1db3325e2f80d (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
  20070621
    fixed improper ClearCode termination condition in GIF decoder (JZ); fixed
    some minor inconsistencies in Makefile (GRR)
        - xv-joe-zbiciak-20070621-gif-decoder-bugfix.dif

  20080121
    removed duplicate "XDestroyWindow(theDisp, pngW);" in xvmisc.c (IMC); fixed
    empty-filename click-and-crash bug in xvdir.c (IMC, DB)
        - xv-ian-collier-20080118-crash-fixes.msg
        - xv-david-bath-20080901-empty-filename-save-crash-fix.dif

  20081205
    reverted xvxwd.c to SJT's version (bug reported by Jari Ruusu)

  20081216
    fixed crash-bug in IFF decoder (EP)
        - xv-elmar-plischke-20081216-xviff-crash-fix.dif



diff -ru ../test3.20070520.stock/xv-3.10a/xv.h ./xv.h
--- ../test3.20070520.stock/xv-3.10a/xv.h	2007-05-20 22:23:33.000000000 -0700
+++ ./xv.h	2008-12-16 09:45:00.000000000 -0800
@@ -16,8 +16,9 @@
 /* GRR 2nd public jumbo F+E patches:	20050410 */
 /* GRR 3rd public jumbo F+E patches:	20050501 */
 /* GRR 4th public jumbo F+E patch:  	20070520 */
-#define REVDATE   "version 3.10a-jumboFix+Enh of 20070520"
-#define VERSTR    "3.10a-20070520"
+/* GRR 5th public jumbo F+E patch:  	200xxxxx (probably mid-2009) */
+#define REVDATE   "version 3.10a-jumboFix+Enh of 20081216 (interim!)"
+#define VERSTR    "3.10a-20081216"
 
 /*
  * uncomment the following, and modify for your site, but only if you've



diff -ru ../test3.20070520.stock/xv-3.10a/xvdir.c ./xvdir.c
--- ../test3.20070520.stock/xv-3.10a/xvdir.c	2007-05-20 22:23:33.000000000 -0700
+++ ./xvdir.c	2008-01-21 13:02:38.000000000 -0800
@@ -539,8 +539,9 @@
     return -1;
   }
 
-  /* handle clicks inside the filename box */
-  if (x > 80 &&
+  /* handle clicks inside the filename box, but only when box is not empty */
+  if (enPos > stPos &&
+      x > 80 &&
       y > dList.y + (int) dList.h + 30 &&
       x < 80 + DNAMWIDE+6 &&
       y < dList.y + (int) dList.h + 30 + LINEHIGH+5) {



diff -ru ../test3.20070520.stock/xv-3.10a/xvgif.c ./xvgif.c
--- ../test3.20070520.stock/xv-3.10a/xvgif.c	2007-05-20 22:23:33.000000000 -0700
+++ ./xvgif.c	2007-06-21 09:36:40.000000000 -0700
@@ -700,7 +700,7 @@
        * associated output code on the output queue.
        */
 
-      while (CurCode > BitMask) {
+      while (CurCode >= ClearCode) {  /* Joe Zbiciak fix, 20070621 */
 	if (OutCount > 4096) break;   /* corrupt file */
 	OutCode[OutCount++] = Suffix[CurCode];
 	CurCode = Prefix[CurCode];



diff -ru ../test3.20070520.stock/xv-3.10a/xvmisc.c ./xvmisc.c
--- ../test3.20070520.stock/xv-3.10a/xvmisc.c	2007-05-20 22:23:33.000000000 -0700
+++ ./xvmisc.c	2008-01-21 12:57:29.000000000 -0800
@@ -561,10 +561,6 @@
     if (mgcsfxW) XDestroyWindow(theDisp, mgcsfxW);
 #endif
 
-#ifdef HAVE_PNG
-    if (pngW)  XDestroyWindow(theDisp, pngW);
-#endif
-
     /* if NOT using stdcmap for images, free stdcmap */
     if (colorMapMode != CM_STDCMAP) {
       int j;



[This one reverts xvxwd.c to the pre-2007 SJT version, which actually worked...]

diff -ru ../test3.20070520.stock/xv-3.10a/xvxwd.c ./xvxwd.c
--- ../test3.20070520.stock/xv-3.10a/xvxwd.c	2007-05-20 22:23:33.000000000 -0700
+++ ./xvxwd.c	2008-12-06 00:30:44.000000000 -0800
@@ -19,6 +19,12 @@
  */
 
 #include "xv.h"
+#include <limits.h>             /* for CHAR_BIT */
+
+/* SJT: just in case ... */
+#ifndef CHAR_BIT
+#  define CHAR_BIT 8
+#endif
 
 
 /***************************** x11wd.h *****************************/
@@ -83,9 +89,14 @@
 static int    writebiglong    PARM((FILE *, CARD32));
 #endif
 
+static void   getcolorshift   PARM((CARD32, int *, int *)); /* SJT */
+
+/* SJT: for 16bpp and 24bpp shifts */
+static int    red_shift_right, red_justify_left,
+              grn_shift_right, grn_justify_left,
+              blu_shift_right, blu_justify_left;
 static byte  *pic8, *pic24;
-static CARD32 red_mask, green_mask, blue_mask;
-static int    red_shift, green_shift, blue_shift;
+static CARD32 red_mask, grn_mask, blu_mask;
 static int    bits_per_item, bits_used, bit_shift,
               bits_per_pixel, bits_per_rgb;
 static char   buf[4];
@@ -189,38 +200,34 @@
       return 0;
     }
 
-    switch (bits_per_pixel) {
-    case 16:
-    case 24:
-    case 32:
-      ;
-    default:
-      xwdError("True/Direct supports only 16, 24, and 32 bits");
-      return 0;
-    }
+    for (row=0; row<rows; row++) {
+      for (col=0, xP=pic24+(row*cols*3); col<cols; col++) {
+	CARD32 ul;
 
-    if (byte_order == MSBFirst) {
-      for (row=0; row<rows; row++) {
-        for (col=0, xP=pic24+(row*cols*3); col<cols; col++) {
-          register CARD32 ul = getpixnum(ifp);
-
-          *xP++ = ul >> red_shift   & red_mask  ;
-          *xP++ = ul >> green_shift & green_mask;
-          *xP++ = ul >> blue_shift  & blue_mask ;
-        };
-        for (col=0; col<padright; col++) getpixnum(ifp);
-      }
-    } else {
-      for (row=0; row<rows; row++) {
-        for (col=0, xP=pic24+(row*cols*3); col<cols; col++) {
-          register CARD32 ul = getpixnum(ifp);
-
-          *xP++ = ul >> blue_shift  & blue_mask ;
-          *xP++ = ul >> green_shift & green_mask;
-          *xP++ = ul >> red_shift   & red_mask  ;
-        };
-        for (col=0; col<padright; col++) getpixnum(ifp);
+	ul = getpixnum(ifp);
+	switch (bits_per_pixel) {
+        case 16:
+        case 24:
+        case 32:
+          /* SJT: shift all the way to the right and then shift left. The
+             pairs of shifts could be combined. There will be two right and
+             one left shift, but it's unknown which will be which. It seems
+             easier to do the shifts (which might be 0) separately than to
+             have a complex set of tests. I believe this is independent of
+             byte order but I have no way to test.
+           */
+          *xP++ = ((ul & red_mask) >> red_shift_right) << red_justify_left;
+          *xP++ = ((ul & grn_mask) >> grn_shift_right) << grn_justify_left;
+          *xP++ = ((ul & blu_mask) >> blu_shift_right) << blu_justify_left;
+          break;
+
+	default:
+	  xwdError("True/Direct supports only 16, 24, and 32 bits");
+	  return 0;
+	}
       }
+
+      for (col=0; col<padright; col++) getpixnum(ifp);
     }
 
     pinfo->type = PIC24;
@@ -445,28 +452,18 @@
      (i.e., 3 bytes, no alpha/padding) */
 
 
-  bits_used      = bits_per_item;
+  bits_used  = bits_per_item;
 
   if (bits_per_pixel == sizeof(pixel_mask) * 8)  pixel_mask = (CARD32) -1;
   else pixel_mask = (1 << bits_per_pixel) - 1;
 
-  red_mask   = h11P->red_mask;
-  green_mask = h11P->grn_mask;
-  blue_mask  = h11P->blu_mask;
-
-  red_shift = blue_shift = green_shift = 0;
-  while (!(red_mask & 1)) {
-    red_mask >>= 1;
-    ++red_shift;
-  }
-  while (!(blue_mask & 1)) {
-    blue_mask >>= 1;
-    ++blue_shift;
-  }
-  while (!(green_mask & 1)) {
-    green_mask >>= 1;
-    ++green_shift;
-  }
+  red_mask = h11P->red_mask;
+  grn_mask = h11P->grn_mask;
+  blu_mask = h11P->blu_mask;
+
+  getcolorshift(red_mask, &red_shift_right, &red_justify_left);
+  getcolorshift(grn_mask, &grn_shift_right, &grn_justify_left);
+  getcolorshift(blu_mask, &blu_shift_right, &blu_justify_left);
 
   byteP  = (char   *) buf;
   shortP = (CARD16 *) buf;
@@ -476,6 +473,45 @@
 }
 
 
+/* SJT: figure out the proper shifts */
+static void getcolorshift (CARD32 mask, int *rightshift, int *leftshift)
+{
+  int lshift, rshift;
+  unsigned int uu;
+
+  if (mask == 0)
+  {
+    *rightshift = *leftshift = 0;
+    return;
+  }
+
+  uu = mask;
+  lshift = rshift = 0;
+  while ((uu & 0xf) == 0)
+  {
+      rshift += 4;
+      uu >>= 4;
+  }
+  while ((uu & 1) == 0)
+  {
+      rshift++;
+      uu >>= 1;
+  }
+
+  while (uu != 0)
+  {
+      if (uu & 1)
+      {
+          lshift++;
+          uu >>= 1;
+      }
+  }
+  *rightshift = rshift;
+  *leftshift = CHAR_BIT * sizeof(pixel) - lshift;
+  return;
+}
+
+
 /******************************/
 static CARD32 getpixnum(file)
      FILE* file;



diff -ru ../test3.20070520.stock/xv-3.10a/xviff.c ./xviff.c
--- ../test3.20070520.stock/xv-3.10a/xviff.c	2007-05-13 17:50:59.000000000 -0700
+++ ./xviff.c	2008-12-16 09:20:25.000000000 -0800
@@ -73,6 +73,7 @@
   int           BMHDok, CMAPok, CAMGok;
   int           bmhd_width, bmhd_height, bmhd_bitplanes, bmhd_transcol;
   int           i, j, k, lineskip, colors, fmt;
+  int           npixels = 0; /* needs to be initialized _outside_ while-loop */
   byte          bmhd_masking, bmhd_compression;
   long          chunkLen, camg_viewmode;
   byte          *databuf, *dataptr, *cmapptr, *picptr, *pic, *bodyptr;
@@ -138,7 +139,6 @@
      BODY chunk was found or dataptr ran over end of file */
 
   while ((rv<0) && (dataptr < (databuf + filesize))) {
-    int npixels = 0;
     chunkLen = (iff_getlong(dataptr + 4) + 1) & 0xfffffffe; /* make even */
 
     if (strncmp((char *) dataptr, "BMHD", (size_t) 4)==0) { /* BMHD chunk? */