libtiff: Fix bug in auto rotate option code.

https://github.com/libsdl-org/libtiff/commit/145eca24b585cd0d33d2469bf1a9ede0d225155b

From 145eca24b585cd0d33d2469bf1a9ede0d225155b Mon Sep 17 00:00:00 2001
From: Bob Friesenhahn <[EMAIL REDACTED]>
Date: Sat, 26 Jan 2013 02:23:07 +0000
Subject: [PATCH] Fix bug in auto rotate option code.

---
 ChangeLog       | 742 ++++++++++++++++++++++++------------------------
 tools/tiff2ps.c |  12 +-
 2 files changed, 384 insertions(+), 370 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8696d6ef..d4ecc953 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,16 @@
+2013-01-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+	* tools/tiff2ps.c:Fix bug in auto rotate option code. Once a
+	rotation angle was set by the auto rotate check, it was retained
+	for all pages that followed instead of being retested for each
+	page.  Patch by Richard Nolde.
+
 2012-12-12  Tom Lane  <tgl@sss.pgh.pa.us>
 
 	* libtiff/tif_print.c: Back-patch recent fixes in
 	TIFFPrintDirectory to make it handle field_passcount fields sanely
 	for both TIFF_VARIABLE and TIFF_VARIABLE2 cases.
-	
+
 2012-12-10  Tom Lane  <tgl@sss.pgh.pa.us>
 
 	* tools/ppm2tiff.c: Back-patch fix for CVE-2012-4564.
@@ -52,7 +59,7 @@
 
 	* libtiff/tif_dirread.c: Avoid trusting samplesperpixel's default
 	of 1 for purposes of trimming tags.  This is to get some super
-	crappy OJPEG files to work again.  Grr. 
+	crappy OJPEG files to work again.  Grr.
 	http://bugzilla.maptools.org/show_bug.cgi?id=2348
 
 2012-06-01  Frank Warmerdam  <warmerdam@google.com>
