From e4f269ed3f3d57d027f0a51df57ac94d06250e00 Mon Sep 17 00:00:00 2001 From: Olivier Paquet Date: Mon, 20 Oct 2014 17:52:05 +0000 Subject: [PATCH] * tools/tiff2pdf.c: Preserve input file directory order when pages are tagged with the same page number. --- ChangeLog | 4 ++++ tools/tiff2pdf.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53e89c1f..9ceeced5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-10-20 Olivier Paquet + * tools/tiff2pdf.c: Preserve input file directory order when pages + are tagged with the same page number. + 2014-08-31 Bob Friesenhahn * libtiff/tif_dirread.c (TIFFReadDirEntryOutputErr): Incorrect diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index e79c971c..b7e2d0e4 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -1,4 +1,4 @@ -/* $Id: tiff2pdf.c,v 1.73 2013-09-20 15:35:37 faxguy Exp $ +/* $Id: tiff2pdf.c,v 1.74 2014-10-20 17:52:05 olivier Exp $ * * tiff2pdf - converts a TIFF image to a PDF document * @@ -1197,12 +1197,18 @@ void t2p_read_tiff_init(T2P* t2p, TIFF* input){ /* * This function is used by qsort to sort a T2P_PAGE* array of page structures - * by page number. + * by page number. If the page numbers are the same, we fall back to comparing + * directory numbers to preserve the order of the input file. */ int t2p_cmp_t2p_page(const void* e1, const void* e2){ - return( ((T2P_PAGE*)e1)->page_number - ((T2P_PAGE*)e2)->page_number ); + int d; + d = (int32)(((T2P_PAGE*)e1)->page_number) - (int32)(((T2P_PAGE*)e2)->page_number); + if(d == 0){ + d = (int32)(((T2P_PAGE*)e1)->page_directory) - (int32)(((T2P_PAGE*)e2)->page_directory); + } + return d; } /*