Anonymous avatar Anonymous committed 2399023

- sync to 2.0.9

Comments (0)

Files changed (41)

 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
 LDFLAGS = @LDFLAGS@
+LIBICONV = @LIBICONV@
 LIBOBJS = @LIBOBJS@
 LIBPNG_CONFIG = @LIBPNG_CONFIG@
 LIBS = @LIBS@
 # This is just to silence aclocal about the macro not being used
 ifelse([AC_DISABLE_FAST_INSTALL])
 
+#serial AM2
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV],
+[
+  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+  dnl those with the standalone portable GNU libiconv installed).
+
+  AC_ARG_WITH([libiconv-prefix],
+[  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
+    for dir in `echo "$withval" | tr : ' '`; do
+      if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
+      if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
+    done
+   ])
+
+  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
+    am_cv_func_iconv="no, consider installing GNU libiconv"
+    am_cv_lib_iconv=no
+    AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+      [iconv_t cd = iconv_open("","");
+       iconv(cd,NULL,NULL,NULL,NULL);
+       iconv_close(cd);],
+      am_cv_func_iconv=yes)
+    if test "$am_cv_func_iconv" != yes; then
+      am_save_LIBS="$LIBS"
+      LIBS="$LIBS -liconv"
+      AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+        [iconv_t cd = iconv_open("","");
+         iconv(cd,NULL,NULL,NULL,NULL);
+         iconv_close(cd);],
+        am_cv_lib_iconv=yes
+        am_cv_func_iconv=yes)
+      LIBS="$am_save_LIBS"
+    fi
+  ])
+  if test "$am_cv_func_iconv" = yes; then
+    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+    AC_MSG_CHECKING([for iconv declaration])
+    AC_CACHE_VAL(am_cv_proto_iconv, [
+      AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
+      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+    AC_MSG_RESULT([$]{ac_t:-
+         }[$]am_cv_proto_iconv)
+    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
+      [Define as const if the declaration of iconv() needs const.])
+  fi
+  LIBICONV=
+  if test "$am_cv_lib_iconv" = yes; then
+    LIBICONV="-liconv"
+  fi
+  AC_SUBST(LIBICONV)
+])
+
 	existing JPEG images. Type annotate -h for instructions. 
 	Thanks to Joel Dubiner for supporting this work. -TBB */
 