@@ -122,8 +129,8 @@
 	* libtiff/tiffiop.h: avoid declaring int64/uint64 on AIX with XLC
 	where they are already available.  (#2301)
 
-	* libtiff/tif_thunder.c: Correct potential buffer overflow with 
-	thunder encoded files with wrong bitspersample set.  The libtiff 
+	* libtiff/tif_thunder.c: Correct potential buffer overflow with
+	thunder encoded files with wrong bitspersample set.  The libtiff
 	development team would like to thank Marin Barbella and TippingPoint's
 	Zero Day Initiative for reporting this vulnerability (ZDI-CAN-1004,
 	CVE-2011-1167).
@@ -131,18 +138,18 @@
 
 2011-03-10  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_fax3.h: Fix to last change allowing zero length 
+	* libtiff/tif_fax3.h: Fix to last change allowing zero length
 	runs at the start of a scanline - needed for legal cases.
 
 2011-03-02  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_fax3.h: Protect against a fax VL(n) codeword commanding 
-	a move left.  Without this, a malicious input file can generate an 
-	indefinitely large series of runs without a0 ever reaching the right 
+	* libtiff/tif_fax3.h: Protect against a fax VL(n) codeword commanding
+	a move left.  Without this, a malicious input file can generate an
+	indefinitely large series of runs without a0 ever reaching the right
 	margin, thus overrunning our buffer of run lengths.  Per CVE-2011-0192.
-	This is a modified version of a patch proposed by Drew Yao of Apple 
-	Product Security.  It adds an unexpected() report, and disallows the 
-	equality case, since emitting a run without increasing a0 still allows 
+	This is a modified version of a patch proposed by Drew Yao of Apple
+	Product Security.  It adds an unexpected() report, and disallows the
+	equality case, since emitting a run without increasing a0 still allows
 	buffer overrun.
 
 2011-02-25  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -154,7 +161,7 @@
 2011-01-03  Lee Howard <faxguy@howardsilvan.com>
 
 	* libtiff/tif_jpeg.c: Fix regressions with 2 and 3 band images
-	caused by commit on 2010-12-14.  Submitted by e-mail from 
+	caused by commit on 2010-12-14.  Submitted by e-mail from
 	Even Rouault <even.rouault@mines-paris.org>
 
 2010-12-31  Olivier Paquet  <olivier.paquet@gmail.com>
@@ -209,13 +216,13 @@
 
 2010-12-12  Lee Howard <faxguy@howardsilvan.com>
 
-	* tools/tiff2pdf.c: fix colors for images with RGBA 
+	* tools/tiff2pdf.c: fix colors for images with RGBA
 	interleaved data
 	http://bugzilla.maptools.org/show_bug.cgi?id=2250
 
 2010-12-11  Lee Howard <faxguy@howardsilvan.com>
 
-	* tools/tiff2pdf.c: remove invalid duplication for Lab 
+	* tools/tiff2pdf.c: remove invalid duplication for Lab
 	http://bugzilla.maptools.org/show_bug.cgi?id=2162
 
 2010-12-11  Lee Howard <faxguy@howardsilvan.com>
@@ -257,7 +264,7 @@
 
 2010-12-07  Lee Howard <faxguy@howardsilvan.com>
 
-	* libtiff/tif_jpeg.c, libtiff/tif_strip.c: apply patch for 
+	* libtiff/tif_jpeg.c, libtiff/tif_strip.c: apply patch for
 	CVE-2010-3087 per bug
 	http://bugzilla.maptools.org/show_bug.cgi?id=2140
 
@@ -269,7 +276,7 @@
 2010-09-25  Lee Howard <faxguy@howardsilvan.com>
 
 	* tools/tiff2ps.c: improvements and enhancements from Richard Nolde
-	with additional command line options for Document Title, 
+	with additional command line options for Document Title,
 	Document Creator, and Page Orientation
 
 2010-07-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
@@ -370,14 +377,14 @@
 	* libtiff/tif_dirread.c: Fixed bad handling of out of order tags
 	definated late by a codec (#2210)
 
-	* libtiff/tif_dirread.c: Fixed inadequate validation of the 
+	* libtiff/tif_dirread.c: Fixed inadequate validation of the
 	SubjectDistance field (#2212).
 
-	* tiff2pdf.c: Fix assorted bugs in tiff2pdf: missing "return" 
-	in t2p_read_tiff_size() causes t2p->tiff_datasize to be set entirely 
-	wrong for COMPRESSION_JPEG case, resulting in memory stomp if actual 
-	size is larger.  Also, there are a bunch of places that try to 
-	memset() a malloc'd buffer before checking for malloc failure, which 
+	* tiff2pdf.c: Fix assorted bugs in tiff2pdf: missing "return"
+	in t2p_read_tiff_size() causes t2p->tiff_datasize to be set entirely
+	wrong for COMPRESSION_JPEG case, resulting in memory stomp if actual
+	size is larger.  Also, there are a bunch of places that try to
+	memset() a malloc'd buffer before checking for malloc failure, which
 	would result in core dump if there actually were a failure. (#2211)
 
 2010-06-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
@@ -473,13 +480,13 @@
 
 2010-05-07  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_jpeg.c: Ensure that quality is always set in 
-	JPEGPreEncode(), not just when we want to output local tables.  
+	* libtiff/tif_jpeg.c: Ensure that quality is always set in
+	JPEGPreEncode(), not just when we want to output local tables.
 	Otherwise the quality used during compression may not be right and
 	might not match the tables in the tables tag.   This bug only occurs
 	when seeking between directories in the midst of writing blocks.
 	http://trac.osgeo.org/gdal/ticket/3539
-	
+
 2010-05-05  Olivier Paquet  <olivier.paquet@gmail.com>
 
 	* libtiff/tif_print.c: Have TIFFTAG_REFERENCEBLACKWHITE always print 6
@@ -497,11 +504,11 @@
 2010-02-22  Lee Howard  <faxguy@howardsilvan.com>
 
 	* libtiff/tif_jpeg.c: Do not generate a JPEGTables tag when creating
-	the JPEG TIFF as is is not required in order to prevent it from 
-	being unused and filled with invalid data.  (Leave it to be 
+	the JPEG TIFF as is is not required in order to prevent it from
+	being unused and filled with invalid data.  (Leave it to be
 	generated by later activity.)
 	http://bugzilla.maptools.org/show_bug.cgi?id=2135
-	* tools/tiff2pdf.c: Write the JPEG SOI headers into the TIFF strip 
+	* tools/tiff2pdf.c: Write the JPEG SOI headers into the TIFF strip
 	data rather than skipping them.  This fixes the ability to view in
 	Acrobat Reader, Evince, and Ghostscript.
 	http://bugzilla.maptools.org/show_bug.cgi?id=2135
@@ -512,13 +519,13 @@
 2010-01-06  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_dir.c: Ensure tile and scanline sizes are reset
-	when moving to new directories. 
+	when moving to new directories.
 	http://bugzilla.maptools.org/show_bug.cgi?id=1936
 
 2009-12-03  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_jpeg.c: Fix a couple of issues that trigger failures in
-	some cases when using TIFFReadScanline() with JPEG compressed 
+	some cases when using TIFFReadScanline() with JPEG compressed
 	subsampled ycbcr images.
 	http://bugzilla.maptools.org/show_bug.cgi?id=1936
 
@@ -631,7 +638,7 @@
 
 2009-06-22  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_lzw.c: Fix buffer underflow bug. 
+	* libtiff/tif_lzw.c: Fix buffer underflow bug.
 	http://bugzilla.maptools.org/show_bug.cgi?id=2065
 
 2009-06-03  Frank Warmerdam  <warmerdam@pobox.com>
@@ -642,7 +649,7 @@
 
 2009-02-12  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_luv.c: Fix handling of tiled logluv images. 
+	* libtiff/tif_luv.c: Fix handling of tiled logluv images.
 	http://bugzilla.maptools.org/show_bug.cgi?id=2005
 
 2009-01-23  Frank Warmerdam  <warmerdam@pobox.com>
@@ -656,7 +663,7 @@
 
 2009-01-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-	* tools/tiff2ps.c: Remove spurious message printed to stderr. 
+	* tools/tiff2ps.c: Remove spurious message printed to stderr.
 
 2009-01-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
@@ -689,7 +696,7 @@
 2008-12-31  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* tools/tiffcrop.c, man/tiffcrop.1: A major update from Richard
-	Nolde.  
+	Nolde.
 
 2008-12-21  Frank Warmerdam  <warmerdam@pobox.com>
 
@@ -699,7 +706,7 @@
 
 2008-12-21  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_getimage.c, tiffio.h: More ABI corrections. 
+	* libtiff/tif_getimage.c, tiffio.h: More ABI corrections.
 	Removed SubsamplingHor/Ver from TIFFRGBAImage structure.
 	  http://bugzilla.maptools.org/show_bug.cgi?id=1980
 
@@ -740,15 +747,15 @@
 
 2008-05-24  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* tif_codec.c: Avoid NULL pointer dereferencing for exotic 
+	* tif_codec.c: Avoid NULL pointer dereferencing for exotic
 	compression codec codes.
 
 	* tif_dirread.c: zero tif->tif_dir after freeing the directory
 	in TIFFReadCustomDirectory().  I don't exactly remember why this
-	was important. 
+	was important.
 
 	* tif_dirwrite.c: Fix potential memory leak writing large double
-	tags. 
+	tags.
 
 	* tif_dirread.c: Fix unchecked malloc result.
 
@@ -768,12 +775,12 @@
 
 2007-11-22  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* tif_write.c: Rip out the fancy logic in TIFFAppendToStrip() for 
-	establishing if an existing tile can be rewritten to the same location 
-	by comparing the current size to all the other blocks in the same 
-	directory.  This is dangerous in many situations and can easily 
+	* tif_write.c: Rip out the fancy logic in TIFFAppendToStrip() for
+	establishing if an existing tile can be rewritten to the same location
+	by comparing the current size to all the other blocks in the same
+	directory.  This is dangerous in many situations and can easily
 	corrupt a file.  (observed in esoteric GDAL situation that's hard to
-	document).  This change involves leaving the stripbytecount[] values 
+	document).  This change involves leaving the stripbytecount[] values
 	unaltered till TIFFAppendToStrip().  Now we only write a block back
 	to the same location it used to be at if the new data is the same
 	size or smaller - otherwise we move it to the end of file.
@@ -781,17 +788,17 @@
 	* tif_dirwrite.c: Try to avoid writing out a full readbuffer of tile
 	data when writing the directory just because we have BEENWRITING at
 	some point in the past.  This was causing odd junk to be written out
-	in a tile of data when a single tile had an interleaving of reading 
-	and writing with reading last.  (highlighted by gdal 
-	autotest/gcore/tif_write.py test 7. 
+	in a tile of data when a single tile had an interleaving of reading
+	and writing with reading last.  (highlighted by gdal
+	autotest/gcore/tif_write.py test 7.
 
 	* tif_predict.c: use working buffer in PredictorEncodeTile to avoid
-	modifying callers buffer. 
+	modifying callers buffer.
 	http://trac.osgeo.org/gdal/ticket/1965
 
-	* tif_predict.c/h, tif_lzw.c, tif_zip.c: Improvements so that 
+	* tif_predict.c/h, tif_lzw.c, tif_zip.c: Improvements so that
 	predictor based encoding and decoding works in read-write update
-	mode properly. 
+	mode properly.
 	http://trac.osgeo.org/gdal/ticket/1948
 
 2007-10-05  Frank Warmerdam  <warmerdam@pobox.com>
@@ -806,7 +813,7 @@
 
 2007-07-18  Andrey Kiselev  <dron@ak4719.spb.edu>
 
-	* libtiff/{Makefile.am, Makefile.v}: Do not distribute tiffconf.h, 
+	* libtiff/{Makefile.am, Makefile.v}: Do not distribute tiffconf.h,
 	remove tif_config.h/tiffconf.h during cleaning. As per bug
 
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1573
@@ -824,14 +831,13 @@
 2007-07-03  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* tools/tiff2ps.c:  Added support 16-bit images as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1566
 
 	Patch from William Bader.
 
 	* tools/tiff2pdf.c: Fix for TIFFTAG_JPEGTABLES tag fetching and
 	significant upgrade of the whole utility as per bug
-	
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1560
 
 	Now we don't need tiffiop.h in tiff2pdf anymore and will open output
@@ -849,7 +855,7 @@
 
 	* libtiff/tif_dirwrite.c: Fixed problem introduced with a fix for a
 	byte swapping issue
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1363
 
 	As per bug
@@ -867,7 +873,7 @@
 	* libtiff/{tif_dir.h, tif_dirread.c, tif_dirinfo.c, tif_jpeg.c,
 	tif_fax3.c, tif_jbig.c, tif_luv.c, tif_ojpeg.c, tif_pixarlog.c,
 	tif_predict.c, tif_zip.c}: Finally fix bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1274
 
 	by introducing _TIFFMergeFieldInfo() returning integer error status
@@ -878,7 +884,7 @@
 
 2007-04-07  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* contrib/addtiffo/tif_overview.c: Fix problems with odd sized output 
+	* contrib/addtiffo/tif_overview.c: Fix problems with odd sized output
 	blocks in TIFF_DownSample_Subsampled() (bug 1542).
 
 2007-04-06  Frank Warmerdam  <warmerdam@pobox.com>
@@ -886,20 +892,20 @@
 	* libtiff/tif_jpeg.c: Changed JPEGInitializeLibJPEG() so that it
 	will convert from decompressor to compressor or compress to decompress
 	if required by the force arguments.  This works around a problem in
-	where the JPEGFixupTestSubsampling() may cause a decompressor to 
+	where the JPEGFixupTestSubsampling() may cause a decompressor to
 	be setup on a directory when later a compressor is required with the
-	force flag set.  Occurs with the addtiffo program for instance. 
+	force flag set.  Occurs with the addtiffo program for instance.
 
 2007-04-06  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* libtiff/tif_dirwrite.c: Fixed swapping of byte arrays stored
 	in-place in tag offsets as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1363
 
 	* tools/tiffcrop.c, man/tiffcrop.1: Significant update in
 	functionality from Richard Nolde. As per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1525
 
 2007-03-28  Frank Warmerdam  <warmerdam@pobox.com>
@@ -907,15 +913,15 @@
 	* libtiff/tif_fax3.c: "inline static" -> "static inline" for IRIC CC.
 
 2007-03-07  Joris Van Damme  <joris.at.lebbeke@skynet.be>
-	
+
 	* libtiff/tif_getimage.c: workaround for 'Fractional scanline' error reading
 	OJPEG images with rowsperstrip that is not a multiple of vertical subsampling
 	factor. This bug is mentioned in:
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1390
-	http://www.asmail.be/msg0054766825.html 
+	http://www.asmail.be/msg0054766825.html
 
 2007-03-07  Joris Van Damme  <joris.at.lebbeke@skynet.be>
-	
+
 	* libtiff/tif_win32.c: made inclusion of windows.h unconditional
 
 	* libtiff/tif_win32.c: replaced preprocessor indication for consiously
@@ -965,14 +971,14 @@
 	larger than 2GB. Fixes bug
 
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=890
-	
+
 	Idea submitted by Matt Hancher.
 
 2007-01-31  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* tools/tif2rgba.c: This utility does not work properly on big-endian
 	architectures. It was fixed including the bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1149
 
 2007-01-15  Mateusz Loskot <mateusz@loskot.net>
@@ -989,15 +995,15 @@
 
 2006-11-19  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_write.c: TIFFAppendToStrip() - clear sorted flag if 
-	we move a strip. 
-	http://bugzilla.remotesensing.org/show_bug.cgi?id=1359	
+	* libtiff/tif_write.c: TIFFAppendToStrip() - clear sorted flag if
+	we move a strip.
+	http://bugzilla.remotesensing.org/show_bug.cgi?id=1359
 
 2006-10-13  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* libtiff/tif_dir.c: More fixes for vulnerabilities, reported
 	in Gentoo bug ():
-	
+
 	http://bugs.gentoo.org/show_bug.cgi?id=142383
 
 	* libtiff/contrib/dbs/xtiff/xtiff.c: Make xtiff utility compilable.
@@ -1031,12 +1037,12 @@
 	* libtiff/tif_lzw.c, libtiff/tif_zip.c: Fixed problems with mixing
 	encoding and decoding on the same read-write TIFF handle.  The LZW
 	code can now maintain encode and decode state at the same time. The
-	ZIP code will switch back and forth as needed.  
+	ZIP code will switch back and forth as needed.
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=757
 
 2006-09-20  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff: Rename config.h.vc and tif_config.h.vc to config.vc.h and 
+	* libtiff: Rename config.h.vc and tif_config.h.vc to config.vc.h and
 	tif_config.vc.h for easier identification by folks using an IDE.
 
 2006-07-25  Frank Warmerdam  <warmerdam@pobox.com>
@@ -1051,7 +1057,7 @@
 
 2006-07-12  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* tif_dirwrite.c: make sure to use uint32 for wordcount in 
+	* tif_dirwrite.c: make sure to use uint32 for wordcount in
 	TIFFWriteNormanTag if writecount is VARIABLE2 for ASCII fields.
 	It already seems to have been done for other field types.  Needed
 	for "tiffset" on files with geotiff ascii text.
@@ -1079,9 +1085,9 @@
 2006-06-17  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* tif_readdir.c: Added case in EstimateStripByteCounts() for tiled
-	files.  Modified TIFFReadDirectory() to not invoke 
+	files.  Modified TIFFReadDirectory() to not invoke
 	EstimateStripByteCounts() for case where entry 0 and 1 are unequal
-	but one of them is zero. 
+	but one of them is zero.
 	  http://bugzilla.remotesensing.org/show_bug.cgi?id=1204
 
 2006-06-08  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -1109,7 +1115,7 @@
 	* {configure, configure.ac, libtiff/tif_jbig.c, tools/tiffcp.c}: Added
 	support for JBIG compression scheme (34661 code) contributed by Lee
 	Howard. As per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=896
 
 	* configure, configure.ac: OJPEG support enabled by default.
@@ -1148,7 +1154,7 @@
 2006-04-18  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* nmake.opt: use /EHsc for VS2005 compatibility.  Also define
-	_CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005. 
+	_CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005.
 
 2006-04-12  Joris Van Damme  <joris.at.lebbeke@skynet.be>
 
@@ -1156,7 +1162,7 @@
 	non-subsampled YCbCr (i.e. separate YCbCr with subsampling [1,1])
 
 2006-04-11  Joris Van Damme  <joris.at.lebbeke@skynet.be>
-	
+
 	* libtiff/tif_getimage.c: Revision of all RGB(A) put routines
 	- Conversion of unassociated alpha to associated alpha now done with
 	  more performant LUT, and calculation more correct
@@ -1165,21 +1171,21 @@
 	- Bugfix of handling of 16bit RGB with unassociated alpha
 
 2006-04-11  Joris Van Damme  <joris.at.lebbeke@skynet.be>
-	
-	* libtiff/tif_getimage.c: 
-	- When there is no alpha, gtTileSeparate and gtStripSeparate allocated 
-	  buffer for alpha strile and filled it, only to never read it back. 
+
+	* libtiff/tif_getimage.c:
+	- When there is no alpha, gtTileSeparate and gtStripSeparate allocated
+	  buffer for alpha strile and filled it, only to never read it back.
 	  Removed allocation and fill.
-	- Minor rename of vars in gtTileSeparate and gtStripSeparate 
+	- Minor rename of vars in gtTileSeparate and gtStripSeparate
 	  anticipating planned functionality extension
 
 2006-04-08  Joris Van Damme  <joris.at.lebbeke@skynet.be>
 
-	* libtiff/tif_getimage.c: renamed pickTileContigCase to PickContigCase 
-	and pickTileSeparateCase to PickSeparateCase as both work on strips as 
+	* libtiff/tif_getimage.c: renamed pickTileContigCase to PickContigCase
+	and pickTileSeparateCase to PickSeparateCase as both work on strips as
 	well
 
-	* libtiff/tif_getimage.c: moved img->get selection from 
+	* libtiff/tif_getimage.c: moved img->get selection from
 	TIFFRGBAImageBegin into PickContigCase and PickSeparateCase to create
 	logical hook for planned functionality extension
 
@@ -1190,9 +1196,9 @@
 
 2006-04-07  Joris Van Damme  <joris.at.lebbeke@skynet.be>
 
-	* libtiff/tif_getimage.c: replaced usage of TIFFScanlineSize in 
+	* libtiff/tif_getimage.c: replaced usage of TIFFScanlineSize in
 	gtStripContig with TIFFNewScanlineSize so as to fix buggy behaviour
-	on subsampled images - this ought to get sorted when we feel brave 
+	on subsampled images - this ought to get sorted when we feel brave
 	enough to replace TIFFScanlineSize alltogether
 
 	* libtiff/tif_ojpeg.c: fixed bug in OJPEGReadSkip
@@ -1201,13 +1207,13 @@
 
 	* libtiff/tiffio.h: added new type tstrile_t
 
-	* libtiff/tif_dir.h: changed types of td_stripsperimage and td_nstrips 
-	to new tstrile_t, types of td_stripoffset and td_stripbytecount to 
+	* libtiff/tif_dir.h: changed types of td_stripsperimage and td_nstrips
+	to new tstrile_t, types of td_stripoffset and td_stripbytecount to
 	toff_t*
 
 	* libtiff/tif_ojpeg.c: totally new implementation
 
-	* libtiff/tif_dirread.c: added several hacks to suit new support of 
+	* libtiff/tif_dirread.c: added several hacks to suit new support of
 	OJPEG
 
 	* libtiff/tif_getimage.c: removed TIFFTAG_JPEGCOLORMODE handling
@@ -1247,7 +1253,7 @@
 
 	* libtiff/tif_getimage.c: added putcontig8bitYCbCr12tile
 
-	* libtiff/tif_read.c: added support for new TIFF_NOREADRAW flag to 
+	* libtiff/tif_read.c: added support for new TIFF_NOREADRAW flag to
 	prepare	the path for new tif_ojpeg.c
 
 2006-03-23  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -1363,7 +1369,7 @@
 
 	* libtiff/tif_write.c: Small code rearrangement in TIFFWriteScanline()
 	to avoid crash as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1081.
 
 2006-02-26  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -1413,7 +1419,7 @@
 2006-02-07  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* tools/tiff2pdf.c: Fixed support for non-YCbCr encoded JPEG
-	compressed TIFF files, per submission from Dan Cobra. 
+	compressed TIFF files, per submission from Dan Cobra.
 
 2006-02-07  Andrey Kiselev  <dron@ak4719.spb.edu>
 
@@ -1445,7 +1451,7 @@
 
 	* libtiff/tif_dirread.c: Use _TIFFGetExifFieldInfo() instead of
 	_TIFFGetFieldInfo() in TIFFReadEXIFDirectory() call as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1026.
 
 2006-01-23  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -1511,7 +1517,7 @@
 
 2005-12-26  Andrey Kiselev  <dron@ak4719.spb.edu>
 
-	* libtiff/{tif_dir.c, tif_dir.h, tif_dirread.c, tif_dirinfo.c}: 
+	* libtiff/{tif_dir.c, tif_dir.h, tif_dirread.c, tif_dirinfo.c}:
 	tiffFieldInfo and exifFieldInfo arrays definitions moved back to
 	tif_dirinfo.c; added _TIFFGetFieldInfo() and _TIFFGetExifFieldInfo()
 	private functions to retrieve FieldInfo arrays.
@@ -1538,10 +1544,10 @@
 
 2005-12-23  Joris Van Damme  <joris.at.lebbeke@skynet.be>
 
-	* libtiff/tiffio.h: fixed typo that potentially resulted in 
+	* libtiff/tiffio.h: fixed typo that potentially resulted in
 	redefininition of USE_WIN32_FILEIO
 
-	* libtiff/*: Added more 'dual-mode' error handling: Done TIFFWarning 
+	* libtiff/*: Added more 'dual-mode' error handling: Done TIFFWarning
 	calls in core LibTiff.
 
 2005-12-21  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -1551,10 +1557,10 @@
 
 2005-12-21  Joris Van Damme  <joris.at.lebbeke@skynet.be>
 
-	* libtiff/*, contrib/*: Added 'dual-mode' error handling, enabling 
+	* libtiff/*, contrib/*: Added 'dual-mode' error handling, enabling
 	newer code to get context indicator in error handler and still
-	remain compatible with older code: Done TIFFError calls everywhere 
-	except in tools   
+	remain compatible with older code: Done TIFFError calls everywhere
+	except in tools
 
 2005-12-20  Andrey Kiselev  <dron@ak4719.spb.edu>
 
@@ -1627,7 +1633,7 @@
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=1002
 
 	* .cvsignore: many files added, and a few update according
-	to suggestion of Brad HArds on tiff mailing list. 
+	to suggestion of Brad HArds on tiff mailing list.
 
 2005-11-03  Frank Warmerdam  <warmerdam@pobox.com>
 
@@ -1652,7 +1658,7 @@
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=946
 
 	* tools/bmp2tiff.c: Fixed possible integer overflow error as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=965
 
 	* libtiff/tif_dirinfo.c: Make XResolution, YResolution and
@@ -1662,7 +1668,7 @@
 
 	* tools/tiffsplit.c: Copy fax related fields over splitted parts
 	as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=983
 
 2005-10-21  Frank Warmerdam  <warmerdam@pobox.com>
@@ -1718,7 +1724,7 @@
 
 	* libtiff/tif_dir.c: When prefreeing tv->value in TIFFSetFieldV
 	also set it to NULL to avoid double free when re-setting custom
-	string fields as per: 
+	string fields as per:
 
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=922
 
@@ -1754,7 +1760,7 @@
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=831
 
 	Remove TIFFFetchExtraSamples() function, use TIFFFetchNormalTag()
-	instead. 
+	instead.
 
 	* libtiff/tiffconf.h.in: One more attempt to fix the AIX bug
 
@@ -1925,7 +1931,7 @@
 
 2005-05-22  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_dirread.c: Changed the code that computes 
+	* libtiff/tif_dirread.c: Changed the code that computes
 	stripbytecount[0] if it appears bogus to ignore if stripoffset[0] is
 	zero. This is a common case with GDAL indicating a "null" tile/strip.
 
@@ -1935,8 +1941,8 @@
 
 2005-05-06  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_dirread.c: Applied similar change to 
-	TIFFFetchPerSampleLongs and TIFFFetchPerSampleAnys. 
+	* libtiff/tif_dirread.c: Applied similar change to
+	TIFFFetchPerSampleLongs and TIFFFetchPerSampleAnys.
 
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=843
 
@@ -1986,7 +1992,7 @@
 
 	* man/TIFFSetField.3tiff: Fixed definition of the TIFFTAG_INKNAMES tag
 	as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=816
 
 2005-03-30  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -2096,7 +2102,7 @@
 
 	* libtiff/tiffio.h: Move TIFFOpenW() function into the extern "C"{}
 	block as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=763
 
 2005-02-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
@@ -2117,7 +2123,7 @@
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=320
 
 	* tools/tiff2ps.c: Fixed problem with page sizes as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=742
 
 2005-01-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
@@ -2158,7 +2164,7 @@
 	TIFFRGBAImageBegin() as per bug
 
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=739
-	
+
 2005-01-12  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* libtiff/tif_jpeg.c: Added ability to read/write the fax specific
@@ -2187,7 +2193,7 @@
 	* libtiff/tiff.h: Restore back the workaround for AIX Visual Age C
 	compiler to avoid double definition of BSD types as per bug
 
-	http://bugzilla.remotesensing.org/show_bug.cgi?id=39	
+	http://bugzilla.remotesensing.org/show_bug.cgi?id=39
 
 	* libtiff/Makefile.am: Place the C++ stream API in the separate
 	library called libtiffxx to avoid unneeded dependencies. Probably
@@ -2211,7 +2217,7 @@
 
 	* libtiff/tif_getimage.c: More fixes for multiple-alpha-channelled
 	RGB-images as per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=713
 
 
@@ -2247,7 +2253,7 @@
 2004-12-15  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_getimage.c: #define A1 bracketing for clean build on
-	SunPro compiler. 
+	SunPro compiler.
 
 2004-12-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
@@ -2259,7 +2265,7 @@
 
 	* libtiff/tif_dirwrite.c: Always write TIFFTAG_SUBIFD using LONG type
 	as per bugs
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=703
 
 	and
@@ -2279,9 +2285,9 @@
 
 	* libtiff/tif_config.in.vc: Removed unneded definitions for
 	read/open/close/lseek functions to fix the
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=680
-	
+
 2004-12-03  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* libtiff/{tif_dir.c, tif_dirread.c}: Remove TIFFReassignTagToIgnore()
@@ -2317,7 +2323,7 @@
 
 2004-11-26  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/makefile.vc: make it easier to rename the libtiff DLL. 
+	* libtiff/makefile.vc: make it easier to rename the libtiff DLL.
 
 2004-11-24  Andrey Kiselev  <dron@ak4719.spb.edu>
 
@@ -2414,7 +2420,7 @@
 	per bug
 
 	 http://bugzilla.remotesensing.org/show_bug.cgi?id=648
-	
+
 	* libtiff/{tif_jpeg.c, tif_ojpeg.c}: TIFFTAG_JPEGTABLES should have
 	uint32 count. Use this type everywhere.
 
@@ -2427,7 +2433,7 @@
 	* tools/tiff2rgba.c: removed extra newlines in usage message.
 
 2004-10-30  Andrey Kiselev  <dron@ak4719.spb.edu>
-	
+
 	* libtiff/tif_dirwrite.c: Improvements in tag writing code.
 
 	* tools/tiff2ps.c: Fixed wrong variable data type when read Position
@@ -2442,7 +2448,7 @@
 
 	* libtiff/tif_fax3.c: Fixed case with the wrong decode routines
 	choosing when the incorrect Group4Options tag set. As per bug
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=323
 
 	* libtiff/tif_dirwrite.c: Fixed problem with passing count variable of
@@ -2461,7 +2467,7 @@
 	* tools/tiff2pdf.c: added casts to avoid warnings.
 
 	* libtiff/libtiff.def: Added several more entry points required
-	to link fax2tiff.c against the DLL on windows. 
+	to link fax2tiff.c against the DLL on windows.
 
 2004-10-27  Andrey Kiselev  <dron@ak4719.spb.edu>
 
@@ -2532,7 +2538,7 @@
 2004-10-08  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_dirinfo.c: Fix bug with tif_foundfield and reallocation
-	of tif_fieldinfo.  
+	of tif_fieldinfo.
 
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=630
 
@@ -2564,7 +2570,7 @@
 
 2004-09-30  Frank Warmerdam  <warmerdam@pobox.com>
 
-	* libtiff/tif_dirinfo.c: changed type of XMLPacket (tag 700) to 
+	* libtiff/tif_dirinfo.c: changed type of XMLPacket (tag 700) to
 	TIFFTAG_BYTE instead of TIFFTAG_UNDEFINED to comply with the info
 	in the Adobe XMP Specification.
 
@@ -2584,7 +2590,7 @@
 2004-09-26  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* libtiff/{tif_dir.h, tif_dir.c, tif_dirread.c, tif_write.c}:
-	Optimize checking for the strip bounds. 
+	Optimize checking for the strip bounds.
 
 	* libtiff/{tif_dirread.c, tif_strip.c}: TIFFScanlineSize() and
 	TIFFRasterScanlineSize() functions report zero in the case of integer
@@ -2735,7 +2741,7 @@
 	here
 
 	http://www.asmail.be/msg0054799560.html
-	
+
 	for details.
 
 	* tools/fax2tiff.c: Use the new functions in the code.
@@ -2863,11 +2869,11 @@
 	* tools/tiffsplit.c: Fixed problem with unproperly written multibyte
 	files. Now output files will be written using the same byte order
 	flag as	in the input image. See
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=574
-	
+
 	for details.
-	
+
 2004-05-19  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_print.c: added (untested) support for printing
@@ -2879,7 +2885,7 @@
 
 	* libtiff/tif_fax3.c: Avoid reading CCITT compression options
 	if compression type mismatches. See
-	
+
 	http://bugzilla.remotesensing.org/show_bug.cgi?id=565
 
 2004-04-30  Andrey Kiselev  <dron@ak4719.spb.edu>
@@ -2924,7 +2930,7 @@
 2004-04-04  Frank Warmerdam  <warmerdam@pobox.com>
 
 	* libtiff/tif_open.c: close clientdata if TIFFClientOpen() fails
-	via bad2. 
+	via bad2.
 
 2004-03-26  Andrey Kiselev  <dron@ak4719.spb.edu>
 
@@ -2951,10 +2957,1

(Patch may be truncated, please check the link at the top of this post.)