libtiff: Support the JBIG-KIT 2.0 (compatibility with the older versions retained).

From d5e1e0bf654311b6b1367a886dac3ea14aff7b3e Mon Sep 17 00:00:00 2001
From: Andrey Kiselev <[EMAIL REDACTED]>
Date: Tue, 21 Oct 2008 13:13:07 +0000
Subject: [PATCH] Support the JBIG-KIT 2.0 (compatibility with the older
 versions retained).

---
 ChangeLog          |  5 +++++
 libtiff/tif_jbig.c | 16 +++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e8b78f32..976792dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-21  Andrey Kiselev  <dron@ak4719.spb.edu>
+
+	* libtiff/tif_jbig.c: Support the JBIG-KIT 2.0 (compatibility with
+	the older versions retained).
+
 2008-09-05  Andrey Kiselev  <dron@ak4719.spb.edu>
 
 	* tools/tiffsplit.c: Use dynamically allocated array instead of static
diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c
index 794cf4ae..99183ba7 100644
--- a/libtiff/tif_jbig.c
+++ b/libtiff/tif_jbig.c
@@ -1,4 +1,4 @@
-/* $Id: tif_jbig.c,v 1.2.2.1 2007-04-07 14:58:30 dron Exp $ */
+/* $Id: tif_jbig.c,v 1.2.2.2 2008-10-21 13:13:07 dron Exp $ */
 
 /*
  * Copyright (c) 1988-1997 Sam Leffler
@@ -106,8 +106,18 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s)
                                   tif->tif_rawdatasize, NULL);
         if (JBG_EOK != decodeStatus)
         {
-                TIFFError("JBIG", "Error (%d) decoding: %s",
-                          decodeStatus, jbg_strerror(decodeStatus, JBG_EN));
+		/*
+		 * XXX: JBG_EN constant was defined in pre-2.0 releases of the
+		 * JBIG-KIT. Since the 2.0 the error reporting functions were
+		 * changed. We will handle both cases here.
+		 */
+                TIFFError("JBIG", "Error (%d) decoding: %s", decodeStatus,
+#if defined(JBG_EN)
+			  jbg_strerror(decodeStatus, JBG_EN)
+#else
+                          jbg_strerror(decodeStatus)
+#endif
+			 );
                 return 0;
         }