comms/hylafax: fix build with tiff 4.5.0.

tiff 4.5 doesnt export anymore private symbols/functions that hylafax
was never supposed to have used anyway in the first place - copy them
from tiff 4.4 source into hylafax where needed.

cf https://gitlab.com/libtiff/libtiff/-/issues/504
This commit is contained in:
landry 2022-12-19 08:52:15 +00:00
parent f7d5bb5879
commit a3e8139ab7
4 changed files with 1427 additions and 1 deletions

View File

@ -1,6 +1,6 @@
COMMENT= send/receive faxes and share modems
DISTNAME= hylafax-6.0.6
REVISION= 15
REVISION= 16
CATEGORIES= comms
HOMEPAGE= https://www.HylaFAX.org/

View File

@ -0,0 +1,126 @@
tiff 4.5 removed private symbols/function that hylafax was never supposed to
used anyway - copy them from tiff 4.4 source.
https://gitlab.com/libtiff/libtiff/-/issues/504
Index: faxd/G3Decoder.c++
--- faxd/G3Decoder.c++.orig
+++ faxd/G3Decoder.c++
@@ -87,6 +87,109 @@
} \
} while (0)
+/* taken from tiff-4.4.0/libtiff/tif_fax3.c */
+#define isAligned(p,t) ((((size_t)(p)) & (sizeof (t)-1)) == 0)
+# define FILL(n, cp) \
+ for (int32_t ifill = 0; ifill < (n); ++ifill) \
+ { \
+ (cp)[ifill] = 0xff; \
+ } \
+ (cp) += (n);
+
+# define ZERO(n, cp) \
+ for (int32_t izero = 0; izero < (n); ++izero) \
+ { \
+ (cp)[izero] = 0; \
+ } \
+ (cp) += (n);
+
+void shopliftedfrom_TIFFFax3fillruns(unsigned char* buf, tiff_runlen_t* runs, tiff_runlen_t* erun, tiff_runlen_t lastx)
+{
+ static const unsigned char _fillmasks[] =
+ { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff };
+ unsigned char* cp;
+ uint32_t x, bx, run;
+ int32_t n, nw;
+ int64_t* lp;
+
+ if ((erun-runs)&1)
+ *erun++ = 0;
+ x = 0;
+ for (; runs < erun; runs += 2) {
+ run = runs[0];
+ if (x+run > lastx || run > lastx )
+ run = runs[0] = (uint32_t) (lastx - x);
+ if (run) {
+ cp = buf + (x>>3);
+ bx = x&7;
+ if (run > 8-bx) {
+ if (bx) { /* align to byte boundary */
+ *cp++ &= 0xff << (8-bx);
+ run -= 8-bx;
+ }
+ if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */
+ if ((n/sizeof (int64_t)) > 1) {
+ /*
+ * Align to int64_tword boundary and fill.
+ */
+ for (; n && !isAligned(cp, int64_t); n--)
+ *cp++ = 0x00;
+ lp = (int64_t*) cp;
+ nw = (int32_t)(n / sizeof (int64_t));
+ n -= nw * sizeof (int64_t);
+ do {
+ *lp++ = 0L;
+ } while (--nw);
+ cp = (unsigned char*) lp;
+ }
+ ZERO(n, cp);
+ run &= 7;
+ }
+ if (run)
+ cp[0] &= 0xff >> run;
+ } else
+ cp[0] &= ~(_fillmasks[run]>>bx);
+ x += runs[0];
+ }
+ run = runs[1];
+ if (x+run > lastx || run > lastx )
+ run = runs[1] = lastx - x;
+ if (run) {
+ cp = buf + (x>>3);
+ bx = x&7;
+ if (run > 8-bx) {
+ if (bx) { /* align to byte boundary */
+ *cp++ |= 0xff >> bx;
+ run -= 8-bx;
+ }
+ if( (n = run>>3) != 0 ) { /* multiple bytes to fill */
+ if ((n/sizeof (int64_t)) > 1) {
+ /*
+ * Align to int64_t boundary and fill.
+ */
+ for (; n && !isAligned(cp, int64_t); n--)
+ *cp++ = 0xff;
+ lp = (int64_t*) cp;
+ nw = (int32_t)(n / sizeof (int64_t));
+ n -= nw * sizeof (int64_t);
+ do {
+ *lp++ = -1L;
+ } while (--nw);
+ cp = (unsigned char*) lp;
+ }
+ FILL(n, cp);
+ run &= 7;
+ }
+ /* Explicit 0xff masking to make icc -check=conversions happy */
+ if (run)
+ cp[0] = (unsigned char)((cp[0] | (0xff00 >> run))&0xff);
+ } else
+ cp[0] |= _fillmasks[run]>>bx;
+ x += runs[1];
+ }
+ }
+ assert(x == lastx);
+}
#include "tif_fax3.h"
G3Decoder::G3Decoder() {}
@@ -239,7 +342,7 @@ G3Decoder::decodeRow(void* scanline, u_int lastx)
if (!nullrow)
RTCrun = 0;
if (scanline)
- _TIFFFax3fillruns((u_char*) scanline, thisrun, pa, lastx);
+ shopliftedfrom_TIFFFax3fillruns((u_char*) scanline, thisrun, pa, lastx);
if (is2D) {
SETVAL(0); // imaginary change for reference
SWAP(tiff_runlen_t*, curruns, refruns);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
tiff 4.5 removed private symbols/function that hylafax was never supposed to
used anyway - copy them from tiff 4.4 source.
https://gitlab.com/libtiff/libtiff/-/issues/504
Index: faxd/tif_fax3.h
--- faxd/tif_fax3.h.orig
+++ faxd/tif_fax3.h
@@ -57,13 +57,7 @@ typedef void (*TIFFFaxFillFunc)(unsigned char*, tiff_r
/*
* The default run filler; made external for other decoders.
*/
-#if defined(__cplusplus)
-extern "C" {
-#endif
-extern void _TIFFFax3fillruns(unsigned char*, tiff_runlen_t*, tiff_runlen_t*, tiff_runlen_t);
-#if defined(__cplusplus)
-}
-#endif
+void shopliftedfrom_TIFFFax3fillruns(unsigned char*, tiff_runlen_t*, tiff_runlen_t*, tiff_runlen_t);
/* finite state machine codes */