1From: Yoshida Hiroshi <BXH04165@nifty.ne.jp>
2Subject: Add support for PNG images and other misc fixes.
3
4diff -urNad xloadimage-4.1~/Makefile.in xloadimage-4.1/Makefile.in
5--- xloadimage-4.1~/Makefile.in	2005-12-06 02:59:07.000000000 +0000
6+++ xloadimage-4.1/Makefile.in	2005-12-06 02:59:07.000000000 +0000
7@@ -5,7 +5,7 @@
8 CC = @CC@
9 DEFS = @DEFS@
10 CFLAGS = @CFLAGS@
11-XLIB = @X_LIBS@ @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@
12+XLIB = @X_LIBS@ -lX11 @X_EXTRA_LIBS@
13 LDFLAGS = @LDFLAGS@
14 LIBS = @LIBS@
15
16@@ -14,7 +14,7 @@
17 mac.c mc_tables.c mcidas.c merge.c misc.c new.c niff.c options.c \
18 pbm.c pcx.c pdsuncomp.c reduce.c rle.c rlelib.c root.c rotate.c \
19 send.c smooth.c sunraster.c tiff.c undither.c value.c vff.c \
20-vicar.c window.c xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c
21+vicar.c window.c xbitmap.c xloadimage.c xpixmap.c xwd.c zio.c zoom.c png.c
22
23 OBJS = $(SRCS:.c=.o)
24 PROG = xloadimage
25@@ -24,7 +24,7 @@
26 $(PROG): $(OBJS)
27 	./build-info
28 	$(CC) $(CFLAGS) -c $(DEFS) build.c
29-	$(CC) -o $@ $(OBJS) build.o$(LDFLAGS) $(XLIB) $(LIBS)
30+	$(CC) -o $@ $(OBJS) build.o $(LDFLAGS) $(XLIB) $(LIBS)
31
32 uufilter: uufilter.c
33 	$(CC) $(CFLAGS) $(DEFS) uufilter.c -o $@
34@@ -34,8 +34,13 @@
35
36 build.c:
37 	./build-info
38+
39 clean:
40-	rm -f $(PROG) uufilter build.c *.o
41+	rm -f autoconfig build.c err
42+#	cd jpeg ; make clean
43+#	cd tiff ; make clean
44+	rm -f *.o *~ xloadimage uufilter autoconfig libconfig packtar \
45+	  buildshar doshar shar.* *.tar *.tar.Z *.tc
46
47 distclean:
48 	make clean
49diff -urNad xloadimage-4.1~/bright.c xloadimage-4.1/bright.c
50--- xloadimage-4.1~/bright.c	2005-12-06 02:59:04.000000000 +0000
51+++ xloadimage-4.1/bright.c	2005-12-06 02:59:07.000000000 +0000
52@@ -73,9 +73,10 @@
53      double disp_gam;
54      unsigned int verbose;
55 { int          a;
56-  int gammamap[256];
57-  unsigned int size;
58+  static int gammamap[256];
59   byte        *destptr;
60+  const byte  *endptr, *srcptr;
61+  static double old_gamma = -1.0;
62
63   goodImage(image, "gammacorrect");
64   if (BITMAPP(image)) /* we're AT&T */
65@@ -86,7 +87,9 @@
66     fflush(stdout);
67   }
68
69-  make_gamma(disp_gam,gammamap);
70+  if( disp_gam != old_gamma)
71+    make_gamma(disp_gam,gammamap);
72+  old_gamma = disp_gam;
73
74   switch (image->type) {
75   case IRGB:
76@@ -98,12 +101,13 @@
77     break;
78
79   case ITRUE:
80-    size= image->width * image->height * 3;
81-    destptr= image->data;
82-    for (a= 0; a < size; a++) {
83-      *destptr= gammamap[*destptr];
84-      destptr++;
85-    }
86+    srcptr = destptr = image->data;
87+    endptr = destptr + image->width * image->height * 3;
88+    do {
89+      *destptr++ = gammamap[*srcptr++];
90+      *destptr++ = gammamap[*srcptr++];
91+      *destptr++ = gammamap[*srcptr++];
92+    } while (srcptr < endptr);
93     break;
94   }
95
96diff -urNad xloadimage-4.1~/compress.c xloadimage-4.1/compress.c
97--- xloadimage-4.1~/compress.c	2005-12-06 02:59:04.000000000 +0000
98+++ xloadimage-4.1/compress.c	2005-12-06 02:59:07.000000000 +0000
99@@ -30,7 +30,7 @@
100
101 #define NIL_PIXEL 0xffffffff
102
103-void compress(image, verbose)
104+void compress_cmap(image, verbose)
105      Image        *image;
106      unsigned int  verbose;
107 { Pixel         hash_table[32768];
108diff -urNad xloadimage-4.1~/config.c xloadimage-4.1/config.c
109--- xloadimage-4.1~/config.c	2005-12-06 02:59:04.000000000 +0000
110+++ xloadimage-4.1/config.c	2005-12-06 02:59:07.000000000 +0000
111@@ -17,7 +17,7 @@
112 #include <pwd.h>
113 #endif
114 #include <errno.h>
115-#ifndef IS_BSD
116+#ifdef HAVE_UNISTD_H
117 #include <unistd.h>
118 #endif
119
120diff -urNad xloadimage-4.1~/config.h.in xloadimage-4.1/config.h.in
121--- xloadimage-4.1~/config.h.in	2005-12-06 02:59:07.000000000 +0000
122+++ xloadimage-4.1/config.h.in	2005-12-06 02:59:07.000000000 +0000
123@@ -9,9 +9,6 @@
124 /* Define if the X Window System is missing or not being used.  */
125 #undef X_DISPLAY_MISSING
126
127-/* Define if you have the mkdir function.  */
128-#undef HAVE_MKDIR
129-
130 /* Define if you have the select function.  */
131 #undef HAVE_SELECT
132
133@@ -27,14 +24,17 @@
134 /* Define if you have the <unistd.h> header file.  */
135 #undef HAVE_UNISTD_H
136
137-/* Define if you have the jpeg library (-ljpeg).  */
138-#undef HAVE_LIBJPEG
139-
140 /* Define if you have the m library (-lm).  */
141 #undef HAVE_LIBM
142
143+/* Define if you have the jpeg library (-ljpeg).  */
144+#undef HAVE_LIBJPEG
145+
146 /* Define if you have the tiff library (-ltiff).  */
147 #undef HAVE_LIBTIFF
148
149+/* Define if you have the png library (-lpng).  */
150+#undef HAVE_LIBPNG
151+
152 /* Define if you have the z library (-lz).  */
153 #undef HAVE_LIBZ
154diff -urNad xloadimage-4.1~/configure xloadimage-4.1/configure
155--- xloadimage-4.1~/configure	2005-12-06 02:59:07.000000000 +0000
156+++ xloadimage-4.1/configure	2005-12-06 02:59:07.000000000 +0000
157@@ -1,7 +1,7 @@
158 #! /bin/sh
159
160 # Guess values for system-dependent variables and create Makefiles.
161-# Generated automatically using autoconf version 2.12
162+# Generated automatically using autoconf version 2.13
163 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
164 #
165 # This configure script is free software; the Free Software Foundation
166@@ -51,6 +51,7 @@
167 # Initialize some other variables.
168 subdirs=
169 MFLAGS= MAKEFLAGS=
170+SHELL=${CONFIG_SHELL-/bin/sh}
171 # Maximum number of lines to put in a shell here document.
172 ac_max_here_lines=12
173
174@@ -334,7 +335,7 @@
175     verbose=yes ;;
176
177   -version | --version | --versio | --versi | --vers)
178-    echo "configure generated by autoconf version 2.12"
179+    echo "configure generated by autoconf version 2.13"
180     exit 0 ;;
181
182   -with-* | --with-*)
183@@ -504,9 +505,11 @@
184 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
185 ac_cpp='$CPP $CPPFLAGS'
186 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
187-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
188+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
189 cross_compiling=$ac_cv_prog_cc_cross
190
191+ac_exeext=
192+ac_objext=o
193 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
194   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
195   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
196@@ -525,15 +528,16 @@
197 # Extract the first word of "gcc", so it can be a program name with args.
198 set dummy gcc; ac_word=$2
199 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
200-echo "configure:529: checking for $ac_word" >&5
201+echo "configure:532: checking for $ac_word" >&5
202 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
203   echo $ac_n "(cached) $ac_c" 1>&6
204 else
205   if test -n "$CC"; then
206   ac_cv_prog_CC="$CC" # Let the user override the test.
207 else
208-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
209-  for ac_dir in $PATH; do
210+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
211+  ac_dummy="$PATH"
212+  for ac_dir in $ac_dummy; do
213     test -z "$ac_dir" && ac_dir=.
214     if test -f $ac_dir/$ac_word; then
215       ac_cv_prog_CC="gcc"
216@@ -554,16 +558,17 @@
217   # Extract the first word of "cc", so it can be a program name with args.
218 set dummy cc; ac_word=$2
219 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
220-echo "configure:558: checking for $ac_word" >&5
221+echo "configure:562: checking for $ac_word" >&5
222 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
223   echo $ac_n "(cached) $ac_c" 1>&6
224 else
225   if test -n "$CC"; then
226   ac_cv_prog_CC="$CC" # Let the user override the test.
227 else
228-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
229+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
230   ac_prog_rejected=no
231-  for ac_dir in $PATH; do
232+  ac_dummy="$PATH"
233+  for ac_dir in $ac_dummy; do
234     test -z "$ac_dir" && ac_dir=.
235     if test -f $ac_dir/$ac_word; then
236       if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
237@@ -598,25 +603,61 @@
238   echo "$ac_t""no" 1>&6
239 fi
240
241+  if test -z "$CC"; then
242+    case "`uname -s`" in
243+    *win32* | *WIN32*)
244+      # Extract the first word of "cl", so it can be a program name with args.
245+set dummy cl; ac_word=$2
246+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
247+echo "configure:613: checking for $ac_word" >&5
248+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
249+  echo $ac_n "(cached) $ac_c" 1>&6
250+else
251+  if test -n "$CC"; then
252+  ac_cv_prog_CC="$CC" # Let the user override the test.
253+else
254+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
255+  ac_dummy="$PATH"
256+  for ac_dir in $ac_dummy; do
257+    test -z "$ac_dir" && ac_dir=.
258+    if test -f $ac_dir/$ac_word; then
259+      ac_cv_prog_CC="cl"
260+      break
261+    fi
262+  done
263+  IFS="$ac_save_ifs"
264+fi
265+fi
266+CC="$ac_cv_prog_CC"
267+if test -n "$CC"; then
268+  echo "$ac_t""$CC" 1>&6
269+else
270+  echo "$ac_t""no" 1>&6
271+fi
272+ ;;
273+    esac
274+  fi
275   test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
276 fi
277
278 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
279-echo "configure:606: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
280+echo "configure:645: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
281
282 ac_ext=c
283 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
284 ac_cpp='$CPP $CPPFLAGS'
285 ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
286-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
287+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
288 cross_compiling=$ac_cv_prog_cc_cross
289
290-cat > conftest.$ac_ext <<EOF
291-#line 616 "configure"
292+cat > conftest.$ac_ext << EOF
293+
294+#line 656 "configure"
295 #include "confdefs.h"
296+
297 main(){return(0);}
298 EOF
299-if { (eval echo configure:620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
300+if { (eval echo configure:661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
301   ac_cv_prog_cc_works=yes
302   # If we can't run a trivial program, we are probably using a cross compiler.
303   if (./conftest; exit) 2>/dev/null; then
304@@ -630,18 +671,24 @@
305   ac_cv_prog_cc_works=no
306 fi
307 rm -fr conftest*
308+ac_ext=c
309+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
310+ac_cpp='$CPP $CPPFLAGS'
311+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
312+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
313+cross_compiling=$ac_cv_prog_cc_cross
314
315 echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
316 if test $ac_cv_prog_cc_works = no; then
317   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
318 fi
319 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
320-echo "configure:640: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
321+echo "configure:687: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
322 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
323 cross_compiling=$ac_cv_prog_cc_cross
324
325 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
326-echo "configure:645: checking whether we are using GNU C" >&5
327+echo "configure:692: checking whether we are using GNU C" >&5
328 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
329   echo $ac_n "(cached) $ac_c" 1>&6
330 else
331@@ -650,7 +697,7 @@
332   yes;
333 #endif
334 EOF
335-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:654: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
336+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:701: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
337   ac_cv_prog_gcc=yes
338 else
339   ac_cv_prog_gcc=no
340@@ -661,11 +708,15 @@
341
342 if test $ac_cv_prog_gcc = yes; then
343   GCC=yes
344-  ac_test_CFLAGS="${CFLAGS+set}"
345-  ac_save_CFLAGS="$CFLAGS"
346-  CFLAGS=
347-  echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
348-echo "configure:669: checking whether ${CC-cc} accepts -g" >&5
349+else
350+  GCC=
351+fi
352+
353+ac_test_CFLAGS="${CFLAGS+set}"
354+ac_save_CFLAGS="$CFLAGS"
355+CFLAGS=
356+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
357+echo "configure:720: checking whether ${CC-cc} accepts -g" >&5
358 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
359   echo $ac_n "(cached) $ac_c" 1>&6
360 else
361@@ -680,21 +731,25 @@
362 fi
363
364 echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
365-  if test "$ac_test_CFLAGS" = set; then
366-    CFLAGS="$ac_save_CFLAGS"
367-  elif test $ac_cv_prog_cc_g = yes; then
368+if test "$ac_test_CFLAGS" = set; then
369+  CFLAGS="$ac_save_CFLAGS"
370+elif test $ac_cv_prog_cc_g = yes; then
371+  if test "$GCC" = yes; then
372     CFLAGS="-g -O2"
373   else
374-    CFLAGS="-O2"
375+    CFLAGS="-g"
376   fi
377 else
378-  GCC=
379-  test "${CFLAGS+set}" = set || CFLAGS="-g"
380+  if test "$GCC" = yes; then
381+    CFLAGS="-O2"
382+  else
383+    CFLAGS=
384+  fi
385 fi
386
387
388 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
389-echo "configure:698: checking how to run the C preprocessor" >&5
390+echo "configure:753: checking how to run the C preprocessor" >&5
391 # On Suns, sometimes $CPP names a directory.
392 if test -n "$CPP" && test -d "$CPP"; then
393   CPP=
394@@ -709,14 +764,14 @@
395   # On the NeXT, cc -E runs the code through the compiler's parser,
396   # not just through cpp.
397   cat > conftest.$ac_ext <<EOF
398-#line 713 "configure"
399+#line 768 "configure"
400 #include "confdefs.h"
401 #include <assert.h>
402 Syntax Error
403 EOF
404 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
405-{ (eval echo configure:719: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
406-ac_err=`grep -v '^ *+' conftest.out`
407+{ (eval echo configure:774: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
408+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
409 if test -z "$ac_err"; then
410   :
411 else
412@@ -726,14 +781,31 @@
413   rm -rf conftest*
414   CPP="${CC-cc} -E -traditional-cpp"
415   cat > conftest.$ac_ext <<EOF
416-#line 730 "configure"
417+#line 785 "configure"
418 #include "confdefs.h"
419 #include <assert.h>
420 Syntax Error
421 EOF
422 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
423-{ (eval echo configure:736: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
424-ac_err=`grep -v '^ *+' conftest.out`
425+{ (eval echo configure:791: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
426+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
427+if test -z "$ac_err"; then
428+  :
429+else
430+  echo "$ac_err" >&5
431+  echo "configure: failed program was:" >&5
432+  cat conftest.$ac_ext >&5
433+  rm -rf conftest*
434+  CPP="${CC-cc} -nologo -E"
435+  cat > conftest.$ac_ext <<EOF
436+#line 802 "configure"
437+#include "confdefs.h"
438+#include <assert.h>
439+Syntax Error
440+EOF
441+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
442+{ (eval echo configure:808: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
443+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
444 if test -z "$ac_err"; then
445   :
446 else
447@@ -746,6 +818,8 @@
448 rm -f conftest*
449 fi
450 rm -f conftest*
451+fi
452+rm -f conftest*
453   ac_cv_prog_CPP="$CPP"
454 fi
455   CPP="$ac_cv_prog_CPP"
456@@ -759,7 +833,7 @@
457 # Uses ac_ vars as temps to allow command line to override cache and checks.
458 # --without-x overrides everything else, but does not touch the cache.
459 echo $ac_n "checking for X""... $ac_c" 1>&6
460-echo "configure:763: checking for X" >&5
461+echo "configure:837: checking for X" >&5
462
463 # Check whether --with-x or --without-x was given.
464 if test "${with_x+set}" = set; then
465@@ -821,13 +895,13 @@
466
467   # First, try using that file with no special directory specified.
468 cat > conftest.$ac_ext <<EOF
469-#line 825 "configure"
470+#line 899 "configure"
471 #include "confdefs.h"
472 #include <$x_direct_test_include>
473 EOF
474 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
475-{ (eval echo configure:830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
476-ac_err=`grep -v '^ *+' conftest.out`
477+{ (eval echo configure:904: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
478+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
479 if test -z "$ac_err"; then
480   rm -rf conftest*
481   # We can compile using X headers with no special include directory.
482@@ -895,14 +969,14 @@
483   ac_save_LIBS="$LIBS"
484   LIBS="-l$x_direct_test_library $LIBS"
485 cat > conftest.$ac_ext <<EOF
486-#line 899 "configure"
487+#line 973 "configure"
488 #include "confdefs.h"
489
490 int main() {
491 ${x_direct_test_function}()
492 ; return 0; }
493 EOF
494-if { (eval echo configure:906: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
495+if { (eval echo configure:980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
496   rm -rf conftest*
497   LIBS="$ac_save_LIBS"
498 # We can link X programs with no special library path.
499@@ -1008,17 +1082,17 @@
500     case "`(uname -sr) 2>/dev/null`" in
501     "SunOS 5"*)
502       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
503-echo "configure:1012: checking whether -R must be followed by a space" >&5
504+echo "configure:1086: checking whether -R must be followed by a space" >&5
505       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
506       cat > conftest.$ac_ext <<EOF
507-#line 1015 "configure"
508+#line 1089 "configure"
509 #include "confdefs.h"
510
511 int main() {
512
513 ; return 0; }
514 EOF
515-if { (eval echo configure:1022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
516+if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
517   rm -rf conftest*
518   ac_R_nospace=yes
519 else
520@@ -1034,14 +1108,14 @@
521       else
522 	LIBS="$ac_xsave_LIBS -R $x_libraries"
523 	cat > conftest.$ac_ext <<EOF
524-#line 1038 "configure"
525+#line 1112 "configure"
526 #include "confdefs.h"
527
528 int main() {
529
530 ; return 0; }
531 EOF
532-if { (eval echo configure:1045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
533+if { (eval echo configure:1119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
534   rm -rf conftest*
535   ac_R_space=yes
536 else
537@@ -1073,7 +1147,7 @@
538     # libraries were built with DECnet support.  And karl@cs.umb.edu says
539     # the Alpha needs dnet_stub (dnet does not exist).
540     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
541-echo "configure:1077: checking for dnet_ntoa in -ldnet" >&5
542+echo "configure:1151: checking for dnet_ntoa in -ldnet" >&5
543 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
544 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
545   echo $ac_n "(cached) $ac_c" 1>&6
546@@ -1081,7 +1155,7 @@
547   ac_save_LIBS="$LIBS"
548 LIBS="-ldnet  $LIBS"
549 cat > conftest.$ac_ext <<EOF
550-#line 1085 "configure"
551+#line 1159 "configure"
552 #include "confdefs.h"
553 /* Override any gcc2 internal prototype to avoid an error.  */
554 /* We use char because int might match the return type of a gcc2
555@@ -1092,7 +1166,7 @@
556 dnet_ntoa()
557 ; return 0; }
558 EOF
559-if { (eval echo configure:1096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
560+if { (eval echo configure:1170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
561   rm -rf conftest*
562   eval "ac_cv_lib_$ac_lib_var=yes"
563 else
564@@ -1114,7 +1188,7 @@
565
566     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
567       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
568-echo "configure:1118: checking for dnet_ntoa in -ldnet_stub" >&5
569+echo "configure:1192: checking for dnet_ntoa in -ldnet_stub" >&5
570 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
571 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
572   echo $ac_n "(cached) $ac_c" 1>&6
573@@ -1122,7 +1196,7 @@
574   ac_save_LIBS="$LIBS"
575 LIBS="-ldnet_stub  $LIBS"
576 cat > conftest.$ac_ext <<EOF
577-#line 1126 "configure"
578+#line 1200 "configure"
579 #include "confdefs.h"
580 /* Override any gcc2 internal prototype to avoid an error.  */
581 /* We use char because int might match the return type of a gcc2
582@@ -1133,7 +1207,7 @@
583 dnet_ntoa()
584 ; return 0; }
585 EOF
586-if { (eval echo configure:1137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
587+if { (eval echo configure:1211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
588   rm -rf conftest*
589   eval "ac_cv_lib_$ac_lib_var=yes"
590 else
591@@ -1162,12 +1236,12 @@
592     # The nsl library prevents programs from opening the X display
593     # on Irix 5.2, according to dickey@clark.net.
594     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
595-echo "configure:1166: checking for gethostbyname" >&5
596+echo "configure:1240: checking for gethostbyname" >&5
597 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
598   echo $ac_n "(cached) $ac_c" 1>&6
599 else
600   cat > conftest.$ac_ext <<EOF
601-#line 1171 "configure"
602+#line 1245 "configure"
603 #include "confdefs.h"
604 /* System header to define __stub macros and hopefully few prototypes,
605     which can conflict with char gethostbyname(); below.  */
606@@ -1190,7 +1264,7 @@
607
608 ; return 0; }
609 EOF
610-if { (eval echo configure:1194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
611+if { (eval echo configure:1268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
612   rm -rf conftest*
613   eval "ac_cv_func_gethostbyname=yes"
614 else
615@@ -1211,7 +1285,7 @@
616
617     if test $ac_cv_func_gethostbyname = no; then
618       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
619-echo "configure:1215: checking for gethostbyname in -lnsl" >&5
620+echo "configure:1289: checking for gethostbyname in -lnsl" >&5
621 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
622 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
623   echo $ac_n "(cached) $ac_c" 1>&6
624@@ -1219,7 +1293,7 @@
625   ac_save_LIBS="$LIBS"
626 LIBS="-lnsl  $LIBS"
627 cat > conftest.$ac_ext <<EOF
628-#line 1223 "configure"
629+#line 1297 "configure"
630 #include "confdefs.h"
631 /* Override any gcc2 internal prototype to avoid an error.  */
632 /* We use char because int might match the return type of a gcc2
633@@ -1230,7 +1304,7 @@
634 gethostbyname()
635 ; return 0; }
636 EOF
637-if { (eval echo configure:1234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
638+if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
639   rm -rf conftest*
640   eval "ac_cv_lib_$ac_lib_var=yes"
641 else
642@@ -1260,12 +1334,12 @@
643     # -lsocket must be given before -lnsl if both are needed.
644     # We assume that if connect needs -lnsl, so does gethostbyname.
645     echo $ac_n "checking for connect""... $ac_c" 1>&6
646-echo "configure:1264: checking for connect" >&5
647+echo "configure:1338: checking for connect" >&5
648 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
649   echo $ac_n "(cached) $ac_c" 1>&6
650 else
651   cat > conftest.$ac_ext <<EOF
652-#line 1269 "configure"
653+#line 1343 "configure"
654 #include "confdefs.h"
655 /* System header to define __stub macros and hopefully few prototypes,
656     which can conflict with char connect(); below.  */
657@@ -1288,7 +1362,7 @@
658
659 ; return 0; }
660 EOF
661-if { (eval echo configure:1292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
662+if { (eval echo configure:1366: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
663   rm -rf conftest*
664   eval "ac_cv_func_connect=yes"
665 else
666@@ -1309,7 +1383,7 @@
667
668     if test $ac_cv_func_connect = no; then
669       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
670-echo "configure:1313: checking for connect in -lsocket" >&5
671+echo "configure:1387: checking for connect in -lsocket" >&5
672 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
673 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
674   echo $ac_n "(cached) $ac_c" 1>&6
675@@ -1317,7 +1391,7 @@
676   ac_save_LIBS="$LIBS"
677 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
678 cat > conftest.$ac_ext <<EOF
679-#line 1321 "configure"
680+#line 1395 "configure"
681 #include "confdefs.h"
682 /* Override any gcc2 internal prototype to avoid an error.  */
683 /* We use char because int might match the return type of a gcc2
684@@ -1328,7 +1402,7 @@
685 connect()
686 ; return 0; }
687 EOF
688-if { (eval echo configure:1332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
689+if { (eval echo configure:1406: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
690   rm -rf conftest*
691   eval "ac_cv_lib_$ac_lib_var=yes"
692 else
693@@ -1352,12 +1426,12 @@
694
695     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
696     echo $ac_n "checking for remove""... $ac_c" 1>&6
697-echo "configure:1356: checking for remove" >&5
698+echo "configure:1430: checking for remove" >&5
699 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
700   echo $ac_n "(cached) $ac_c" 1>&6
701 else
702   cat > conftest.$ac_ext <<EOF
703-#line 1361 "configure"
704+#line 1435 "configure"
705 #include "confdefs.h"
706 /* System header to define __stub macros and hopefully few prototypes,
707     which can conflict with char remove(); below.  */
708@@ -1380,7 +1454,7 @@
709
710 ; return 0; }
711 EOF
712-if { (eval echo configure:1384: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
713+if { (eval echo configure:1458: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
714   rm -rf conftest*
715   eval "ac_cv_func_remove=yes"
716 else
717@@ -1401,7 +1475,7 @@
718
719     if test $ac_cv_func_remove = no; then
720       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
721-echo "configure:1405: checking for remove in -lposix" >&5
722+echo "configure:1479: checking for remove in -lposix" >&5
723 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
724 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
725   echo $ac_n "(cached) $ac_c" 1>&6
726@@ -1409,7 +1483,7 @@
727   ac_save_LIBS="$LIBS"
728 LIBS="-lposix  $LIBS"
729 cat > conftest.$ac_ext <<EOF
730-#line 1413 "configure"
731+#line 1487 "configure"
732 #include "confdefs.h"
733 /* Override any gcc2 internal prototype to avoid an error.  */
734 /* We use char because int might match the return type of a gcc2
735@@ -1420,7 +1494,7 @@
736 remove()
737 ; return 0; }
738 EOF
739-if { (eval echo configure:1424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
740+if { (eval echo configure:1498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
741   rm -rf conftest*
742   eval "ac_cv_lib_$ac_lib_var=yes"
743 else
744@@ -1444,12 +1518,12 @@
745
746     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
747     echo $ac_n "checking for shmat""... $ac_c" 1>&6
748-echo "configure:1448: checking for shmat" >&5
749+echo "configure:1522: checking for shmat" >&5
750 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
751   echo $ac_n "(cached) $ac_c" 1>&6
752 else
753   cat > conftest.$ac_ext <<EOF
754-#line 1453 "configure"
755+#line 1527 "configure"
756 #include "confdefs.h"
757 /* System header to define __stub macros and hopefully few prototypes,
758     which can conflict with char shmat(); below.  */
759@@ -1472,7 +1546,7 @@
760
761 ; return 0; }
762 EOF
763-if { (eval echo configure:1476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
764+if { (eval echo configure:1550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
765   rm -rf conftest*
766   eval "ac_cv_func_shmat=yes"
767 else
768@@ -1493,7 +1567,7 @@
769
770     if test $ac_cv_func_shmat = no; then
771       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
772-echo "configure:1497: checking for shmat in -lipc" >&5
773+echo "configure:1571: checking for shmat in -lipc" >&5
774 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
775 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
776   echo $ac_n "(cached) $ac_c" 1>&6
777@@ -1501,7 +1575,7 @@
778   ac_save_LIBS="$LIBS"
779 LIBS="-lipc  $LIBS"
780 cat > conftest.$ac_ext <<EOF
781-#line 1505 "configure"
782+#line 1579 "configure"
783 #include "confdefs.h"
784 /* Override any gcc2 internal prototype to avoid an error.  */
785 /* We use char because int might match the return type of a gcc2
786@@ -1512,7 +1586,7 @@
787 shmat()
788 ; return 0; }
789 EOF
790-if { (eval echo configure:1516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
791+if { (eval echo configure:1590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
792   rm -rf conftest*
793   eval "ac_cv_lib_$ac_lib_var=yes"
794 else
795@@ -1545,15 +1619,15 @@
796   # libraries we check for below, so use a different variable.
797   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
798   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
799-echo "configure:1549: checking for IceConnectionNumber in -lICE" >&5
800+echo "configure:1623: checking for IceConnectionNumber in -lICE" >&5
801 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
802 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
803   echo $ac_n "(cached) $ac_c" 1>&6
804 else
805   ac_save_LIBS="$LIBS"
806-LIBS="-lICE  $LIBS"
807+LIBS="-lICE $X_EXTRA_LIBS $LIBS"
808 cat > conftest.$ac_ext <<EOF
809-#line 1557 "configure"
810+#line 1631 "configure"
811 #include "confdefs.h"
812 /* Override any gcc2 internal prototype to avoid an error.  */
813 /* We use char because int might match the return type of a gcc2
814@@ -1564,7 +1638,7 @@
815 IceConnectionNumber()
816 ; return 0; }
817 EOF
818-if { (eval echo configure:1568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
819+if { (eval echo configure:1642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
820   rm -rf conftest*
821   eval "ac_cv_lib_$ac_lib_var=yes"
822 else
823@@ -1589,12 +1663,12 @@
824 fi
825
826 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
827-echo "configure:1593: checking for ANSI C header files" >&5
828+echo "configure:1667: checking for ANSI C header files" >&5
829 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
830   echo $ac_n "(cached) $ac_c" 1>&6
831 else
832   cat > conftest.$ac_ext <<EOF
833-#line 1598 "configure"
834+#line 1672 "configure"
835 #include "confdefs.h"
836 #include <stdlib.h>
837 #include <stdarg.h>
838@@ -1602,8 +1676,8 @@
839 #include <float.h>
840 EOF
841 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
842-{ (eval echo configure:1606: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
843-ac_err=`grep -v '^ *+' conftest.out`
844+{ (eval echo configure:1680: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
845+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
846 if test -z "$ac_err"; then
847   rm -rf conftest*
848   ac_cv_header_stdc=yes
849@@ -1619,7 +1693,7 @@
850 if test $ac_cv_header_stdc = yes; then
851   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
852 cat > conftest.$ac_ext <<EOF
853-#line 1623 "configure"
854+#line 1697 "configure"
855 #include "confdefs.h"
856 #include <string.h>
857 EOF
858@@ -1637,7 +1711,7 @@
859 if test $ac_cv_header_stdc = yes; then
860   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
861 cat > conftest.$ac_ext <<EOF
862-#line 1641 "configure"
863+#line 1715 "configure"
864 #include "confdefs.h"
865 #include <stdlib.h>
866 EOF
867@@ -1658,7 +1732,7 @@
868   :
869 else
870   cat > conftest.$ac_ext <<EOF
871-#line 1662 "configure"
872+#line 1736 "configure"
873 #include "confdefs.h"
874 #include <ctype.h>
875 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
876@@ -1669,7 +1743,7 @@
877 exit (0); }
878
879 EOF
880-if { (eval echo configure:1673: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
881+if { (eval echo configure:1747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
882 then
883   :
884 else
885@@ -1696,18 +1770,18 @@
886 do
887 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
888 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
889-echo "configure:1700: checking for $ac_hdr" >&5
890+echo "configure:1774: checking for $ac_hdr" >&5
891 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
892   echo $ac_n "(cached) $ac_c" 1>&6
893 else
894   cat > conftest.$ac_ext <<EOF
895-#line 1705 "configure"
896+#line 1779 "configure"
897 #include "confdefs.h"
898 #include <$ac_hdr>
899 EOF
900 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
901-{ (eval echo configure:1710: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
902-ac_err=`grep -v '^ *+' conftest.out`
903+{ (eval echo configure:1784: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
904+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
905 if test -z "$ac_err"; then
906   rm -rf conftest*
907   eval "ac_cv_header_$ac_safe=yes"
908@@ -1734,7 +1808,7 @@
909
910
911 echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
912-echo "configure:1738: checking for main in -lm" >&5
913+echo "configure:1812: checking for main in -lm" >&5
914 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
915 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
916   echo $ac_n "(cached) $ac_c" 1>&6
917@@ -1742,14 +1816,14 @@
918   ac_save_LIBS="$LIBS"
919 LIBS="-lm  $LIBS"
920 cat > conftest.$ac_ext <<EOF
921-#line 1746 "configure"
922+#line 1820 "configure"
923 #include "confdefs.h"
924
925 int main() {
926 main()
927 ; return 0; }
928 EOF
929-if { (eval echo configure:1753: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
930+if { (eval echo configure:1827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
931   rm -rf conftest*
932   eval "ac_cv_lib_$ac_lib_var=yes"
933 else
934@@ -1777,7 +1851,7 @@
935 fi
936
937 echo $ac_n "checking for main in -lz""... $ac_c" 1>&6
938-echo "configure:1781: checking for main in -lz" >&5
939+echo "configure:1855: checking for main in -lz" >&5
940 ac_lib_var=`echo z'_'main | sed 'y%./+-%__p_%'`
941 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
942   echo $ac_n "(cached) $ac_c" 1>&6
943@@ -1785,14 +1859,14 @@
944   ac_save_LIBS="$LIBS"
945 LIBS="-lz  $LIBS"
946 cat > conftest.$ac_ext <<EOF
947-#line 1789 "configure"
948+#line 1863 "configure"
949 #include "confdefs.h"
950
951 int main() {
952 main()
953 ; return 0; }
954 EOF
955-if { (eval echo configure:1796: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
956+if { (eval echo configure:1870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
957   rm -rf conftest*
958   eval "ac_cv_lib_$ac_lib_var=yes"
959 else
960@@ -1819,8 +1893,51 @@
961   echo "$ac_t""no" 1>&6
962 fi
963
964+echo $ac_n "checking for main in -lpng""... $ac_c" 1>&6
965+echo "configure:1898: checking for main in -lpng" >&5
966+ac_lib_var=`echo png'_'main | sed 'y%./+-%__p_%'`
967+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
968+  echo $ac_n "(cached) $ac_c" 1>&6
969+else
970+  ac_save_LIBS="$LIBS"
971+LIBS="-lpng  $LIBS"
972+cat > conftest.$ac_ext <<EOF
973+#line 1906 "configure"
974+#include "confdefs.h"
975+
976+int main() {
977+main()
978+; return 0; }
979+EOF
980+if { (eval echo configure:1913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
981+  rm -rf conftest*
982+  eval "ac_cv_lib_$ac_lib_var=yes"
983+else
984+  echo "configure: failed program was:" >&5
985+  cat conftest.$ac_ext >&5
986+  rm -rf conftest*
987+  eval "ac_cv_lib_$ac_lib_var=no"
988+fi
989+rm -f conftest*
990+LIBS="$ac_save_LIBS"
991+
992+fi
993+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
994+  echo "$ac_t""yes" 1>&6
995+    ac_tr_lib=HAVE_LIB`echo png | sed -e 's/[^a-zA-Z0-9_]/_/g' \
996+    -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
997+  cat >> confdefs.h <<EOF
998+#define $ac_tr_lib 1
999+EOF
1000+
1001+  LIBS="-lpng $LIBS"
1002+
1003+else
1004+  echo "$ac_t""no" 1>&6
1005+fi
1006+
1007 echo $ac_n "checking for main in -ljpeg""... $ac_c" 1>&6
1008-echo "configure:1824: checking for main in -ljpeg" >&5
1009+echo "configure:1941: checking for main in -ljpeg" >&5
1010 ac_lib_var=`echo jpeg'_'main | sed 'y%./+-%__p_%'`
1011 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1012   echo $ac_n "(cached) $ac_c" 1>&6
1013@@ -1828,14 +1945,14 @@
1014   ac_save_LIBS="$LIBS"
1015 LIBS="-ljpeg  $LIBS"
1016 cat > conftest.$ac_ext <<EOF
1017-#line 1832 "configure"
1018+#line 1949 "configure"
1019 #include "confdefs.h"
1020
1021 int main() {
1022 main()
1023 ; return 0; }
1024 EOF
1025-if { (eval echo configure:1839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1026+if { (eval echo configure:1956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
1027   rm -rf conftest*
1028   eval "ac_cv_lib_$ac_lib_var=yes"
1029 else
1030@@ -1863,7 +1980,7 @@
1031 fi
1032
1033 echo $ac_n "checking for main in -ltiff""... $ac_c" 1>&6
1034-echo "configure:1867: checking for main in -ltiff" >&5
1035+echo "configure:1984: checking for main in -ltiff" >&5
1036 ac_lib_var=`echo tiff'_'main | sed 'y%./+-%__p_%'`
1037 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1038   echo $ac_n "(cached) $ac_c" 1>&6
1039@@ -1871,14 +1988,14 @@
1040   ac_save_LIBS="$LIBS"
1041 LIBS="-ltiff  $LIBS"
1042 cat > conftest.$ac_ext <<EOF
1043-#line 1875 "configure"
1044+#line 1992 "configure"
1045 #include "confdefs.h"
1046
1047 int main() {
1048 main()
1049 ; return 0; }
1050 EOF
1051-if { (eval echo configure:1882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1052+if { (eval echo configure:1999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
1053   rm -rf conftest*
1054   eval "ac_cv_lib_$ac_lib_var=yes"
1055 else
1056@@ -1909,12 +2026,12 @@
1057
1058
1059 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
1060-echo "configure:1913: checking return type of signal handlers" >&5
1061+echo "configure:2030: checking return type of signal handlers" >&5
1062 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
1063   echo $ac_n "(cached) $ac_c" 1>&6
1064 else
1065   cat > conftest.$ac_ext <<EOF
1066-#line 1918 "configure"
1067+#line 2035 "configure"
1068 #include "confdefs.h"
1069 #include <sys/types.h>
1070 #include <signal.h>
1071@@ -1931,7 +2048,7 @@
1072 int i;
1073 ; return 0; }
1074 EOF
1075-if { (eval echo configure:1935: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1076+if { (eval echo configure:2052: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
1077   rm -rf conftest*
1078   ac_cv_type_signal=void
1079 else
1080@@ -1952,12 +2069,12 @@
1081 for ac_func in mkdir select
1082 do
1083 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
1084-echo "configure:1956: checking for $ac_func" >&5
1085+echo "configure:2073: checking for $ac_func" >&5
1086 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
1087   echo $ac_n "(cached) $ac_c" 1>&6
1088 else
1089   cat > conftest.$ac_ext <<EOF
1090-#line 1961 "configure"
1091+#line 2078 "configure"
1092 #include "confdefs.h"
1093 /* System header to define __stub macros and hopefully few prototypes,
1094     which can conflict with char $ac_func(); below.  */
1095@@ -1980,7 +2097,7 @@
1096
1097 ; return 0; }
1098 EOF
1099-if { (eval echo configure:1984: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
1100+if { (eval echo configure:2101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
1101   rm -rf conftest*
1102   eval "ac_cv_func_$ac_func=yes"
1103 else
1104@@ -2028,7 +2145,7 @@
1105 # Ultrix sh set writes to stderr and can't be redirected directly,
1106 # and sets the high bit in the cache file unless we assign to the vars.
1107 (set) 2>&1 |
1108-  case `(ac_space=' '; set) 2>&1` in
1109+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
1110   *ac_space=\ *)
1111     # `set' does not quote correctly, so add quotes (double-quote substitution
1112     # turns \\\\ into \\, and sed turns \\ into \).
1113@@ -2095,7 +2212,7 @@
1114     echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
1115     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
1116   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
1117-    echo "$CONFIG_STATUS generated by autoconf version 2.12"
1118+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
1119     exit 0 ;;
1120   -help | --help | --hel | --he | --h)
1121     echo "\$ac_cs_usage"; exit 0 ;;
1122@@ -2114,9 +2231,11 @@
1123  s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
1124 $ac_vpsub
1125 $extrasub
1126+s%@SHELL@%$SHELL%g
1127 s%@CFLAGS@%$CFLAGS%g
1128 s%@CPPFLAGS@%$CPPFLAGS%g
1129 s%@CXXFLAGS@%$CXXFLAGS%g
1130+s%@FFLAGS@%$FFLAGS%g
1131 s%@DEFS@%$DEFS%g
1132 s%@LDFLAGS@%$LDFLAGS%g
1133 s%@LIBS@%$LIBS%g
1134diff -urNad xloadimage-4.1~/configure.in xloadimage-4.1/configure.in
1135--- xloadimage-4.1~/configure.in	2005-12-06 02:59:07.000000000 +0000
1136+++ xloadimage-4.1/configure.in	2005-12-06 02:59:07.000000000 +0000
1137@@ -15,6 +15,8 @@
1138 AC_CHECK_LIB(m, main)
1139 dnl Replace `main' with a function in -lz:
1140 AC_CHECK_LIB(z, main)
1141+dnl Replace `main' with a function in -lpng:
1142+AC_CHECK_LIB(png, main)
1143 dnl Replace `main' with a function in -ljpeg:
1144 AC_CHECK_LIB(jpeg, main)
1145 dnl Replace `main' with a function in -ltiff:
1146@@ -25,6 +27,6 @@
1147
1148 dnl Checks for library functions.
1149 AC_TYPE_SIGNAL
1150-AC_CHECK_FUNCS(mkdir select)
1151+AC_CHECK_FUNCS(select)
1152
1153 AC_OUTPUT(Makefile)
1154diff -urNad xloadimage-4.1~/image.h xloadimage-4.1/image.h
1155--- xloadimage-4.1~/image.h	2005-12-06 02:59:07.000000000 +0000
1156+++ xloadimage-4.1/image.h	2005-12-06 02:59:07.000000000 +0000
1157@@ -18,15 +18,12 @@
1158
1159 /* ANSI-C stuff
1160  */
1161-#if defined(__STDC__)
1162-
1163+#ifdef STDC_HEADERS
1164 #if !defined(_ArgProto)
1165 #define _ArgProto(ARGS) ARGS
1166 #endif
1167-
1168 #include <stdlib.h>
1169-
1170-#else /* !__STDC__ */
1171+#else /* !STDC_HEADERS */
1172
1173 #if !defined(const) /* "const" is an ANSI thing */
1174 #define const
1175@@ -35,26 +32,14 @@
1176 #define _ArgProto(ARGS) ()
1177 #endif
1178
1179-#endif /* !__STDC__ */
1180+#endif /* !STDC_HEADERS */
1181
1182 /* handle strings stuff that varies between BSD and ANSI/SYSV
1183  */
1184-#if defined(IS_BSD) && !defined(__STDC__)
1185-#include <strings.h>
1186-#if !defined(strchr) && !defined(index)
1187-#define strchr index
1188-#endif
1189-#if !defined(strrchr) && !defined(rindex)
1190-#define strrchr rindex
1191-#endif
1192-#if !defined(memcpy) && !defined(bcopy)
1193-#define memcpy(D,S,L) bcopy((char *)(S),(char *)(D),(L))
1194-#endif
1195-#if !defined(memset) && !defined(bzero)
1196-/* #define memset(D,V,L) bzero(D,L) */
1197-#endif
1198-#else /* !IS_BSD || __STDC__ */
1199 #include <string.h>
1200+#ifdef HAVE_STRINGS_H
1201+#include <strings.h>
1202+#else /* !HAVE_STRINGS_H */
1203 #if !defined(index) && !defined(strchr)
1204 #define index strchr
1205 #endif
1206@@ -67,7 +52,7 @@
1207 #if !defined(bzero) && !defined(memset)
1208 #define bzero(D,L) memset((void *)(D),0,(L))
1209 #endif
1210-#endif /* !IS_BSD || __STDC__ */
1211+#endif /* !HAVE_STRINGS_H */
1212
1213 #ifdef VMS
1214 #define R_OK 4
1215@@ -234,7 +219,7 @@
1216 Image *normalize _ArgProto((Image *image, unsigned int verbose));
1217
1218 /* compress.c */
1219-void compress _ArgProto((Image *image, unsigned int verbose));
1220+void compress_cmap _ArgProto((Image *image, unsigned int verbose));
1221
1222 /* dither.c */
1223 Image *dither _ArgProto((Image *image, unsigned int verbose));
1224diff -urNad xloadimage-4.1~/imagetypes.h xloadimage-4.1/imagetypes.h
1225--- xloadimage-4.1~/imagetypes.h	2005-12-06 02:59:07.000000000 +0000
1226+++ xloadimage-4.1/imagetypes.h	2005-12-06 02:59:07.000000000 +0000
1227@@ -34,6 +34,9 @@
1228 #ifdef HAVE_LIBTIFF
1229 Image *tiffLoad();
1230 #endif
1231+#ifdef HAVE_LIBPNG
1232+Image *pngLoad();
1233+#endif
1234
1235 int niffIdent();
1236 int facesIdent();
1237@@ -62,6 +65,9 @@
1238 #ifdef HAVE_LIBTIFF
1239 int tiffIdent();
1240 #endif
1241+#ifdef HAVE_LIBPNG
1242+int pngIdent();
1243+#endif
1244
1245 void niffDump();
1246 #ifdef HAVE_LIBJPEG
1247@@ -91,6 +97,9 @@
1248 #ifdef HAVE_LIBTIFF
1249   tiffIdent,      tiffLoad,      tiffDump,    "tiff",      "TIFF image",
1250 #endif
1251+#ifdef HAVE_LIBPNG
1252+  pngIdent,       pngLoad,       NULL,        "png",       "PNG image",
1253+#endif
1254   fbmIdent,       fbmLoad,       NULL,        "fbm",       "FBM Image",
1255   cmuwmIdent,     cmuwmLoad,     NULL,        "cmuraster", "CMU WM Raster",
1256   pbmIdent,       pbmLoad,       pbmDump,     "pbm",       "Portable Bit Map (PBM, PGM, PPM)",
1257diff -urNad xloadimage-4.1~/new.c xloadimage-4.1/new.c
1258--- xloadimage-4.1~/new.c	2005-12-06 02:59:04.000000000 +0000
1259+++ xloadimage-4.1/new.c	2005-12-06 02:59:07.000000000 +0000
1260@@ -10,6 +10,9 @@
1261
1262 #include "copyright.h"
1263 #include "image.h"
1264+#ifdef HAVE_MALLOC_H
1265+#include <malloc.h>
1266+#endif
1267
1268 extern int _Xdebug;
1269
1270diff -urNad xloadimage-4.1~/niff.c xloadimage-4.1/niff.c
1271--- xloadimage-4.1~/niff.c	2005-12-06 02:59:07.000000000 +0000
1272+++ xloadimage-4.1/niff.c	2005-12-06 02:59:07.000000000 +0000
1273@@ -8,8 +8,10 @@
1274  * this is in the public domain.
1275  */
1276
1277-#include <unistd.h>
1278 #include "image.h"
1279+#ifdef HAVE_UNISTD_H
1280+#include <unistd.h>
1281+#endif
1282 #include "niff.h"
1283
1284 static void babble(name, header, title)
1285diff -urNad xloadimage-4.1~/options.c xloadimage-4.1/options.c
1286--- xloadimage-4.1~/options.c	2005-12-06 02:59:04.000000000 +0000
1287+++ xloadimage-4.1/options.c	2005-12-06 02:59:07.000000000 +0000
1288@@ -731,6 +731,11 @@
1289       if (++a >= argc)
1290 	optionUsage(GAMMA);
1291       newopt->info.gamma= getFloat(GAMMA, argv[a]);
1292+      if (newopt->info.gamma < 0.0) {
1293+	fprintf(stderr, "Argument to %s must be over 0.0 (ignored)\n",
1294+		optionName(GAMMA));
1295+	newopt->type= OPT_IGNORE;
1296+      }
1297       break;
1298
1299     case GOTO:
1300diff -urNad xloadimage-4.1~/png.c xloadimage-4.1/png.c
1301--- xloadimage-4.1~/png.c	1970-01-01 00:00:00.000000000 +0000
1302+++ xloadimage-4.1/png.c	2005-12-06 02:59:07.000000000 +0000
1303@@ -0,0 +1,350 @@
1304+/*
1305+ * PNG - Portable Network Graphics
1306+ *
1307+ * Alpha channle is linear.
1308+ * Color   \   Bit Depth      1   2   4   8  16  palette  bKGD
1309+ * PNG_COLOR_TYPE_PALETTE     O   O   O   O      must      8 bit
1310+ * PNG_COLOR_TYPE_GRAY        O   O   O   O   O           16
1311+ * PNG_COLOR_TYPE_GRAY_ALPHA              O   O           16
1312+ * PNG_COLOR_TYPE_RGB                     O   O  possible 16 * 3
1313+ * PNG_COLOR_TYPE_RGB_ALPHA               O   O  possible 16 * 3
1314+ *
1315+ * This code is based on jpeg.c and sample code from the libpng-1.0.5.
1316+ * 2000/01/10: YOSHIDA Hiroshi
1317+ *
1318+ * TODO:
1319+ * pngLoad(): Alpha channel, Transparency palette.
1320+ * pngDump(): Dump.
1321+ *
1322+ */
1323+
1324+
1325+#include "image.h"	/* xloadimage declarations */
1326+#ifdef HAVE_LIBPNG
1327+#include "options.h"
1328+#include <png.h>
1329+#include <setjmp.h>
1330+
1331+#undef  DEBUG
1332+/* #define  DEBUG */
1333+#undef  debug
1334+
1335+#ifdef DEBUG
1336+# define debug(xx)	fprintf(stderr,xx)
1337+#else
1338+# define debug(xx)
1339+#endif
1340+
1341+#define PNG_BYTES_TO_CHECK 4
1342+
1343+static Image *image;    /* xloadimage image being returned */
1344+static ZFILE *zinput_file;
1345+static char *filename;
1346+
1347+int pngIdent(char *fullname, char *name);
1348+Image *pngLoad(char *fullname, char *name, unsigned int verbose);
1349+/* void pngDump(Image *image, char *options, char *file, int verbose); */
1350+
1351+
1352+/*
1353+ * png read handler
1354+ */
1355+static void png_read_data(png_structp png_ptr,
1356+			  png_bytep data, png_size_t length)
1357+{
1358+  if (zread(zinput_file, data, length) != length)
1359+    png_error(png_ptr, "Read Error");
1360+}
1361+
1362+
1363+/*
1364+ * png warn handler
1365+ */
1366+static void output_warn(png_structp png_ptr, png_const_charp str)
1367+{
1368+  debug(" #warn ");
1369+  fprintf(stderr, " PNG file: %s - %s\n", filename, str);
1370+  fflush(stderr);
1371+}
1372+
1373+
1374+/*
1375+ * png error handler
1376+ */
1377+static void output_error(png_structp png_ptr, png_const_charp str)
1378+{
1379+  debug(" #error ");
1380+  output_warn( png_ptr, str);
1381+  longjmp(png_ptr->jmpbuf, 1);	/* return control to outer routine */
1382+}
1383+
1384+
1385+static const char *pngColor(int color_type)
1386+{
1387+  const char *str;
1388+
1389+  switch (color_type) {
1390+  case PNG_COLOR_TYPE_GRAY:
1391+    str = "GRAY";
1392+    break;
1393+  case PNG_COLOR_TYPE_GRAY_ALPHA:
1394+    str = "GRAY_ALPHA";
1395+    break;
1396+  case PNG_COLOR_TYPE_PALETTE:
1397+    str = "PALETTE";
1398+    break;
1399+  case PNG_COLOR_TYPE_RGB:
1400+    str = "RGB";
1401+    break;
1402+  case PNG_COLOR_TYPE_RGB_ALPHA:
1403+    str = "RGB_ALPHA";
1404+    break;
1405+  default:
1406+    str = "UNKNOWN_COLOR_TYPE";
1407+  }
1408+  return str;
1409+}
1410+
1411+
1412+static const char *pngInterlace(int interlace_type)
1413+{
1414+  const char *str;
1415+
1416+  switch (interlace_type) {
1417+  case PNG_INTERLACE_NONE:
1418+    str = "NONE";
1419+    break;
1420+  case PNG_INTERLACE_ADAM7:
1421+    str = "ADAM7";
1422+    break;
1423+  default:
1424+    str = "UNKNOWN_TYPE";
1425+  }
1426+  return str;
1427+}
1428+
1429+
1430+/*
1431+ * Output PNG file infomation.
1432+ */
1433+static void pngInfo( png_uint_32 width, png_uint_32 height,
1434+		     int bit_depth, int color_type, int interlace_type,
1435+		     double file_gamma)
1436+{
1437+  printf("%s is %ldx%ld PNG image, color type %s, %d bit",
1438+	 filename, width, height, pngColor(color_type), bit_depth);
1439+  if( interlace_type != PNG_INTERLACE_NONE)
1440+    printf(", interlace %s", pngInterlace(interlace_type));
1441+  if( file_gamma >= 0.0)
1442+    printf(", file gamma %.4f", file_gamma);
1443+  putchar('\n');
1444+}
1445+
1446+
1447+/*
1448+ * pngIdent(), pngLoad()
1449+ * Read PNG header & allocate png's struct:
1450+ * return 1: success
1451+ */
1452+static int pngHeader(png_structpp png_pp,
1453+		     png_infopp info_pp, png_infopp end_pp)
1454+{
1455+  *info_pp = *end_pp = NULL;
1456+  *png_pp = png_create_read_struct(PNG_LIBPNG_VER_STRING,
1457+				   NULL, output_error, output_warn);
1458+  if (!*png_pp)
1459+    return 0;
1460+  *info_pp = png_create_info_struct(*png_pp);
1461+  if (!*info_pp) {
1462+    png_destroy_read_struct(png_pp, info_pp, end_pp);
1463+    return 0;
1464+  }
1465+  *end_pp = png_create_info_struct(*png_pp);
1466+  if (!*end_pp) {
1467+    png_destroy_read_struct(png_pp, info_pp, end_pp);
1468+    return 0;
1469+  }
1470+  if (setjmp((*png_pp)->jmpbuf)) {
1471+    /* On error */
1472+    png_destroy_read_struct(png_pp, info_pp, end_pp);
1473+    return 0;
1474+  }
1475+  png_set_sig_bytes(*png_pp, PNG_BYTES_TO_CHECK);
1476+  png_set_read_fn(*png_pp, NULL, png_read_data);
1477+  png_read_info(*png_pp, *info_pp);
1478+
1479+  return 1;
1480+}
1481+
1482+
1483+/*
1484+ * return !0: It is a PNG.
1485+ */
1486+static int is_png(ZFILE *zf)
1487+{
1488+  byte png_read_buff[PNG_BYTES_TO_CHECK];
1489+
1490+  /* Read in some of the signature bytes */
1491+  if (zread(zf, png_read_buff,PNG_BYTES_TO_CHECK) != PNG_BYTES_TO_CHECK)
1492+    return 0;
1493+  return !png_sig_cmp(png_read_buff, (png_size_t)0, PNG_BYTES_TO_CHECK);
1494+}
1495+
1496+
1497+/*
1498+ * Main control routine for identifying PNG without loading
1499+ * return 1: PNG file.
1500+ */
1501+int pngIdent(char *fullname, char *name)
1502+{
1503+  png_structp png_ptr;
1504+  png_infop info_ptr, end_info;
1505+  png_uint_32 width, height;
1506+  int color_type, bit_depth, interlace_type;
1507+  double file_gamma;
1508+
1509+  zinput_file = zopen(fullname);
1510+  if (zinput_file == NULL) {
1511+    zclose(zinput_file);
1512+    return 0;
1513+  }
1514+  /* check at early timing */
1515+  if (is_png(zinput_file) == 0) {
1516+    zclose(zinput_file);
1517+    return 0;
1518+  }
1519+  filename = name;
1520+
1521+  /* read infomation header */
1522+  if (!pngHeader(&png_ptr, &info_ptr, &end_info)) {
1523+    zclose(zinput_file);
1524+    return 0;
1525+  }
1526+  if (setjmp(png_ptr->jmpbuf)) {
1527+    /* On error */
1528+    freeImage(image);
1529+    png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1530+    zclose(zinput_file);
1531+    return 0;
1532+  }
1533+  png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
1534+	       &color_type, &interlace_type, NULL, NULL);
1535+  if(!png_get_gAMA( png_ptr, info_ptr, &file_gamma))
1536+    file_gamma = -1.0;
1537+  /* print out PNG infomation */
1538+  pngInfo( width, height, bit_depth, color_type, interlace_type, file_gamma);
1539+
1540+  znocache(zinput_file);
1541+  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1542+  zclose(zinput_file);
1543+  return 1;
1544+}
1545+
1546+
1547+/*
1548+ * Main control routine for loading
1549+ */
1550+Image *pngLoad(char *fullname, char *name, unsigned int verbose)
1551+{
1552+  png_structp png_ptr;
1553+  png_infop info_ptr, end_info;
1554+  png_colorp palette;
1555+  png_color_16p background;
1556+  png_bytep bufp, *row_pointers;
1557+  png_uint_32 width, height;
1558+  int i, row_stride, color_type, bit_depth, num_palette, interlace_type;
1559+  double file_gamma;
1560+
1561+  zinput_file = zopen(fullname);
1562+  if (zinput_file == NULL) {
1563+    zclose(zinput_file);
1564+    return NULL;
1565+  }
1566+  /* check at early timing */
1567+  if (is_png(zinput_file) == 0) {
1568+    zclose(zinput_file);
1569+    return NULL;
1570+  }
1571+  filename = name;
1572+
1573+  /* read infomation header */
1574+  if (!pngHeader(&png_ptr, &info_ptr, &end_info)) {
1575+    zclose(zinput_file);
1576+    return NULL;
1577+  }
1578+  png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
1579+	       &color_type, &interlace_type, NULL, NULL);
1580+  if(!png_get_gAMA( png_ptr, info_ptr, &file_gamma))
1581+    file_gamma = -1.0;
1582+  /* print out PNG infomation */
1583+  if (verbose)
1584+    pngInfo( width, height, bit_depth, color_type, interlace_type, file_gamma);
1585+  znocache(zinput_file);
1586+  image = NULL;
1587+
1588+  if (file_gamma <= 0.0)
1589+    file_gamma = 1.0;
1590+  png_set_gamma(png_ptr, 1.0, file_gamma);
1591+  if (bit_depth > 8)
1592+    png_set_strip_16(png_ptr);      /* 16 bit -> 8 bit */
1593+  /*  if (color_type & PNG_COLOR_MASK_ALPHA) */
1594+  png_set_strip_alpha(png_ptr);
1595+  if (png_get_bKGD(png_ptr, info_ptr, &background))
1596+    png_set_background(png_ptr, background, file_gamma, 1, 1.0);
1597+  switch (color_type) {
1598+  case PNG_COLOR_TYPE_PALETTE:
1599+    if (bit_depth < 8)
1600+      png_set_packing(png_ptr);     /* 1 pixlel 1 byte */
1601+    image = newRGBImage(width, height, 8);
1602+    png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
1603+    image->rgb.used = num_palette;
1604+    for (i = 0; i < num_palette; i++) {
1605+      *(image->rgb.red + i) = palette->red << 8;
1606+      *(image->rgb.green + i) = palette->green << 8;
1607+      *(image->rgb.blue + i) = palette->blue << 8;
1608+      palette++;
1609+    }
1610+    break;
1611+  case PNG_COLOR_TYPE_GRAY_ALPHA:
1612+  case PNG_COLOR_TYPE_GRAY:
1613+    if (bit_depth < 8)
1614+      png_set_gray_1_2_4_to_8(png_ptr);  /* 1 pixlel 1 byte */
1615+    image = newRGBImage(width, height, 8);
1616+    image->rgb.used = 256;
1617+    for (i = 0; i < 256; i++) {
1618+      *(image->rgb.red + i) =
1619+	*(image->rgb.green + i) =
1620+	*(image->rgb.blue + i) = i << 8;
1621+    }
1622+    break;
1623+  case PNG_COLOR_TYPE_RGB_ALPHA:
1624+  case PNG_COLOR_TYPE_RGB:
1625+    image = newTrueImage(width, height);
1626+    break;
1627+  default:
1628+    fprintf(stderr, "Unknown color type PNG.");
1629+    png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1630+    zclose(zinput_file);
1631+    return NULL;
1632+  }
1633+  image->title = dupString(filename);
1634+
1635+  bufp = image->data;
1636+  png_read_update_info(png_ptr, info_ptr);
1637+  row_stride = png_get_rowbytes(png_ptr, info_ptr);
1638+  row_pointers = (png_bytep *)lmalloc(sizeof(png_bytep) * height);
1639+  for (i = 0; i < height; i++) {
1640+    *(row_pointers + i) = bufp;
1641+    bufp += row_stride;
1642+  }
1643+  png_read_image(png_ptr, row_pointers);
1644+  lfree((byte *)row_pointers);
1645+  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
1646+  zclose(zinput_file);
1647+
1648+  return image;
1649+}
1650+
1651+#else /* !HAVE_LIBPNG */
1652+static int unused;
1653+#endif /* !HAVE_LIBPNG */
1654diff -urNad xloadimage-4.1~/send.c xloadimage-4.1/send.c
1655--- xloadimage-4.1~/send.c	2005-12-06 02:59:04.000000000 +0000
1656+++ xloadimage-4.1/send.c	2005-12-06 02:59:07.000000000 +0000
1657@@ -255,7 +255,7 @@
1658
1659   default:
1660   retry: /* this tag is used when retrying because we couldn't get a fit */
1661-    compress(image, verbose);
1662+    compress_cmap(image, verbose);
1663
1664     index= (Pixel *)lmalloc(sizeof(Pixel) * image->rgb.used);
1665
1666diff -urNad xloadimage-4.1~/vff.c xloadimage-4.1/vff.c
1667--- xloadimage-4.1~/vff.c	2005-12-06 02:59:07.000000000 +0000
1668+++ xloadimage-4.1/vff.c	2005-12-06 02:59:07.000000000 +0000
1669@@ -150,7 +150,7 @@
1670 	  op = image->data;
1671 	  skip = bands - 3;
1672 	  linewidth = bands * width;
1673-	  buf = (unsigned char *)malloc((unsigned)linewidth);
1674+	  buf = (unsigned char *)lmalloc((unsigned)linewidth);
1675 	  if (buf == NULL) {
1676 	       memoryExhausted();
1677 	  }
1678@@ -337,7 +337,7 @@
1679 		    return(0);
1680 	       }
1681
1682-	       if ((header[lines] = (char *)malloc((unsigned)count+1)) == NULL) {
1683+	       if ((header[lines] = (char *)lmalloc((unsigned)count+1)) == NULL) {
1684 		    memoryExhausted();
1685 	       }
1686 	       bcopy(buf, header[lines], count);
1687diff -urNad xloadimage-4.1~/vicar.c xloadimage-4.1/vicar.c
1688--- xloadimage-4.1~/vicar.c	2005-12-06 02:59:04.000000000 +0000
1689+++ xloadimage-4.1/vicar.c	2005-12-06 02:59:07.000000000 +0000
1690@@ -12,7 +12,6 @@
1691 #define SAMPLES   label[6]
1692
1693 #include <stdio.h>
1694-#include <malloc.h>
1695 #include "image.h"
1696 #include <sys/types.h>
1697
1698diff -urNad xloadimage-4.1~/window.c xloadimage-4.1/window.c
1699--- xloadimage-4.1~/window.c	2005-12-06 02:59:07.000000000 +0000
1700+++ xloadimage-4.1/window.c	2005-12-06 02:59:07.000000000 +0000
1701@@ -15,23 +15,21 @@
1702 #include <X11/Xatom.h>
1703 #include <signal.h>
1704 #include <errno.h>
1705+#ifdef HAVE_UNISTD_H
1706+#include <unistd.h>
1707+#endif
1708+#ifdef HAVE_SYS_TIME_H
1709 #include <sys/time.h>
1710+#endif
1711+#ifdef HAVE_SELECT
1712+#define ENABLE_TIMEOUT
1713+#include <sys/select.h>
1714+#else /* !HAVE_SELECT */
1715 #ifdef HAS_POLL
1716 #include <poll.h>
1717-#else /* !HAS_POLL */
1718-#ifdef HAS_SELECT_INCLUDE
1719-#include <sys/select.h>
1720-#endif /* HAS_SELECT_INCLUDE */
1721-#endif /* !HAS_POLL */
1722-
1723-/* we can use timeouts if either select() or poll() are available.
1724- */
1725-#if IS_BSD
1726 #define ENABLE_TIMEOUT
1727-#endif
1728-#if defined(HAS_SELECT_INCLUDE) || defined(HAS_POLL)
1729-#define ENABLE_TIMEOUT
1730-#endif
1731+#endif /* !HAS_POLL */
1732+#endif /* !HAVE_SELECT */
1733
1734 /* SUPPRESS 560 */
1735
1736diff -urNad xloadimage-4.1~/xloadimage.c xloadimage-4.1/xloadimage.c
1737--- xloadimage-4.1~/xloadimage.c	2005-12-06 02:59:07.000000000 +0000
1738+++ xloadimage-4.1/xloadimage.c	2005-12-06 02:59:07.000000000 +0000
1739@@ -16,6 +16,9 @@
1740 #else
1741 #include "patchlevel"
1742 #endif
1743+#ifdef HAVE_UNISTD_H
1744+#include <unistd.h>
1745+#endif
1746 #include <signal.h>
1747
1748 char *ProgramName= "xloadimage";
1749diff -urNad xloadimage-4.1~/xloadimagerc xloadimage-4.1/xloadimagerc
1750--- xloadimage-4.1~/xloadimagerc	2005-12-06 02:59:04.000000000 +0000
1751+++ xloadimage-4.1/xloadimagerc	2005-12-06 03:11:46.000000000 +0000
1752@@ -14,6 +14,7 @@
1753             .pbm .pgm .ppm    # PBMPLUS
1754             .img              # GEM IMG
1755             .pcx              # PCX image
1756+            .png              # PNG image
1757
1758 # add uufilter for automatic uudecoding of files ending in .uu or .uue
1759 filter = "uufilter -s" .uu .uue
1760