From ec18caeb67e751fb50b5777c9b4d7c9cf2a71683 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Mon, 21 Nov 2022 21:45:48 +0100
Subject: [PATCH] Remove TIFFSetErrorHandlerExtR() and
TIFFSetWarningHandlerExtR() that were temporarily added in master
---
doc/functions/TIFFError.rst | 7 +++----
doc/functions/TIFFWarning.rst | 16 ++--------------
libtiff/libtiff.def | 2 --
libtiff/libtiff.map | 2 --
libtiff/tif_error.c | 7 -------
libtiff/tif_warning.c | 7 -------
libtiff/tiffio.h | 2 --
test/test_error_handlers.c | 27 +++++++++------------------
8 files changed, 14 insertions(+), 56 deletions(-)
diff --git a/doc/functions/TIFFError.rst b/doc/functions/TIFFError.rst
index 3648db77..797c1c0e 100644
--- a/doc/functions/TIFFError.rst
+++ b/doc/functions/TIFFError.rst
@@ -23,10 +23,6 @@ Synopsis
.. c:function:: TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
-.. c:type:: int (*TIFFErrorHandlerExtR)(TIFF* tif, void* errorhandler_user_data, const char * module, const char* fmt, va_list ap)
-
-.. c:function:: void TIFFSetErrorHandlerExtR(TIFF* tif, TIFFErrorHandlerExtR handler, void* errorhandler_user_data)
-
Description
-----------
@@ -52,6 +48,9 @@ in order to write to a file. The file handle needs to be stored in
``tif->tif_clientdata`` if the ``libtiff`` internal errors shall also
be written to that file.
+Note that, starting with libtiff 4.5, a per-TIFF handler may also be installed
+with :c:func:`TIFFOpenExt` or :c:func:`TIFFClientOpenExt`
+
Note
----
diff --git a/doc/functions/TIFFWarning.rst b/doc/functions/TIFFWarning.rst
index 281341f0..2006696c 100644
--- a/doc/functions/TIFFWarning.rst
+++ b/doc/functions/TIFFWarning.rst
@@ -23,11 +23,6 @@ Synopsis
.. c:function:: TIFFWarningHandlerExt TIFFSetWarningHandlerExt(TIFFWarningHandlerExt handler)
-.. c:type:: int (*TIFFWarningHandlerExtR)(TIFF* tif, void* warnhandler_user_data, const char * module, const char* fmt, va_list ap)
-
-.. c:function:: void TIFFSetWarningHandlerExtR(TIFF* tif, TIFFWarningHandlerExtR handler, void* warnhandler_user_data)
-
-
Description
-----------
@@ -54,15 +49,8 @@ as *fd*, which represents the TIFF file handle (file descriptor).
With :c:func:`TIFFSetWarningHandlerExt` an extra warning handler can be
setup up.
-:c:func:`TIFFSetWarningHandlerExtR` (added in libtiff 4.5) installs a warning
-handler for a given TIFF handle. The R suffix means re-entrant, in that it avoids
-the global effects of :c:func:`TIFFSetWarningHandler` or :c:func:`TIFFSetWarningHandlerExt`.
-The installed handler replaces any previously set handler with that function.
-The handler should nominally return a non-0 value. If it returns 0, then the
-global handler set with :c:func:`TIFFSetWarningHandler` or :c:func:`TIFFSetWarningHandlerExt`
-will also be called.
-Note that this per-TIFF handler may also be installed with :c:func:`TIFFOpenExt`
-or :c:func:`TIFFClientOpenExt`
+Note that, starting with libtiff 4.5, a per-TIFF handler may also be installed
+with :c:func:`TIFFOpenExt` or :c:func:`TIFFClientOpenExt`
Note
----
diff --git a/libtiff/libtiff.def b/libtiff/libtiff.def
index 8ec0e031..975ad1fd 100644
--- a/libtiff/libtiff.def
+++ b/libtiff/libtiff.def
@@ -125,7 +125,6 @@ EXPORTS TIFFAccessTagMethods
TIFFSetDirectory
TIFFSetErrorHandler
TIFFSetErrorHandlerExt
- TIFFSetErrorHandlerExtR
TIFFSetField
TIFFSetFileName
TIFFSetFileno
@@ -134,7 +133,6 @@ EXPORTS TIFFAccessTagMethods
TIFFSetTagExtender
TIFFSetWarningHandler
TIFFSetWarningHandlerExt
- TIFFSetWarningHandlerExtR
TIFFSetWriteOffset
TIFFSetupStrips
TIFFStripSize
diff --git a/libtiff/libtiff.map b/libtiff/libtiff.map
index e9523352..c811a751 100644
--- a/libtiff/libtiff.map
+++ b/libtiff/libtiff.map
@@ -208,8 +208,6 @@ LIBTIFF_4.5 {
TIFFOpenWExt;
TIFFErrorExtR;
TIFFWarningExtR;
- TIFFSetErrorHandlerExtR;
- TIFFSetWarningHandlerExtR;
TIFFOpenOptionsAlloc;
TIFFOpenOptionsFree;
TIFFOpenOptionsSetErrorHandlerExtR;
diff --git a/libtiff/tif_error.c b/libtiff/tif_error.c
index ed8e1de4..4065d60a 100644
--- a/libtiff/tif_error.c
+++ b/libtiff/tif_error.c
@@ -77,13 +77,6 @@ TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
}
}
-void TIFFSetErrorHandlerExtR(TIFF* tif, TIFFErrorHandlerExtR handler, void* errorhandler_user_data) {
- if (tif) {
- tif->tif_errorhandler_user_data = errorhandler_user_data;
- tif->tif_errorhandler = handler;
- }
-}
-
void _TIFFErrorEarly(TIFFOpenOptions* opts, thandle_t clientdata, const char* module, const char* fmt, ...)
{
va_list ap;
diff --git a/libtiff/tif_warning.c b/libtiff/tif_warning.c
index d952bdfd..29e26bec 100644
--- a/libtiff/tif_warning.c
+++ b/libtiff/tif_warning.c
@@ -77,13 +77,6 @@ TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...)
}
}
-void TIFFSetWarningHandlerExtR(TIFF* tif, TIFFErrorHandlerExtR handler, void* warnhandler_user_data) {
- if (tif) {
- tif->tif_warnhandler_user_data = warnhandler_user_data;
- tif->tif_warnhandler = handler;
- }
-}
-
void TIFFWarningExtR(TIFF* tif, const char* module, const char* fmt, ...)
{
va_list ap;
diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h
index 6523c048..7d12a88c 100644
--- a/libtiff/tiffio.h
+++ b/libtiff/tiffio.h
@@ -460,8 +460,6 @@ extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt);
-extern void TIFFSetErrorHandlerExtR(TIFF*, TIFFErrorHandlerExtR, void* errorhandler_user_data);
-extern void TIFFSetWarningHandlerExtR(TIFF*, TIFFErrorHandlerExtR, void* warnhandler_user_data);
extern void TIFFWarningExtR(TIFF*, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4)));
extern void TIFFErrorExtR(TIFF*, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4)));
diff --git a/test/test_error_handlers.c b/test/test_error_handlers.c
index d1ba0587..f0e8e3ea 100644
--- a/test/test_error_handlers.c
+++ b/test/test_error_handlers.c
@@ -62,7 +62,7 @@ static int myErrorHandler(TIFF* tiff, void* user_data, const char* module, const
return 1;
}
-int test_open_ext(int handlers_set_in_open)
+int test_open_ext()
{
int ret = 0;
char error_buffer[ERROR_STRING_SIZE] = {0};
@@ -77,22 +77,14 @@ int test_open_ext(int handlers_set_in_open)
.buffer = warn_buffer,
.buffer_size = ERROR_STRING_SIZE
};
- TIFF* tif;
- if( handlers_set_in_open )
- {
- TIFFOpenOptions* opts = TIFFOpenOptionsAlloc();
- assert(opts);
- TIFFOpenOptionsSetErrorHandlerExtR(opts, myErrorHandler, &errorhandler_user_data);
- TIFFOpenOptionsSetWarningHandlerExtR(opts, myErrorHandler, &warnhandler_user_data);
- tif = TIFFOpenExt("test_error_handler.tif", "w", opts);
- TIFFOpenOptionsFree(opts);
- }
- else
- {
- tif = TIFFOpen("test_error_handler.tif", "w");
- TIFFSetErrorHandlerExtR(tif, myErrorHandler, &errorhandler_user_data);
- TIFFSetWarningHandlerExtR(tif, myErrorHandler, &warnhandler_user_data);
- }
+
+ TIFFOpenOptions* opts = TIFFOpenOptionsAlloc();
+ assert(opts);
+ TIFFOpenOptionsSetErrorHandlerExtR(opts, myErrorHandler, &errorhandler_user_data);
+ TIFFOpenOptionsSetWarningHandlerExtR(opts, myErrorHandler, &warnhandler_user_data);
+ TIFF* tif = TIFFOpenExt("test_error_handler.tif", "w", opts);
+ TIFFOpenOptionsFree(opts);
+
if( tif == NULL )
{
fprintf(stderr, "Cannot create test_error_handler.tif");
@@ -144,6 +136,5 @@ int main()
{
int ret = 0;
ret += test_open_ext(1);
- ret += test_open_ext(0);
return ret;
}