-enum {
-	left, center, right
+enum
+{
+  left, center, right
 };
 
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
-	gdImagePtr im;
-	char *iin, *iout;
-	FILE *in, *out;
-	char s[1024];
-	int bounds[8];
-	int lines = 1;
-	int color = gdTrueColor(0, 0, 0);
-	char font[1024];
-	int size = 12;
-	int align = left;
-	int x = 0, y = 0;
-	char *fontError;
-	strcpy(font, "times");	
-	if (argc != 3) {
-		fprintf(stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
-		fprintf(stderr, "Standard input should consist of\n");
-		fprintf(stderr, "lines in the following formats:\n");
-		fprintf(stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
-		fprintf(stderr, "font fontname\n");
-		fprintf(stderr, "size pointsize\n");
-		fprintf(stderr, "align (left|right|center)\n");
-		fprintf(stderr, "move x y\n");
-		fprintf(stderr, "text actual-output-text\n\n");
-		fprintf(stderr, "If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
-		fprintf(stderr, "location specified in the GDFONTPATH environment variable, 'font paris' is\n");
-		fprintf(stderr, "sufficient. You may also specify the full, rooted path of a font file.\n");
-		exit(1);
-	}
-	iin = argv[1];
-	iout = argv[2];
-	in = fopen(iin, "rb");
-	if (!in) {
-		fprintf(stderr, "Couldn't open %s\n", iin);
-		exit(2);
-	}
+  gdImagePtr im;
+  char *iin, *iout;
+  FILE *in, *out;
+  char s[1024];
+  int bounds[8];
+  int lines = 1;
+  int color = gdTrueColor (0, 0, 0);
+  char font[1024];
+  int size = 12;
+  int align = left;
+  int x = 0, y = 0;
+  char *fontError;
+  strcpy (font, "times");
+  if (argc != 3)
+    {
+      fprintf (stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
+      fprintf (stderr, "Standard input should consist of\n");
+      fprintf (stderr, "lines in the following formats:\n");
+      fprintf (stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
+      fprintf (stderr, "font fontname\n");
+      fprintf (stderr, "size pointsize\n");
+      fprintf (stderr, "align (left|right|center)\n");
+      fprintf (stderr, "move x y\n");
+      fprintf (stderr, "text actual-output-text\n\n");
+      fprintf (stderr,
+	       "If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
+      fprintf (stderr,
+	       "location specified in the GDFONTPATH environment variable, 'font paris' is\n");
+      fprintf (stderr,
+	       "sufficient. You may also specify the full, rooted path of a font file.\n");
+      exit (1);
+    }
+  iin = argv[1];
+  iout = argv[2];
+  in = fopen (iin, "rb");
+  if (!in)
+    {
+      fprintf (stderr, "Couldn't open %s\n", iin);
+      exit (2);
+    }
 #ifdef HAVE_LIBJPEG
-	im = gdImageCreateFromJpeg(in);
+  im = gdImageCreateFromJpeg (in);
 #else
-	fprintf(stderr, "No JPEG library support available.\n");
+  fprintf (stderr, "No JPEG library support available.\n");
 #endif
-	fclose(in);
-	if (!im) {
-		fprintf(stderr, "%s did not load properly\n", iin);
-		exit(3);
+  fclose (in);
+  if (!im)
+    {
+      fprintf (stderr, "%s did not load properly\n", iin);
+      exit (3);
+    }
+  while (fgets (s, sizeof (s), stdin))
+    {
+      char *st;
+      char *text;
+      st = strtok (s, " \t\r\n");
+      if (!st)
+	{
+	  /* Be nice about blank lines */
+	  continue;
+	}
+      if (!strcmp (st, "font"))
+	{
+	  char *st = strtok (0, " \t\r\n");
+	  if (!st)
+	    {
+	      goto badLine;
+	    }
+	  strcpy (font, st);
+	}
+      else if (!strcmp (st, "align"))
+	{
+	  char *st = strtok (0, " \t\r\n");
+	  if (!st)
+	    {
+	      goto badLine;
+	    }
+	  if (!strcmp (st, "left"))
+	    {
+	      align = 0;
+	    }
+	  else if (!strcmp (st, "center"))
+	    {
+	      align = 1;
+	    }
+	  else if (!strcmp (st, "right"))
+	    {
+	      align = 2;
+	    }
 	}
-	while (fgets(s, sizeof(s), stdin)) {
-		char *st;
-		char *text;
-		st = strtok(s, " \t\r\n");
-		if (!st) {
-			/* Be nice about blank lines */
-			continue;
-		}	
-		if (!strcmp(st, "font")) {
-			char *st = strtok(0, " \t\r\n");
-			if (!st) {
-				goto badLine;
-			}
-			strcpy(font, st);
-		} else if (!strcmp(st, "align")) {
-			char *st = strtok(0, " \t\r\n");
-			if (!st) {
-				goto badLine;
-			}
-			if (!strcmp(st, "left")) {
-				align = 0;
-			} else if (!strcmp(st, "center")) {	
-				align = 1;
-			} else if (!strcmp(st, "right")) {	
-				align = 2;
-			}
-		} else if (!strcmp(st, "size")) {
-			char *st = strtok(0, " \t\r\n");
-			if (!st) {
-				goto badLine;
-			}
-			size = atoi(st);
-		} else if (!strcmp(st, "color")) {
-			char *st = strtok(0, "\r\n");
-			int r, g, b, a = 0;
-			if (!st) {
-				goto badLine;
-			}
-			if (sscanf(st, "%d %d %d %d", &r, &g, &b, &a) < 3) {	 
-				fprintf(stderr, "Bad color at line %d\n", lines);
-				exit(2);	
-			}
-			color = gdTrueColorAlpha(r, g, b, a);
-		} else if (!strcmp(st, "move")) {
-			char *st = strtok(0, "\r\n");
-			if (!st) {
-				goto badLine;
-			}
-			if (sscanf(st, "%d %d", &x, &y) != 2) {	 
-				fprintf(stderr, "Missing coordinates at line %d\n", lines);
-				exit(3);	
-			}
-		} else if (!strcmp(st, "text")) {
-			int rx = x;
-			text = strtok(0, "\r\n");
-			if (!text) {
-				text = "";
-			}
-			gdImageStringFT(0, bounds, color, font,
-				size, 0, x, y, text);
-			switch (align) {
-				case left:
-				break;
-				case center:
-				rx -= (bounds[2] - bounds[0]) / 2;
-				break;
-				case right:
-				rx -= (bounds[2] - bounds[0]);
-				break;
-			}
-			fontError = gdImageStringFT(im, 0, color, font,
-				size, 0, rx, y, text);
-			if (fontError) {
-				fprintf(stderr, "font error at line %d: %s\n", lines, fontError);
-				exit(7);
-			}
-			y -= (bounds[7] - bounds[1]); 	
-		} else {
-			goto badLine;
-		}
-		lines++;	
-		continue;
-badLine:
-		fprintf(stderr, "Bad syntax, line %d\n", lines);
-		exit(4);
-	}		
-	out = fopen(iout, "wb");
-	if (!out) {
-		fprintf(stderr, "Cannot create %s\n", iout);
-		exit(5);
+      else if (!strcmp (st, "size"))
+	{
+	  char *st = strtok (0, " \t\r\n");
+	  if (!st)
+	    {
+	      goto badLine;
+	    }
+	  size = atoi (st);
 	}
+      else if (!strcmp (st, "color"))
+	{
+	  char *st = strtok (0, "\r\n");
+	  int r, g, b, a = 0;
+	  if (!st)
+	    {
+	      goto badLine;
+	    }
+	  if (sscanf (st, "%d %d %d %d", &r, &g, &b, &a) < 3)
+	    {
+	      fprintf (stderr, "Bad color at line %d\n", lines);
+	      exit (2);
+	    }
+	  color = gdTrueColorAlpha (r, g, b, a);
+	}
+      else if (!strcmp (st, "move"))
+	{
+	  char *st = strtok (0, "\r\n");
+	  if (!st)
+	    {
+	      goto badLine;
+	    }
+	  if (sscanf (st, "%d %d", &x, &y) != 2)
+	    {
+	      fprintf (stderr, "Missing coordinates at line %d\n", lines);
+	      exit (3);
+	    }
+	}
+      else if (!strcmp (st, "text"))
+	{
+	  int rx = x;
+	  text = strtok (0, "\r\n");
+	  if (!text)
+	    {
+	      text = "";
+	    }
+	  gdImageStringFT (0, bounds, color, font, size, 0, x, y, text);
+	  switch (align)
+	    {
+	    case left:
+	      break;
+	    case center:
+	      rx -= (bounds[2] - bounds[0]) / 2;
+	      break;
+	    case right:
+	      rx -= (bounds[2] - bounds[0]);
+	      break;
+	    }
+	  fontError = gdImageStringFT (im, 0, color, font,
+				       size, 0, rx, y, text);
+	  if (fontError)
+	    {
+	      fprintf (stderr, "font error at line %d: %s\n", lines,
+		       fontError);
+	      exit (7);
+	    }
+	  y -= (bounds[7] - bounds[1]);
+	}
+      else
+	{
+	  goto badLine;
+	}
+      lines++;
+      continue;
+    badLine:
+      fprintf (stderr, "Bad syntax, line %d\n", lines);
+      exit (4);
+    }
+  out = fopen (iout, "wb");
+  if (!out)
+    {
+      fprintf (stderr, "Cannot create %s\n", iout);
+      exit (5);
+    }
 #ifdef HAVE_LIBJPEG
-	gdImageJpeg(im, out, 95);
+  gdImageJpeg (im, out, 95);
 #else
-	fprintf(stderr, "No JPEG library support available.\n");
+  fprintf (stderr, "No JPEG library support available.\n");
 #endif
-	gdImageDestroy(im);
-	fclose(out);
-	return 0;
+  gdImageDestroy (im);
+  fclose (out);
+  return 0;
 }
-
 /* Define to 1 if you have the <freetype/freetype.h> header file. */
 #undef HAVE_FREETYPE_FREETYPE_H
 
+/* Define if you have the iconv() function. */
+#undef HAVE_ICONV
+
 /* Define to 1 if you have the <iconv.h> header file. */
 #undef HAVE_ICONV_H
 
+/* Define if <iconv.h> defines iconv_t. */
+#undef HAVE_ICONV_T_DEF
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define as const if the declaration of iconv() needs const. */
+#undef ICONV_CONST
+
 /* Name of package */
 #undef PACKAGE
 
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.56 for GD 2.0.8.
+# Generated by GNU Autoconf 2.56 for GD 2.0.9.
 #
 # Report bugs to <gd@boutell.com>.
 #
 # Identity of this package.
 PACKAGE_NAME='GD'
 PACKAGE_TARNAME='gd'
-PACKAGE_VERSION='2.0.8'
-PACKAGE_STRING='GD 2.0.8'
+PACKAGE_VERSION='2.0.9'
+PACKAGE_STRING='GD 2.0.9'
 PACKAGE_BUGREPORT='gd@boutell.com'
 
 ac_unique_file="gd.c"
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GDLIB_MAJOR GDLIB_MINOR GDLIB_REVISION GDLIBNAME INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL LIBPNG_CONFIG FREETYPE_CONFIG LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GDLIB_MAJOR GDLIB_MINOR GDLIB_REVISION GDLIBNAME INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL LIBICONV LIBPNG_CONFIG FREETYPE_CONFIG LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures GD 2.0.8 to adapt to many kinds of systems.
+\`configure' configures GD 2.0.9 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of GD 2.0.8:";;
+     short | recursive ) echo "Configuration of GD 2.0.9:";;
    esac
   cat <<\_ACEOF
 
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-pic              try to use only PIC/non-PIC objects default=use both
   --with-x                use the X Window System
+  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib
   --with-png=DIR          where to find the png library
   --with-freetype=DIR     where to find the freetype 2.x library
   --with-jpeg=DIR         where to find the jpeg library
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-GD configure 2.0.8
+GD configure 2.0.9
 generated by GNU Autoconf 2.56
 
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by GD $as_me 2.0.8, which was
+It was created by GD $as_me 2.0.9, which was
 generated by GNU Autoconf 2.56.  Invocation command line was
 
   $ $0 $@
 
 GDLIB_MAJOR=2
 GDLIB_MINOR=0
-GDLIB_REVISION=6
+GDLIB_REVISION=9
 GDLIBNAME=gd
 
 
 
 # Define the identity of the package.
  PACKAGE=gd
- VERSION=2.0.8
+ VERSION=2.0.9
 
 
 cat >>confdefs.h <<_ACEOF
 case $host in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 4639 "configure"' > conftest.$ac_ext
+  echo '#line 4640 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
 save_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
 compiler_c_o=no
-if { (eval echo configure:5165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
+if { (eval echo configure:5166: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
   # The compiler can only warn and ignore the option if not recognized
   # So say no if there are warnings
   if test -s out/conftest.err; then
     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 6783 "configure"
+#line 6784 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 6881 "configure"
+#line 6882 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
 
 
 
+for ac_header in errno.h limits.h stddef.h stdlib.h string.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc in
+  yes:no )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+  no:yes )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------ ##
+## Report this to bug-autoconf@gnu.org. ##
+## ------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
+if test "${with_libiconv_prefix+set}" = set; then
+  withval="$with_libiconv_prefix"
+
+    for dir in `echo "$withval" | tr : ' '`; do
+      if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
+      if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
+    done
+
+fi;
+
+  echo "$as_me:$LINENO: checking for iconv" >&5
+echo $ECHO_N "checking for iconv... $ECHO_C" >&6
+if test "${am_cv_func_iconv+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    am_cv_func_iconv="no, consider installing GNU libiconv"
+    am_cv_lib_iconv=no
+    cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+       iconv(cd,NULL,NULL,NULL,NULL);
+       iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  am_cv_func_iconv=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
-for ac_header in errno.h iconv.h limits.h stddef.h stdlib.h string.h unistd.h
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+    if test "$am_cv_func_iconv" != yes; then
+      am_save_LIBS="$LIBS"
+      LIBS="$LIBS -liconv"
+      cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+         iconv(cd,NULL,NULL,NULL,NULL);
+         iconv_close(cd);
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  am_cv_lib_iconv=yes
+        am_cv_func_iconv=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+      LIBS="$am_save_LIBS"
+    fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
+echo "${ECHO_T}$am_cv_func_iconv" >&6
+  if test "$am_cv_func_iconv" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ICONV 1
+_ACEOF
+
+    echo "$as_me:$LINENO: checking for iconv declaration" >&5
+echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
+    if test "${am_cv_proto_iconv+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+      cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  am_cv_proto_iconv_arg1=""
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+am_cv_proto_iconv_arg1="const"
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
+fi
+
+    am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+    echo "$as_me:$LINENO: result: ${ac_t:-
+         }$am_cv_proto_iconv" >&5
+echo "${ECHO_T}${ac_t:-
+         }$am_cv_proto_iconv" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define ICONV_CONST $am_cv_proto_iconv_arg1
+_ACEOF
+
+  fi
+  LIBICONV=
+  if test "$am_cv_lib_iconv" = yes; then
+    LIBICONV="-liconv"
+  fi
+
+
+if test -n "$LIBICONV" ; then
+  LIBS="$LIBS $LIBICONV"
+fi
+
+
+for ac_header in iconv.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
   cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
+ echo "$as_me:$LINENO: checking whether iconv.h defines iconv_t" >&5
+echo $ECHO_N "checking whether iconv.h defines iconv_t... $ECHO_C" >&6
+   cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <iconv.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "typedef.*iconv_t" >/dev/null 2>&1; then
+  echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ICONV_T_DEF 1
+_ACEOF
+
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+rm -f conftest*
 
 fi
 
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by GD $as_me 2.0.8, which was
+This file was extended by GD $as_me 2.0.9, which was
 generated by GNU Autoconf 2.56.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-GD config.status 2.0.8
+GD config.status 2.0.9
 configured by $0, generated by GNU Autoconf 2.56,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
 s,@CPP@,$CPP,;t t
 s,@EGREP@,$EGREP,;t t
 s,@LIBTOOL@,$LIBTOOL,;t t
+s,@LIBICONV@,$LIBICONV,;t t
 s,@LIBPNG_CONFIG@,$LIBPNG_CONFIG,;t t
 s,@FREETYPE_CONFIG@,$FREETYPE_CONFIG,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 #
 AC_PREREQ(2.54)
 
-AC_INIT([GD], [2.0.8], [gd@boutell.com])
+#HEY! Change BOTH the vesion number and the GDLIB_REVISION setting!
+AC_INIT([GD], [2.0.9], [gd@boutell.com])
 AC_CONFIG_SRCDIR([gd.c])
 AC_CONFIG_AUX_DIR(config)
 
 GDLIB_MAJOR=2
 GDLIB_MINOR=0
-GDLIB_REVISION=6
+GDLIB_REVISION=9
 GDLIBNAME=gd
 
 AC_SUBST(GDLIB_MAJOR)
 fi
 
 AC_HEADER_STDC
-AC_CHECK_HEADERS([errno.h iconv.h limits.h stddef.h stdlib.h string.h unistd.h])
+AC_CHECK_HEADERS([errno.h limits.h stddef.h stdlib.h string.h unistd.h])
+
+AM_ICONV
+if test -n "$LIBICONV" ; then
+  LIBS="$LIBS $LIBICONV"
+fi
+
+AC_CHECK_HEADERS(iconv.h,
+  [AC_MSG_CHECKING(whether iconv.h defines iconv_t)
+   AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
+     [AC_MSG_RESULT(yes)
+      AC_DEFINE(HAVE_ICONV_T_DEF, 1,
+                [Define if <iconv.h> defines iconv_t.])],
+      AC_MSG_RESULT(no))])
 
 # Checks for typedefs, structures, and compiler characteristics.
 #AC_C_CONST

src/fontsizetest.c

 
 #include "gd.h"
 
-void dosizes(gdImagePtr im, int color, char *fontfile,
-             int x, int y, const char *string)
+void
+dosizes (gdImagePtr im, int color, char *fontfile,
+	 int x, int y, const char *string)
 {
   int brect[8];
   double curang = 0.0;
   int cursize;
   char buf[60];
 
-  for (cursize = 1; cursize <= 20; cursize++) 
-  {
-      sprintf(buf,"%d: %s", cursize, string);
+  for (cursize = 1; cursize <= 20; cursize++)
+    {
+      sprintf (buf, "%d: %s", cursize, string);
 
-  /* The case of newlines is taken care of in the gdImageStringTTF call */
+      /* The case of newlines is taken care of in the gdImageStringTTF call */
 #if defined(OLDER_GD)
-      cp = gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y, buf);
+      cp =
+	gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y,
+			  buf);
 #else
-      cp = gdImageStringFT  (im, brect, color, fontfile, cursize, curang, x, y, buf);
+      cp =
+	gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y,
+			 buf);
 #endif
-    if (cp)
-      fprintf(stderr, "%s\n", cp);
-    y += cursize + 4;
+      if (cp)
+	fprintf (stderr, "%s\n", cp);
+      y += cursize + 4;
 
 /* render the same fontsize with antialiasing turned off */
 #if defined(OLDER_GD)
-      cp = gdImageStringTTF (im, brect, 0-color, fontfile, cursize, curang, x, y, buf);
+      cp =
+	gdImageStringTTF (im, brect, 0 - color, fontfile, cursize, curang, x,
+			  y, buf);
 #else
-      cp = gdImageStringFT  (im, brect, 0-color, fontfile, cursize, curang, x, y, buf);
+      cp =
+	gdImageStringFT (im, brect, 0 - color, fontfile, cursize, curang, x,
+			 y, buf);
 #endif
-    if (cp)
-      fprintf(stderr, "%s\n", cp);
-    y += cursize + 4;
-  }
+      if (cp)
+	fprintf (stderr, "%s\n", cp);
+      y += cursize + 4;
+    }
 }
 
-void dotest(char *font, 
- 	    int w, int h, char *string,
-            const char *filename)
+void
+dotest (char *font, int w, int h, char *string, const char *filename)
 {
   gdImagePtr im;
   FILE *out;
   int fc;
   int lc;
 
-  im = gdImageCreate(w, h);
-  bg = gdImageColorAllocate(im, 0, 0, 0);
+  im = gdImageCreate (w, h);
+  bg = gdImageColorAllocate (im, 0, 0, 0);
 
-  gdImageFilledRectangle(im, 1, 1, w-1, h-1, bg);
-  
-  fc = gdImageColorAllocate(im, 255, 192, 192);
-  lc = gdImageColorAllocate(im, 192, 255, 255);
+  gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
 
-  out = fopen(filename, "wb");
+  fc = gdImageColorAllocate (im, 255, 192, 192);
+  lc = gdImageColorAllocate (im, 192, 255, 255);
 
-  dosizes(im, fc, font, 20, 20, string);
+  out = fopen (filename, "wb");
+
+  dosizes (im, fc, font, 20, 20, string);
 
 #if defined(HAVE_LIBPNG)
-  gdImagePng(im, out);
+  gdImagePng (im, out);
 #elif defined(HAVE_LIBJPEG)
-  gdImageJpeg(im, out, -1);
+  gdImageJpeg (im, out, -1);
 #endif
-  fclose(out);
+  fclose (out);
 }
 
-int main(int argc, char **argv)
+int
+main (int argc, char **argv)
 {
 
 #if defined(HAVE_LIBPNG)
-  dotest("times",     400, 600, ".....Hello, there!", "fontsizetest1.png");
-  dotest("cour",      400, 600, ".....Hello, there!", "fontsizetest2.png");
-  dotest("arial",     400, 600, ".....Hello, there!", "fontsizetest3.png");
-  dotest("luximr",   400, 600, ".....Hello, there!", "fontsizetest4.png");
+  dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.png");
+  dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.png");
+  dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.png");
+  dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.png");
 #elif defined(HAVE_LIBJPEG)
-  dotest("times",     400, 600, ".....Hello, there!", "fontsizetest1.jpeg");
-  dotest("cour",      400, 600, ".....Hello, there!", "fontsizetest2.jpeg");
-  dotest("arial",     400, 600, ".....Hello, there!", "fontsizetest3.jpeg");
-  dotest("luximr",   400, 600, ".....Hello, there!", "fontsizetest4.jpeg");
+  dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.jpeg");
+  dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.jpeg");
+  dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.jpeg");
+  dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.jpeg");
 #else
-  fprintf(stderr, "no PNG or JPEG support\n");
+  fprintf (stderr, "no PNG or JPEG support\n");
 #endif
 
   return 0;

src/fontwheeltest.c

 #include "gd.h"
 #define DEGTORAD(x) ( (x) * (2.0 * 3.14159265) / 360.0 )
 
-void doerr(FILE *err, const char *msg)
+void
+doerr (FILE * err, const char *msg)
 {
   if (err)
-  {
-    fprintf(err, "%s\n", msg);
-    fflush(err);
-  }
+    {
+      fprintf (err, "%s\n", msg);
+      fflush (err);
+    }
 }
 
-void dowheel(gdImagePtr im, int color, char *fontfile,
-             int fontsize, double angle, int x, int y, char *string)
+void
+dowheel (gdImagePtr im, int color, char *fontfile,
+	 int fontsize, double angle, int x, int y, char *string)
 {
   int brect[8];
   FILE *err;
   double curang;
   char *cp;
-  
-  err = fopen("err.out", "a");
-  doerr(err, "------------- New fontwheel --------------");
-  doerr(err, fontfile);
-  doerr(err, string);
-  doerr(err, "------------------------------------------");
-
-  for (curang=0.0; curang < 360.0; curang += angle)
-  {
-  /* The case of newlines is taken care of in the gdImageStringTTF call */
+
+  err = fopen ("err.out", "a");
+  doerr (err, "------------- New fontwheel --------------");
+  doerr (err, fontfile);
+  doerr (err, string);
+  doerr (err, "------------------------------------------");
+
+  for (curang = 0.0; curang < 360.0; curang += angle)
+    {
+      /* The case of newlines is taken care of in the gdImageStringTTF call */
 #if defined(OLDER_GD)
-      cp = gdImageStringTTF (im, brect, color, fontfile, fontsize, DEGTORAD(curang), x, y, string);
+      cp =
+	gdImageStringTTF (im, brect, color, fontfile, fontsize,
+			  DEGTORAD (curang), x, y, string);
 #else
-      cp = gdImageStringFT  (im, brect, color, fontfile, fontsize, DEGTORAD(curang), x, y, string);
+      cp =
+	gdImageStringFT (im, brect, color, fontfile, fontsize,
+			 DEGTORAD (curang), x, y, string);
 #endif
-    if (cp)
-      doerr(err, cp);
-  }
+      if (cp)
+	doerr (err, cp);
+    }
 
-  fclose(err);
+  fclose (err);
 }
 
-void dolines(gdImagePtr im, int color, double incr, int x, int y, int offset, int length)
+void
+dolines (gdImagePtr im, int color, double incr, int x, int y, int offset,
+	 int length)
 {
   double curang;
   double angle;
   double x0, x1, y0, y1;
-  for (curang=0.0; curang < 360.0; curang += incr )
-  {
-    angle = curang * (2.0 * 3.14159265) / 360.0;
-    x0 = cos(angle)*offset + x;
-    x1 = cos(angle)*(offset+length) + x;
-    y0 = sin(angle)*offset + y;
-    y1 = sin(angle)*(offset+length) + y;
-    gdImageLine(im, x0, y0, x1, y1, color);
-  }
+  for (curang = 0.0; curang < 360.0; curang += incr)
+    {
+      angle = curang * (2.0 * 3.14159265) / 360.0;
+      x0 = cos (angle) * offset + x;
+      x1 = cos (angle) * (offset + length) + x;
+      y0 = sin (angle) * offset + y;
+      y1 = sin (angle) * (offset + length) + y;
+      gdImageLine (im, x0, y0, x1, y1, color);
+    }
 }
 
-void dotest(char *font, int size, double incr, 
- 	    int w, int h, char *string,
-            const char *filename)
+void
+dotest (char *font, int size, double incr,
+	int w, int h, char *string, const char *filename)
 {
   gdImagePtr im;
   FILE *out;
   int xc = w / 2;
   int yc = h / 2;
 
-  im = gdImageCreate(w, h);
-  bg = gdImageColorAllocate(im, 0, 0, 0);
+  im = gdImageCreate (w, h);
+  bg = gdImageColorAllocate (im, 0, 0, 0);
+
+  gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
 
-  gdImageFilledRectangle(im, 1, 1, w-1, h-1, bg);
-  
-  fc = gdImageColorAllocate(im, 255, 192, 192);
-  lc = gdImageColorAllocate(im, 192, 255, 255);
+  fc = gdImageColorAllocate (im, 255, 192, 192);
+  lc = gdImageColorAllocate (im, 192, 255, 255);
 
-  out = fopen(filename, "wb");
+  out = fopen (filename, "wb");
 
-  dowheel(im, fc, font, size, incr, xc, yc, string);
-  dolines(im, lc, incr, xc, yc, 20, 120);
+  dowheel (im, fc, font, size, incr, xc, yc, string);
+  dolines (im, lc, incr, xc, yc, 20, 120);
 
 #if defined(HAVE_LIBPNG)
-  gdImagePng(im, out);
+  gdImagePng (im, out);
 #elif defined(HAVE_LIBJPEG)
-  gdImageJpeg(im, out, -1);
+  gdImageJpeg (im, out, -1);
 #endif
 
-  fclose(out);
+  fclose (out);
 }
 
-int main(int argc, char **argv)
+int
+main (int argc, char **argv)
 {
 
 #if defined(HAVE_LIBPNG)
-  dotest("times", 16, 20.0, 400, 400, ".....Hello, there!", "fontwheeltest1.png");
-  dotest("times", 16, 30.0, 400, 400, ".....Hello, there!", "fontwheeltest2.png");
-  dotest("arial", 16, 45.0, 400, 400, ".....Hello, there!", "fontwheeltest3.png");
-  dotest("arial", 16, 90.0, 400, 400, ".....Hello, there!", "fontwheeltest4.png");
+  dotest ("times", 16, 20.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest1.png");
+  dotest ("times", 16, 30.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest2.png");
+  dotest ("arial", 16, 45.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest3.png");
+  dotest ("arial", 16, 90.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest4.png");
 #elif defined(HAVE_LIBJPEG)
-  dotest("times", 16, 20.0, 400, 400, ".....Hello, there!", "fontwheeltest1.jpeg");
-  dotest("times", 16, 30.0, 400, 400, ".....Hello, there!", "fontwheeltest2.jpeg");
-  dotest("arial", 16, 45.0, 400, 400, ".....Hello, there!", "fontwheeltest3.jpeg");
-  dotest("arial", 16, 90.0, 400, 400, ".....Hello, there!", "fontwheeltest4.jpeg");
+  dotest ("times", 16, 20.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest1.jpeg");
+  dotest ("times", 16, 30.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest2.jpeg");
+  dotest ("arial", 16, 45.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest3.jpeg");
+  dotest ("arial", 16, 90.0, 400, 400, ".....Hello, there!",
+	  "fontwheeltest4.jpeg");
 #else
-  fprintf(stderr, "no PNG or JPEG support\n");
+  fprintf (stderr, "no PNG or JPEG support\n");
 #endif
 
   return 0;
 #define ASC(ch)  ch
 #else /*CHARSET_EBCDIC */
 #define ASC(ch) gd_toascii[(unsigned char)ch]
-static const unsigned char gd_toascii[256] =
-{
+static const unsigned char gd_toascii[256] = {
 /*00 */ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
   0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,	/*................ */
 /*10 */ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
 
 static void gdImageBrushApply (gdImagePtr im, int x, int y);
 static void gdImageTileApply (gdImagePtr im, int x, int y);
-static int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
+static int gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
 
 gdImagePtr
 gdImageCreate (int sx, int sy)
   for (i = 0; (i < sy); i++)
     {
       /* Row-major ever since gd 1.3 */
-      im->pixels[i] = (unsigned char *) gdCalloc (
-						sx, sizeof (unsigned char));
+      im->pixels[i] = (unsigned char *) gdCalloc (sx, sizeof (unsigned char));
     }
   im->sx = sx;
   im->sy = sy;
   im->style = 0;
   for (i = 0; (i < sy); i++)
     {
-      im->tpixels[i] = (int *) gdCalloc (
-					  sx, sizeof (int));
+      im->tpixels[i] = (int *) gdCalloc (sx, sizeof (int));
     }
   im->sx = sx;
   im->sy = sy;
   im->interlace = 0;
   im->trueColor = 1;
   /* 2.0.2: alpha blending is now on by default, and saving of alpha is
-    off by default. This allows font antialiasing to work as expected
-    on the first try in JPEGs -- quite important -- and also allows 
-    for smaller PNGs when saving of alpha channel is not really 
-    desired, which it usually isn't! */
+     off by default. This allows font antialiasing to work as expected
+     on the first try in JPEGs -- quite important -- and also allows 
+     for smaller PNGs when saving of alpha channel is not really 
+     desired, which it usually isn't! */
   im->saveAlphaFlag = 0;
   im->alphaBlendingFlag = 1;
   im->thick = 1;
 }
 RGBType;
 typedef struct
-  {
-    float H, W, B;
-  }
+{
+  float H, W, B;
+}
 HWBType;
 
 static HWBType *
 	}
     }
 
-  diff = diff * diff + (HWB1.W - HWB2.W) * (HWB1.W - HWB2.W) + (HWB1.B - HWB2.B) * (HWB1.B - HWB2.B);
+  diff =
+    diff * diff + (HWB1.W - HWB2.W) * (HWB1.W - HWB2.W) + (HWB1.B -
+							   HWB2.B) * (HWB1.B -
+								      HWB2.B);
 
   return diff;
 }
 	  continue;
 	}
       if ((im->red[i] == r) &&
-	  (im->green[i] == g) &&
-	  (im->blue[i] == b) &&
-	  (im->alpha[i] == a))
+	  (im->green[i] == g) && (im->blue[i] == b) && (im->alpha[i] == a))
 	{
 	  return i;
 	}
 	  continue;		/* Color not in use */
 	}
       if (c == im->transparent)
-        {
-          /* don't ever resolve to the color that has
-           * been designated as the transparent color */
-          continue;
+	{
+	  /* don't ever resolve to the color that has
+	   * been designated as the transparent color */
+	  continue;
 	}
       rd = (long) (im->red[c] - r);
       gd = (long) (im->green[c] - g);
 	    {
 	      /* This ought to use HWB, but we don't have an alpha-aware
 	         version of that yet. */
-	      xlate[p] = gdImageColorClosestAlpha (from, to->red[p], to->green[p], to->blue[p], to->alpha[p]);
+	      xlate[p] =
+		gdImageColorClosestAlpha (from, to->red[p], to->green[p],
+					  to->blue[p], to->alpha[p]);
 	      /*printf("Mapping %d (%d, %d, %d, %d) to %d (%d, %d, %d, %d)\n", */
 	      /*      p,  to->red[p], to->green[p], to->blue[p], to->alpha[p], */
 	      /*      xlate[p], from->red[xlate[p]], from->green[xlate[p]], from->blue[xlate[p]], from->alpha[xlate[p]]); */
 	    {
 	      if (im->alphaBlendingFlag)
 		{
-		  im->tpixels[y][x] =
-		    gdAlphaBlend (im->tpixels[y][x],
-				  color);
+		  im->tpixels[y][x] = gdAlphaBlend (im->tpixels[y][x], color);
 		}
 	      else
 		{
 	  for (lx = x1; (lx < x2); lx++)
 	    {
 	      int p;
-	      p = gdImageGetTrueColorPixel (
-					     im->brush, srcx, srcy);
-	      gdImageSetPixel (im, lx, ly,
-			       p);
+	      p = gdImageGetTrueColorPixel (im->brush, srcx, srcy);
+	      /* 2.0.9, Thomas Winzig: apply simple full transparency */
+	      if (p != gdImageGetTransparent (im->brush))
+		{
+		  gdImageSetPixel (im, lx, ly, p);
+		}
 	      srcx++;
 	    }
 	  srcy++;
 		  if (im->brush->trueColor)
 		    {
 		      gdImageSetPixel (im, lx, ly,
-				       gdImageColorResolveAlpha (
-								  im,
-						      gdTrueColorGetRed (p),
-						    gdTrueColorGetGreen (p),
-						     gdTrueColorGetBlue (p),
-						  gdTrueColorGetAlpha (p)));
+				       gdImageColorResolveAlpha (im,
+								 gdTrueColorGetRed
+								 (p),
+								 gdTrueColorGetGreen
+								 (p),
+								 gdTrueColorGetBlue
+								 (p),
+								 gdTrueColorGetAlpha
+								 (p)));
 		    }
 		  else
 		    {
-		      gdImageSetPixel (im, lx, ly,
-				       im->brushColorMap[p]);
+		      gdImageSetPixel (im, lx, ly, im->brushColorMap[p]);
 		    }
 		}
 	      srcx++;
     }
   else
     {
-      p = gdImageGetPixel(im->tile, srcx, srcy);
+      p = gdImageGetPixel (im->tile, srcx, srcy);
       /* Allow for transparency */
       if (p != gdImageGetTransparent (im->tile))
 	{
 	      /* Truecolor tile. Very slow
 	         on a palette destination. */
 	      gdImageSetPixel (im, x, y,
-			       gdImageColorResolveAlpha (
-							  im,
-						      gdTrueColorGetRed (p),
-						    gdTrueColorGetGreen (p),
-						     gdTrueColorGetBlue (p),
-						  gdTrueColorGetAlpha (p)));
+			       gdImageColorResolveAlpha (im,
+							 gdTrueColorGetRed
+							 (p),
+							 gdTrueColorGetGreen
+							 (p),
+							 gdTrueColorGetBlue
+							 (p),
+							 gdTrueColorGetAlpha
+							 (p)));
 	    }
 	  else
 	    {
-	      gdImageSetPixel (im, x, y,
-			       im->tileColorMap[p]);
+	      gdImageSetPixel (im, x, y, im->tileColorMap[p]);
 	    }
 	}
     }
     {
       /* More-or-less horizontal. use wid for vertical stroke */
       /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
-      if ((dx == 0) && (dy == 0)) {
-        wid = 1;
-      } else {
-        wid = thick * cos (atan2 (dy, dx));
-        if (wid == 0) {
-          wid = 1;
-        }
-      }
+      if ((dx == 0) && (dy == 0))
+	{
+	  wid = 1;
+	}
+      else
+	{
+	  wid = thick * cos (atan2 (dy, dx));
+	  if (wid == 0)
+	    {
+	      wid = 1;
+	    }
+	}
       d = 2 * dy - dx;
       incr1 = 2 * dy;
       incr2 = 2 * (dy - dx);
 int
 gdImageBoundsSafe (gdImagePtr im, int x, int y)
 {
-  return (!(((y < 0) || (y >= im->sy)) ||
-	    ((x < 0) || (x >= im->sx))));
+  return (!(((y < 0) || (y >= im->sy)) || ((x < 0) || (x >= im->sx))));
 }
 
 void
-gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y,
-	     int c, int color)
+gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
 {
   int cx, cy;
   int px, py;
 }
 
 void
-gdImageCharUp (gdImagePtr im, gdFontPtr f,
-	       int x, int y, int c, int color)
+gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
 {
   int cx, cy;
   int px, py;
    See gd_arc_f_buggy.c for a better version that doesn't 
    seem to be bug-free yet. */
 
-void 
-gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
+void
+gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
+	    int color)
 {
   gdImageFilledArc (im, cx, cy, w, h, s, e, color, gdNoFill);
 }
 
-void 
-gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
+void
+gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
+		  int color, int style)
 {
   gdPoint pts[3];
   int i;
     }
 }
 
-void 
+void
 gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
 {
   gdImageFilledArc (im, cx, cy, w, h, 0, 360, color, gdPie);
 	    {
 	      if ((c != border) && (c != color))
 		{
-		  gdImageFillToBorder (im, i, y - 1,
-				       border, color);
+		  gdImageFillToBorder (im, i, y - 1, border, color);
 		  lastBorder = 0;
 		}
 	    }
 	    {
 	      if ((c != border) && (c != color))
 		{
-		  gdImageFillToBorder (im, i, y + 1,
-				       border, color);
+		  gdImageFillToBorder (im, i, y + 1, border, color);
 		  lastBorder = 0;
 		}
 	    }
 }
 
 void
-gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
+gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
+			int color)
 {
   int x, y;
   for (y = y1; (y <= y2); y++)
 }
 
 void
-gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
+gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
+	     int srcY, int w, int h)
 {
   int c;
   int x, y;
 						srcY + y);
 	      if (c != src->transparent)
 		{
-		  gdImageSetPixel (dst,
-				   dstX + x,
-				   dstY + y,
-				   c);
+		  gdImageSetPixel (dst, dstX + x, dstY + y, c);
 		}
 	    }
 	}
       for (x = srcX; (x < (srcX + w)); x++)
 	{
 	  int nc;
-          int mapTo;
+	  int mapTo;
 	  c = gdImageGetPixel (src, x, y);
 	  /* Added 7/24/95: support transparent copies */
 	  if (gdImageGetTransparent (src) == c)
 	      /* 2.05: remap to the palette available in the
 	         destination image. This is slow and
 	         works badly, but it beats crashing! Thanks 
-                 to Padhrig McCarthy. */
+	         to Padhrig McCarthy. */
 	      mapTo = gdImageColorResolveAlpha (dst,
-					      gdTrueColorGetRed (c),
-					    gdTrueColorGetGreen (c),
-					     gdTrueColorGetBlue (c),
-					   gdTrueColorGetAlpha (c));
+						gdTrueColorGetRed (c),
+						gdTrueColorGetGreen (c),
+						gdTrueColorGetBlue (c),
+						gdTrueColorGetAlpha (c));
 	    }
 	  else if (colorMap[c] == (-1))
 	    {
 		{
 		  /* Get best match possible. This
 		     function never returns error. */
-		  nc = gdImageColorResolveAlpha (
-						  dst,
-						  src->red[c], src->green[c],
-					       src->blue[c], src->alpha[c]);
+		  nc = gdImageColorResolveAlpha (dst,
+						 src->red[c], src->green[c],
+						 src->blue[c], src->alpha[c]);
 		}
 	      colorMap[c] = nc;
-              mapTo = colorMap[c];  
+	      mapTo = colorMap[c];
+	    }
+	  else
+	    {
+	      mapTo = colorMap[c];
 	    }
-          else
-            {
-              mapTo = colorMap[c];  
-            }
 	  gdImageSetPixel (dst, tox, toy, mapTo);
 	  tox++;
 	}
 /* This function is a substitute for real alpha channel operations,
    so it doesn't pay attention to the alpha channel. */
 void
-gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
+gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
+		  int srcX, int srcY, int w, int h, int pct)
 {
 
   int c, dc;
 /* This function is a substitute for real alpha channel operations,
    so it doesn't pay attention to the alpha channel. */
 void
-gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
+gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
+		      int srcX, int srcY, int w, int h, int pct)
 {
 
   int c, dc;
 	    {
 	      dc = gdImageGetPixel (dst, tox, toy);
 	      g = 0.29900 * dst->red[dc]
-		+ 0.58700 * dst->green[dc]
-		+ 0.11400 * dst->blue[dc];
+		+ 0.58700 * dst->green[dc] + 0.11400 * dst->blue[dc];
 
 	      ncR = gdImageRed (src, c) * (pct / 100.0)
-		+ gdImageRed (dst, dc) * g *
-		((100 - pct) / 100.0);
+		+ gdImageRed (dst, dc) * g * ((100 - pct) / 100.0);
 	      ncG = gdImageGreen (src, c) * (pct / 100.0)
-		+ gdImageGreen (dst, dc) * g *
-		((100 - pct) / 100.0);
+		+ gdImageGreen (dst, dc) * g * ((100 - pct) / 100.0);
 	      ncB = gdImageBlue (src, c) * (pct / 100.0)
-		+ gdImageBlue (dst, dc) * g *
-		((100 - pct) / 100.0);
+		+ gdImageBlue (dst, dc) * g * ((100 - pct) / 100.0);
 
 	      /* First look for an exact match */
 	      nc = gdImageColorExact (dst, ncR, ncG, ncB);
 }
 
 void
-gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
+gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
+		    int srcX, int srcY, int dstW, int dstH, int srcW,
+		    int srcH)
 {
   int c;
   int x, y;
 		}
 	      if (dst->trueColor)
 		{
-		  mapTo = gdImageGetTrueColorPixel (src, x, y);
-		  /* Added 7/24/95: support transparent copies */
-		  if (gdImageGetTransparent (src) == mapTo)
+		  /* 2.0.9: Thorben Kundinger: Maybe the source image is not 
+		     a truecolor image */
+		  if (!src->trueColor)
 		    {
-		      tox++;
-		      continue;
+		      int tmp = gdImageGetPixel (src, x, y);
+		      mapTo = gdImageGetTrueColorPixel (src, x, y);
+		      if (gdImageGetTransparent (src) == tmp)
+			{
+			  tox++;
+			  continue;
+			}
+		    }
+		  else
+		    {
+		      /* TK: old code follows */
+		      mapTo = gdImageGetTrueColorPixel (src, x, y);
+		      /* Added 7/24/95: support transparent copies */
+		      if (gdImageGetTransparent (src) == mapTo)
+			{
+			  tox++;
+			  continue;
+			}
 		    }
 		}
 	      else
 		         destination image. This is slow and
 		         works badly. */
 		      mapTo = gdImageColorResolveAlpha (dst,
-						      gdTrueColorGetRed (c),
-						    gdTrueColorGetGreen (c),
-						     gdTrueColorGetBlue (c),
-						   gdTrueColorGetAlpha (c));
+							gdTrueColorGetRed (c),
+							gdTrueColorGetGreen
+							(c),
+							gdTrueColorGetBlue
+							(c),
+							gdTrueColorGetAlpha
+							(c));
 		    }
 		  else
 		    {
 			  else
 			    {
 			      /* Find or create the best match */
-                  /* 2.0.5: can't use gdTrueColorGetRed, etc with palette */
+			      /* 2.0.5: can't use gdTrueColorGetRed, etc with palette */
 			      nc = gdImageColorResolveAlpha (dst,
-						      gdImageRed (src, c),
-						    gdImageGreen (src, c),
-						     gdImageBlue (src, c),
-						   gdImageAlpha (src, c));
+							     gdImageRed (src,
+									 c),
+							     gdImageGreen
+							     (src, c),
+							     gdImageBlue (src,
+									  c),
+							     gdImageAlpha
+							     (src, c));
 			    }
 			  colorMap[c] = nc;
 			}
 
 void
 gdImageCopyRotated (gdImagePtr dst,
-		      gdImagePtr src,
-		      double dstX, double dstY,
-		      int srcX, int srcY,
-		      int srcWidth, int srcHeight,
-                      int angle)
+		    gdImagePtr src,
+		    double dstX, double dstY,
+		    int srcX, int srcY,
+		    int srcWidth, int srcHeight, int angle)
 {
-	double dx, dy;
-        double radius = sqrt(srcWidth * srcWidth + srcHeight * srcHeight);
-	double aCos = cos(angle * .0174532925);
-	double aSin = sin(angle * .0174532925);
-	double scX = srcX + ((double) srcWidth) / 2;
-	double scY = srcY + ((double) srcHeight) / 2;
-        int cmap[gdMaxColors];
-        int i;
-        for (i = 0; (i < gdMaxColors); i++)
-        {
-          cmap[i] = (-1);
-        }
-	for (dy = dstY - radius; (dy <= dstY + radius); dy++) {
-		for (dx = dstX - radius; (dx <= dstX + radius); dx++) {
-			double sxd = (dx - dstX) * aCos - (dy - dstY) * aSin;
-			double syd = (dy - dstY) * aCos + (dx - dstX) * aSin;
-			int sx = sxd + scX;
-			int sy = syd + scY;
-			if ((sx >= srcX) && (sx < srcX + srcWidth) &&
-				(sy >= srcY) && (sy < srcY + srcHeight))
-			{
-				int c =	gdImageGetPixel(src, sx, sy);
-                                if (!src->trueColor) {
-                                  /* Use a table to avoid an expensive
-                                    lookup on every single pixel */
-                                  if (cmap[c] == -1) {
-                                    cmap[c] = gdImageColorResolveAlpha(
-						dst,
-						gdImageRed(src, c),
-						gdImageGreen(src, c),
-						gdImageBlue(src, c),
-						gdImageAlpha(src, c));	
-                                  }
-				  gdImageSetPixel(dst,
-				    dx, dy, cmap[c]);
-                                } else {   
-				  gdImageSetPixel(dst,
-				  	  dx, dy,
-					  gdImageColorResolveAlpha(
-						  dst,
-						  gdImageRed(src, c),
-						  gdImageGreen(src, c),
-						  gdImageBlue(src, c),
-						  gdImageAlpha(src, c)));	
-                                }
-			}
+  double dx, dy;
+  double radius = sqrt (srcWidth * srcWidth + srcHeight * srcHeight);
+  double aCos = cos (angle * .0174532925);
+  double aSin = sin (angle * .0174532925);
+  double scX = srcX + ((double) srcWidth) / 2;
+  double scY = srcY + ((double) srcHeight) / 2;
+  int cmap[gdMaxColors];
+  int i;
+  for (i = 0; (i < gdMaxColors); i++)
+    {
+      cmap[i] = (-1);
+    }
+  for (dy = dstY - radius; (dy <= dstY + radius); dy++)
+    {
+      for (dx = dstX - radius; (dx <= dstX + radius); dx++)
+	{
+	  double sxd = (dx - dstX) * aCos - (dy - dstY) * aSin;
+	  double syd = (dy - dstY) * aCos + (dx - dstX) * aSin;
+	  int sx = sxd + scX;
+	  int sy = syd + scY;
+	  if ((sx >= srcX) && (sx < srcX + srcWidth) &&
+	      (sy >= srcY) && (sy < srcY + srcHeight))
+	    {
+	      int c = gdImageGetPixel (src, sx, sy);
+	      if (!src->trueColor)
+		{
+		  /* Use a table to avoid an expensive
+		     lookup on every single pixel */
+		  if (cmap[c] == -1)
+		    {
+		      cmap[c] = gdImageColorResolveAlpha (dst,
+							  gdImageRed (src, c),
+							  gdImageGreen (src,
+									c),
+							  gdImageBlue (src,
+								       c),
+							  gdImageAlpha (src,
+									c));
+		    }
+		  gdImageSetPixel (dst, dx, dy, cmap[c]);
 		}
+	      else
+		{
+		  gdImageSetPixel (dst,
+				   dx, dy,
+				   gdImageColorResolveAlpha (dst,
+							     gdImageRed (src,
+									 c),
+							     gdImageGreen
+							     (src, c),
+							     gdImageBlue (src,
+									  c),
+							     gdImageAlpha
+							     (src, c)));
+		}
+	    }
 	}
+    }
 }
 
 /* When gd 1.x was first created, floating point was to be avoided.
 		      gdImagePtr src,
 		      int dstX, int dstY,
 		      int srcX, int srcY,
-		      int dstW, int dstH,
-		      int srcW, int srcH)
+		      int dstW, int dstH, int srcW, int srcH)
 {
   int x, y;
   if (!dst->trueColor)
     {
-      gdImageCopyResized (
-			   dst, src, dstX, dstY, srcX, srcY, dstW, dstH,
-			   srcW, srcH);
+      gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH,
+			  srcW, srcH);
       return;
     }
   for (y = dstY; (y < dstY + dstH); y++)
 	  float sx, sy;
 	  float spixels = 0;
 	  float red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
-	  sy1 = ((float) y - (float) dstY) * (float) srcH /
-	    (float) dstH;
+	  sy1 = ((float) y - (float) dstY) * (float) srcH / (float) dstH;
 	  sy2 = ((float) (y + 1) - (float) dstY) * (float) srcH /
 	    (float) dstH;
 	  sy = sy1;
 		{
 		  yportion = 1.0;
 		}
-	      sx1 = ((float) x - (float) dstX) * (float) srcW /
-		dstW;
-	      sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW /
-		dstW;
+	      sx1 = ((float) x - (float) dstX) * (float) srcW / dstW;
+	      sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW / dstW;
 	      sx = sx1;
 	      do
 		{
 		      xportion = 1.0;
 		    }
 		  pcontribution = xportion * yportion;
-                  /* 2.08: previously srcX and srcY were ignored. 
-                     Andrew Pattison */
-		  p = gdImageGetTrueColorPixel (
-						 src,
-						 (int) sx + srcX,
-						 (int) sy + srcY);
+		  /* 2.08: previously srcX and srcY were ignored. 
+		     Andrew Pattison */
+		  p = gdImageGetTrueColorPixel (src,
+						(int) sx + srcX,
+						(int) sy + srcY);
 		  red += gdTrueColorGetRed (p) * pcontribution;
 		  green += gdTrueColorGetGreen (p) * pcontribution;
 		  blue += gdTrueColorGetBlue (p) * pcontribution;
 			   x, y,
 			   gdTrueColorAlpha ((int) red,
 					     (int) green,
-					     (int) blue,
-					     (int) alpha));
+					     (int) blue, (int) alpha));
 	}
     }
 }
 
       for (i = 0; (i < (ints)); i += 2)
 	{
-	  gdImageLine (im, im->polyInts[i], y,
-		       im->polyInts[i + 1], y, c);
+	  gdImageLine (im, im->polyInts[i], y, im->polyInts[i + 1], y, c);
 	}
     }
 }
     {
       gdFree (im->style);
     }
-  im->style = (int *)
-    gdMalloc (sizeof (int) * noOfPixels);
+  im->style = (int *) gdMalloc (sizeof (int) * noOfPixels);
   memcpy (im->style, style, sizeof (int) * noOfPixels);
   im->styleLength = noOfPixels;
   im->stylePos = 0;
 #define GD_H 1
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
 /* default fontpath for unix systems  - whatever happened to standards ! */
 	based on the alpha channel value of the source color.
 	The resulting color is opaque. */
 
-int gdAlphaBlend(int dest, int src);
-
-typedef struct gdImageStruct {
-	/* Palette-based image pixels */
-	unsigned char ** pixels;
-	int sx;
-	int sy;
-	/* These are valid in palette images only. See also
-		'alpha', which appears later in the structure to
-		preserve binary backwards compatibility */
-	int colorsTotal;
-	int red[gdMaxColors];
-	int green[gdMaxColors];
-	int blue[gdMaxColors]; 
-	int open[gdMaxColors];
-	/* For backwards compatibility, this is set to the
-		first palette entry with 100% transparency,
-		and is also set and reset by the 
-		gdImageColorTransparent function. Newer
-		applications can allocate palette entries
-		with any desired level of transparency; however,
-		bear in mind that many viewers, notably
-		many web browsers, fail to implement
-		full alpha channel for PNG and provide
-		support for full opacity or transparency only. */
-	int transparent;
-	int *polyInts;
-	int polyAllocated;
-	struct gdImageStruct *brush;
-	struct gdImageStruct *tile;	
-	int brushColorMap[gdMaxColors];
-	int tileColorMap[gdMaxColors];
-	int styleLength;
-	int stylePos;
-	int *style;
-	int interlace;
-	/* New in 2.0: thickness of line. Initialized to 1. */
-	int thick;
-	/* New in 2.0: alpha channel for palettes. Note that only
-		Macintosh Internet Explorer and (possibly) Netscape 6
-		really support multiple levels of transparency in
-		palettes, to my knowledge, as of 2/15/01. Most
-		common browsers will display 100% opaque and
-		100% transparent correctly, and do something 
-		unpredictable and/or undesirable for levels
-		in between. TBB */
-	int alpha[gdMaxColors]; 
-	/* Truecolor flag and pixels. New 2.0 fields appear here at the
-		end to minimize breakage of existing object code. */
-	int trueColor;
-	int ** tpixels;
-	/* Should alpha channel be copied, or applied, each time a
-		pixel is drawn? This applies to truecolor images only.
-		No attempt is made to alpha-blend in palette images,
-		even if semitransparent palette entries exist. 
-		To do that, build your image as a truecolor image,
-		then quantize down to 8 bits. */
-	int alphaBlendingFlag;
-	/* Should the alpha channel of the image be saved? This affects
-		PNG at the moment; other future formats may also
-		have that capability. JPEG doesn't. */
-	int saveAlphaFlag;
-} gdImage;
-
-typedef gdImage * gdImagePtr;
-
-typedef struct {
-	/* # of characters in font */
-	int nchars;
-	/* First character is numbered... (usually 32 = space) */
-	int offset;
-	/* Character width and height */
-	int w;
-	int h;
-	/* Font data; array of characters, one row after another.
-		Easily included in code, also easily loaded from
-		data files. */
-	char *data;
-} gdFont;
+  int gdAlphaBlend (int dest, int src);
+
+  typedef struct gdImageStruct
+  {
+    /* Palette-based image pixels */
+    unsigned char **pixels;
+    int sx;
+    int sy;
+    /* These are valid in palette images only. See also
+       'alpha', which appears later in the structure to
+       preserve binary backwards compatibility */
+    int colorsTotal;
+    int red[gdMaxColors];
+    int green[gdMaxColors];
+    int blue[gdMaxColors];
+    int open[gdMaxColors];
+    /* For backwards compatibility, this is set to the
+       first palette entry with 100% transparency,
+       and is also set and reset by the 
+       gdImageColorTransparent function. Newer
+       applications can allocate palette entries
+       with any desired level of transparency; however,
+       bear in mind that many viewers, notably
+       many web browsers, fail to implement
+       full alpha channel for PNG and provide
+       support for full opacity or transparency only. */
+    int transparent;
+    int *polyInts;
+    int polyAllocated;
+    struct gdImageStruct *brush;
+    struct gdImageStruct *tile;
+    int brushColorMap[gdMaxColors];
+    int tileColorMap[gdMaxColors];
+    int styleLength;
+    int stylePos;
+    int *style;
+    int interlace;
+    /* New in 2.0: thickness of line. Initialized to 1. */
+    int thick;
+    /* New in 2.0: alpha channel for palettes. Note that only
+       Macintosh Internet Explorer and (possibly) Netscape 6
+       really support multiple levels of transparency in
+       palettes, to my knowledge, as of 2/15/01. Most
+       common browsers will display 100% opaque and
+       100% transparent correctly, and do something 
+       unpredictable and/or undesirable for levels
+       in between. TBB */
+    int alpha[gdMaxColors];
+    /* Truecolor flag and pixels. New 2.0 fields appear here at the
+       end to minimize breakage of existing object code. */
+    int trueColor;
+    int **tpixels;
+    /* Should alpha channel be copied, or applied, each time a
+       pixel is drawn? This applies to truecolor images only.
+       No attempt is made to alpha-blend in palette images,
+       even if semitransparent palette entries exist. 
+       To do that, build your image as a truecolor image,
+       then quantize down to 8 bits. */
+    int alphaBlendingFlag;
+    /* Should the alpha channel of the image be saved? This affects
+       PNG at the moment; other future formats may also
+       have that capability. JPEG doesn't. */
+    int saveAlphaFlag;
+  }
+  gdImage;
+
+  typedef gdImage *gdImagePtr;
+
+  typedef struct
+  {
+    /* # of characters in font */
+    int nchars;
+    /* First character is numbered... (usually 32 = space) */
+    int offset;
+    /* Character width and height */
+    int w;
+    int h;
+    /* Font data; array of characters, one row after another.
+       Easily included in code, also easily loaded from
+       data files. */
+    char *data;
+  }
+  gdFont;
 
 /* Text functions take these. */
-typedef gdFont *gdFontPtr;
+  typedef gdFont *gdFontPtr;
 
 /* For backwards compatibility only. Use gdImageSetStyle()
 	for MUCH more flexible line drawing. Also see
 /* Functions to manipulate images. */
 
 /* Creates a palette-based image (up to 256 colors). */
-gdImagePtr gdImageCreate(int sx, int sy);
+  gdImagePtr gdImageCreate (int sx, int sy);
 
 /* An alternate name for the above (2.0). */
 #define gdImageCreatePalette gdImageCreate
 
 /* Creates a truecolor image (millions of colors). */
-gdImagePtr gdImageCreateTrueColor(int sx, int sy);
+  gdImagePtr gdImageCreateTrueColor (int sx, int sy);
 
 /* Creates an image from various file types. These functions
 	return a palette or truecolor image based on the
 	nature of the file being loaded. Truecolor PNG
 	stays truecolor; palette PNG stays palette-based;
 	JPEG is always truecolor. */
-gdImagePtr gdImageCreateFromPng(FILE *fd);
-gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
-gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
-gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile); 
-gdImagePtr gdImageCreateFromJpeg(FILE *infile);
-gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
+  gdImagePtr gdImageCreateFromPng (FILE * fd);
+  gdImagePtr gdImageCreateFromPngCtx (gdIOCtxPtr in);
+  gdImagePtr gdImageCreateFromWBMP (FILE * inFile);
+  gdImagePtr gdImageCreateFromWBMPCtx (gdIOCtx * infile);
+  gdImagePtr gdImageCreateFromJpeg (FILE * infile);
+  gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx * infile);
 
 /* A custom data source. */
 /* The source function must return -1 on error, otherwise the number
         of bytes fetched. 0 is EOF, not an error! */
 /* context will be passed to your source function. */
 
-typedef struct {
-        int (*source) (void *context, char *buffer, int len);
-        void *context;
-} gdSource, *gdSourcePtr;
+  typedef struct
+  {
+    int (*source) (void *context, char *buffer, int len);
+    void *context;
+  }