zxing-cpp: upgrade to release 1.4.0

== list of removed patches ==
* 0001-Use-a-patch-file-to-document-changes-from-upstream-s.patch: fixed upstream[1].
* 0002-Update-stb_image_write-from-1.14-to-1.16.patch: fixed upstream.
* 0003-Update-stb_image-from-2.25-to-2.27.patch: fixed upstream
* 0004-Apply-stb-PR-1223-to-stb_image.patch: "stb_image.h" and "stb_image.patch" were removed upstream[1][2].
* include.patch.0: fixed upstream (added #include <cstdint>)[3].
* zxing_newline.patch: this issue has been fixed since gcc 11.2/12 or later[4].

== list of added patches ==
* android_include.patch.0: added missing #include <cmath>(for std::abs)
* assume.__cpp_lib_string_view.patch.0 (by Caolán McNamara): fixed "error: no member named 'asString' in 'ZXing::ByteArray'"

[1] b208f4bd90
[2] d2603139c5
[3] 53da58625d
[4] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100392

Change-Id: I6266fd6609f0d4235a8d2bcb6571817ef2135101
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142553
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Taichi Haradaguchi
2022-11-11 00:37:22 +09:00
committed by Caolán McNamara
parent e58ad604df
commit 368116fb55
11 changed files with 98 additions and 1753 deletions

View File

@@ -249,8 +249,8 @@ export ZLIB_SHA256SUM := d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da05
export ZLIB_TARBALL := zlib-1.2.13.tar.xz
export ZMF_SHA256SUM := 27051a30cb057fdb5d5de65a1f165c7153dc76e27fe62251cbb86639eb2caf22
export ZMF_TARBALL := libzmf-0.0.2.tar.xz
export ZXING_SHA256SUM := 653d9e44195d86cf64a36af9ff3a1978ec5599df3882439fefa56e7064f55e8a
export ZXING_TARBALL := zxing-cpp-1.2.0.tar.gz
export ZXING_SHA256SUM := 126767bb56f8a1f25ae84d233db2e9b9be50d71f5776092d0e170ca0f0ed1862
export ZXING_TARBALL := zxing-cpp-1.4.0.tar.gz
NUMBERTEXT_EXTENSION_SHA256SUM := 1568ed1d2feb8210bb5de61d69574a165cded536cfa17c6953c9064076469de2
export OPENSYMBOL_SHA256SUM := f543e6e2d7275557a839a164941c0a86e5f2c3f2a0042bfc434c88c6dde9e140
export OPENSYMBOL_TTF := f543e6e2d7275557a839a164941c0a86e5f2c3f2a0042bfc434c88c6dde9e140-opens___.ttf

View File

@@ -1,35 +0,0 @@
From 1d031966e08aef92ef742ae3cf91e1addaf95a47 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Wed, 8 Dec 2021 18:14:54 -0500
Subject: [PATCH 1/4] Use a patch file to document changes from upstream
stb_image.h
---
thirdparty/stb/stb_image.patch | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 thirdparty/stb/stb_image.patch
diff --git a/thirdparty/stb/stb_image.patch b/thirdparty/stb/stb_image.patch
new file mode 100644
index 0000000..5153728
--- /dev/null
+++ b/thirdparty/stb/stb_image.patch
@@ -0,0 +1,15 @@
+diff -Naur upstream/stb_image.h zxing/stb_image.h
+--- upstream/stb_image.h 2021-12-08 18:11:28.170529096 -0500
++++ zxing/stb_image.h 2021-12-08 18:06:42.706717697 -0500
+@@ -1644,7 +1644,11 @@
+
+ static stbi_uc stbi__compute_y(int r, int g, int b)
+ {
++#if 0 // ori
+ return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8);
++#else // zxing (see ReadBarcode.cpp:RGBToGray)
++ return (stbi_uc) ((306 * r + 601 * g + 117 * b + 0x200) >> 10);
++#endif
+ }
+ #endif
+
--
2.33.1

View File

@@ -1,361 +0,0 @@
From 38f86eecd1e790329d56a4491ee0498d75d61c42 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Wed, 8 Dec 2021 18:16:46 -0500
Subject: [PATCH 2/4] Update stb_image_write from 1.14 to 1.16
1.16 (2021-07-11)
make Deflate code emit uncompressed blocks when it would
otherwise expand support writing BMPs with alpha channel
1.15 (2020-07-13) unknown
---
thirdparty/stb/stb_image_write.h | 132 ++++++++++++++++++++++---------
1 file changed, 95 insertions(+), 37 deletions(-)
diff --git a/thirdparty/stb/stb_image_write.h b/thirdparty/stb/stb_image_write.h
index cffd473..e4b32ed 100644
--- a/thirdparty/stb/stb_image_write.h
+++ b/thirdparty/stb/stb_image_write.h
@@ -1,4 +1,4 @@
-/* stb_image_write - v1.14 - public domain - http://nothings.org/stb
+/* stb_image_write - v1.16 - public domain - http://nothings.org/stb
writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015
no warranty implied; use at your own risk
@@ -140,6 +140,7 @@ CREDITS:
Ivan Tikhonov
github:ignotion
Adam Schackart
+ Andrew Kensler
LICENSE
@@ -166,9 +167,9 @@ LICENSE
#endif
#ifndef STB_IMAGE_WRITE_STATIC // C++ forbids static forward declarations
-extern int stbi_write_tga_with_rle;
-extern int stbi_write_png_compression_level;
-extern int stbi_write_force_png_filter;
+STBIWDEF int stbi_write_tga_with_rle;
+STBIWDEF int stbi_write_png_compression_level;
+STBIWDEF int stbi_write_force_png_filter;
#endif
#ifndef STBI_WRITE_NO_STDIO
@@ -178,7 +179,7 @@ STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const
STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality);
-#ifdef STBI_WINDOWS_UTF8
+#ifdef STBIW_WINDOWS_UTF8
STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
#endif
#endif
@@ -267,6 +268,8 @@ typedef struct
{
stbi_write_func *func;
void *context;
+ unsigned char buffer[64];
+ int buf_used;
} stbi__write_context;
// initialize a callback-based context
@@ -283,7 +286,7 @@ static void stbi__stdio_write(void *context, void *data, int size)
fwrite(data,1,size,(FILE*) context);
}
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
+#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8)
#ifdef __cplusplus
#define STBIW_EXTERN extern "C"
#else
@@ -294,25 +297,25 @@ STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned in
STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
{
- return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
+ return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
}
#endif
static FILE *stbiw__fopen(char const *filename, char const *mode)
{
FILE *f;
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
+#if defined(_WIN32) && defined(STBIW_WINDOWS_UTF8)
wchar_t wMode[64];
wchar_t wFilename[1024];
- if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))
+ if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename)))
return 0;
- if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))
+ if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode)))
return 0;
-#if _MSC_VER >= 1400
- if (0 != _wfopen_s(&f, wFilename, wMode))
- f = 0;
+#if defined(_MSC_VER) && _MSC_VER >= 1400
+ if (0 != _wfopen_s(&f, wFilename, wMode))
+ f = 0;
#else
f = _wfopen(wFilename, wMode);
#endif
@@ -380,16 +383,36 @@ static void stbiw__writef(stbi__write_context *s, const char *fmt, ...)
va_end(v);
}
+static void stbiw__write_flush(stbi__write_context *s)
+{
+ if (s->buf_used) {
+ s->func(s->context, &s->buffer, s->buf_used);
+ s->buf_used = 0;
+ }
+}
+
static void stbiw__putc(stbi__write_context *s, unsigned char c)
{
s->func(s->context, &c, 1);
}
+static void stbiw__write1(stbi__write_context *s, unsigned char a)
+{
+ if ((size_t)s->buf_used + 1 > sizeof(s->buffer))
+ stbiw__write_flush(s);
+ s->buffer[s->buf_used++] = a;
+}
+
static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c)
{
- unsigned char arr[3];
- arr[0] = a; arr[1] = b; arr[2] = c;
- s->func(s->context, arr, 3);
+ int n;
+ if ((size_t)s->buf_used + 3 > sizeof(s->buffer))
+ stbiw__write_flush(s);
+ n = s->buf_used;
+ s->buf_used = n+3;
+ s->buffer[n+0] = a;
+ s->buffer[n+1] = b;
+ s->buffer[n+2] = c;
}
static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
@@ -398,7 +421,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
int k;
if (write_alpha < 0)
- s->func(s->context, &d[comp - 1], 1);
+ stbiw__write1(s, d[comp - 1]);
switch (comp) {
case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case
@@ -406,7 +429,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
if (expand_mono)
stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
else
- s->func(s->context, d, 1); // monochrome TGA
+ stbiw__write1(s, d[0]); // monochrome TGA
break;
case 4:
if (!write_alpha) {
@@ -422,7 +445,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
break;
}
if (write_alpha > 0)
- s->func(s->context, &d[comp - 1], 1);
+ stbiw__write1(s, d[comp - 1]);
}
static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
@@ -447,6 +470,7 @@ static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, i
unsigned char *d = (unsigned char *) data + (j*x+i)*comp;
stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);
}
+ stbiw__write_flush(s);
s->func(s->context, &zero, scanline_pad);
}
}
@@ -467,16 +491,27 @@ static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x,
static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)
{
- int pad = (-x*3) & 3;
- return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
- "11 4 22 4" "4 44 22 444444",
- 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header
- 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
+ if (comp != 4) {
+ // write RGB bitmap
+ int pad = (-x*3) & 3;
+ return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
+ "11 4 22 4" "4 44 22 444444",
+ 'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40, // file header
+ 40, x,y, 1,24, 0,0,0,0,0,0); // bitmap header
+ } else {
+ // RGBA bitmaps need a v4 header
+ // use BI_BITFIELDS mode with 32bpp and alpha mask
+ // (straight BI_RGB with alpha mask doesn't work in most readers)
+ return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *)data,1,0,
+ "11 4 22 4" "4 44 22 444444 4444 4 444 444 444 444",
+ 'B', 'M', 14+108+x*y*4, 0, 0, 14+108, // file header
+ 108, x,y, 1,32, 3,0,0,0,0,0, 0xff0000,0xff00,0xff,0xff000000u, 0, 0,0,0, 0,0,0, 0,0,0, 0,0,0); // bitmap V4 header
+ }
}
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_bmp_core(&s, x, y, comp, data);
}
@@ -484,7 +519,7 @@ STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x,
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_bmp_core(&s, x, y, comp, data);
stbi__end_write_file(&s);
@@ -557,24 +592,25 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v
if (diff) {
unsigned char header = STBIW_UCHAR(len - 1);
- s->func(s->context, &header, 1);
+ stbiw__write1(s, header);
for (k = 0; k < len; ++k) {
stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);
}
} else {
unsigned char header = STBIW_UCHAR(len - 129);
- s->func(s->context, &header, 1);
+ stbiw__write1(s, header);
stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);
}
}
}
+ stbiw__write_flush(s);
}
return 1;
}
STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_tga_core(&s, x, y, comp, (void *) data);
}
@@ -582,7 +618,7 @@ STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x,
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);
stbi__end_write_file(&s);
@@ -598,6 +634,8 @@ STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const
#define stbiw__max(a, b) ((a) > (b) ? (a) : (b))
+#ifndef STBI_WRITE_NO_STDIO
+
static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)
{
int exponent;
@@ -732,7 +770,7 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
s->func(s->context, header, sizeof(header)-1);
-#ifdef __STDC_WANT_SECURE_LIB__
+#ifdef __STDC_LIB_EXT1__
len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#else
len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
@@ -748,15 +786,14 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f
STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_hdr_core(&s, x, y, comp, (float *) data);
}
-#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);
stbi__end_write_file(&s);
@@ -944,6 +981,23 @@ STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, i
(void) stbiw__sbfree(hash_table[i]);
STBIW_FREE(hash_table);
+ // store uncompressed instead if compression was worse
+ if (stbiw__sbn(out) > data_len + 2 + ((data_len+32766)/32767)*5) {
+ stbiw__sbn(out) = 2; // truncate to DEFLATE 32K window and FLEVEL = 1
+ for (j = 0; j < data_len;) {
+ int blocklen = data_len - j;
+ if (blocklen > 32767) blocklen = 32767;
+ stbiw__sbpush(out, data_len - j == blocklen); // BFINAL = ?, BTYPE = 0 -- no compression
+ stbiw__sbpush(out, STBIW_UCHAR(blocklen)); // LEN
+ stbiw__sbpush(out, STBIW_UCHAR(blocklen >> 8));
+ stbiw__sbpush(out, STBIW_UCHAR(~blocklen)); // NLEN
+ stbiw__sbpush(out, STBIW_UCHAR(~blocklen >> 8));
+ memcpy(out+stbiw__sbn(out), data+j, blocklen);
+ stbiw__sbn(out) += blocklen;
+ j += blocklen;
+ }
+ }
+
{
// compute adler32 on input
unsigned int s1=1, s2=0;
@@ -1552,7 +1606,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in
STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
stbi__start_write_callbacks(&s, func, context);
return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);
}
@@ -1561,7 +1615,7 @@ STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x,
#ifndef STBI_WRITE_NO_STDIO
STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
{
- stbi__write_context s;
+ stbi__write_context s = { 0 };
if (stbi__start_write_file(&s,filename)) {
int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);
stbi__end_write_file(&s);
@@ -1574,6 +1628,10 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const
#endif // STB_IMAGE_WRITE_IMPLEMENTATION
/* Revision history
+ 1.16 (2021-07-11)
+ make Deflate code emit uncompressed blocks when it would otherwise expand
+ support writing BMPs with alpha channel
+ 1.15 (2020-07-13) unknown
1.14 (2020-02-02) updated JPEG writer to downsample chroma channels
1.13
1.12
@@ -1611,7 +1669,7 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const
add HDR output
fix monochrome BMP
0.95 (2014-08-17)
- add monochrome TGA output
+ add monochrome TGA output
0.94 (2014-05-31)
rename private functions to avoid conflicts with stb_image.h
0.93 (2014-05-27)
--
2.33.1

File diff suppressed because it is too large Load Diff

View File

@@ -1,98 +0,0 @@
From 5ca63122c53fa0703cad9a8257f123a1ca4c43b1 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Wed, 8 Dec 2021 18:24:31 -0500
Subject: [PATCH 4/4] Apply stb PR#1223 to stb_image
Fixes a crash and an infinite loop in stb_image that could occur with
specially constructed PGM and HDR files
https://github.com/nothings/stb/pull/1223
This is a candidate fix for:
https://nvd.nist.gov/vuln/detail/CVE-2021-42715
In stb_image's HDR reader, loading a specially constructed invalid HDR
file can result in an infinite loop within the RLE decoder
https://github.com/nothings/stb/issues/1224
Additionally, this is a candidate fix for:
https://nvd.nist.gov/vuln/detail/CVE-2021-42716
stbi__pnm_load heap-buffer-overflow bug
https://github.com/nothings/stb/issues/1166
In stb_image's PNM reader, loading a specially constructed valid
16-bit PGM file with 4 channels can cause a crash due to an
out-of-bounds read
https://github.com/nothings/stb/issues/1225
---
thirdparty/stb/stb_image.h | 17 ++++++++++++-----
thirdparty/stb/stb_image.patch | 4 ++--
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/thirdparty/stb/stb_image.h b/thirdparty/stb/stb_image.h
index c58bc0c..612bc4c 100644
--- a/thirdparty/stb/stb_image.h
+++ b/thirdparty/stb/stb_image.h
@@ -108,7 +108,7 @@ RECENT REVISION HISTORY:
Cass Everitt Ryamond Barbiero github:grim210
Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw
Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus
- Josh Tobin Matthew Gregan github:poppolopoppo
+ Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo
Julian Raschke Gregory Mullen Christian Floisand github:darealshinji
Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007
Brad Weinberger Matvey Cherevko github:mosra
@@ -7191,12 +7191,12 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re
// Run
value = stbi__get8(s);
count -= 128;
- if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
+ if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
for (z = 0; z < count; ++z)
scanline[i++ * 4 + k] = value;
} else {
// Dump
- if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
+ if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
for (z = 0; z < count; ++z)
scanline[i++ * 4 + k] = stbi__get8(s);
}
@@ -7450,10 +7450,17 @@ static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req
out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0);
if (!out) return stbi__errpuc("outofmem", "Out of memory");
- stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8));
+ if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) {
+ STBI_FREE(out);
+ return stbi__errpuc("bad PNM", "PNM file truncated");
+ }
if (req_comp && req_comp != s->img_n) {
- out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
+ if (ri->bits_per_channel == 16) {
+ out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y);
+ } else {
+ out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
+ }
if (out == NULL) return out; // stbi__convert_format frees input on failure
}
return out;
diff --git a/thirdparty/stb/stb_image.patch b/thirdparty/stb/stb_image.patch
index f1fee52..1768ba8 100644
--- a/thirdparty/stb/stb_image.patch
+++ b/thirdparty/stb/stb_image.patch
@@ -1,6 +1,6 @@
diff -Naur upstream/stb_image.h zxing/stb_image.h
---- upstream/stb_image.h 2021-12-08 18:18:07.485461782 -0500
-+++ zxing/stb_image.h 2021-12-08 18:18:29.596689004 -0500
+--- upstream/stb_image.h 2021-12-08 18:22:56.724466161 -0500
++++ zxing/stb_image.h 2021-12-08 18:23:15.084657043 -0500
@@ -1725,7 +1725,11 @@
static stbi_uc stbi__compute_y(int r, int g, int b)
--
2.33.1

View File

@@ -25,80 +25,81 @@ $(eval $(call gb_StaticLibrary_set_include,zxing,\
))
$(eval $(call gb_StaticLibrary_add_generated_exception_objects,zxing,\
UnpackedTarball/zxing/core/src/aztec/AZReader \
UnpackedTarball/zxing/core/src/aztec/AZToken \
UnpackedTarball/zxing/core/src/aztec/AZEncoder \
UnpackedTarball/zxing/core/src/aztec/AZDecoder \
UnpackedTarball/zxing/core/src/aztec/AZDetector \
UnpackedTarball/zxing/core/src/aztec/AZEncoder \
UnpackedTarball/zxing/core/src/aztec/AZHighLevelEncoder \
UnpackedTarball/zxing/core/src/aztec/AZReader \
UnpackedTarball/zxing/core/src/aztec/AZToken \
UnpackedTarball/zxing/core/src/aztec/AZWriter \
UnpackedTarball/zxing/core/src/BarcodeFormat \
UnpackedTarball/zxing/core/src/BitArray \
UnpackedTarball/zxing/core/src/BitMatrixIO \
UnpackedTarball/zxing/core/src/BinaryBitmap \
UnpackedTarball/zxing/core/src/BitMatrix \
UnpackedTarball/zxing/core/src/BitSource \
UnpackedTarball/zxing/core/src/textcodec/Big5MapTable \
UnpackedTarball/zxing/core/src/textcodec/Big5TextDecoder \
UnpackedTarball/zxing/core/src/textcodec/Big5TextEncoder \
UnpackedTarball/zxing/core/src/textcodec/Big5MapTable \
UnpackedTarball/zxing/core/src/CharacterSetECI \
UnpackedTarball/zxing/core/src/BinaryBitmap \
UnpackedTarball/zxing/core/src/BitArray \
UnpackedTarball/zxing/core/src/BitMatrix \
UnpackedTarball/zxing/core/src/BitMatrixIO \
UnpackedTarball/zxing/core/src/BitSource \
UnpackedTarball/zxing/core/src/CharacterSet \
UnpackedTarball/zxing/core/src/ConcentricFinder \
UnpackedTarball/zxing/core/src/Content \
UnpackedTarball/zxing/core/src/DecodeHints \
UnpackedTarball/zxing/core/src/DecodeStatus \
UnpackedTarball/zxing/core/src/datamatrix/DMWriter \
UnpackedTarball/zxing/core/src/datamatrix/DMDetector \
UnpackedTarball/zxing/core/src/datamatrix/DMVersion \
UnpackedTarball/zxing/core/src/datamatrix/DMSymbolInfo \
UnpackedTarball/zxing/core/src/datamatrix/DMDecoder \
UnpackedTarball/zxing/core/src/datamatrix/DMReader \
UnpackedTarball/zxing/core/src/datamatrix/DMBitLayout \
UnpackedTarball/zxing/core/src/datamatrix/DMDataBlock \
UnpackedTarball/zxing/core/src/datamatrix/DMDecoder \
UnpackedTarball/zxing/core/src/datamatrix/DMDetector \
UnpackedTarball/zxing/core/src/datamatrix/DMECEncoder \
UnpackedTarball/zxing/core/src/datamatrix/DMHighLevelEncoder \
UnpackedTarball/zxing/core/src/GlobalHistogramBinarizer \
UnpackedTarball/zxing/core/src/GTIN \
UnpackedTarball/zxing/core/src/GenericGF \
UnpackedTarball/zxing/core/src/GridSampler \
UnpackedTarball/zxing/core/src/GenericLuminanceSource \
UnpackedTarball/zxing/core/src/GenericGFPoly \
UnpackedTarball/zxing/core/src/datamatrix/DMReader \
UnpackedTarball/zxing/core/src/datamatrix/DMSymbolInfo \
UnpackedTarball/zxing/core/src/datamatrix/DMVersion \
UnpackedTarball/zxing/core/src/datamatrix/DMWriter \
UnpackedTarball/zxing/core/src/ECI \
UnpackedTarball/zxing/core/src/textcodec/GBTextEncoder \
UnpackedTarball/zxing/core/src/textcodec/GBTextDecoder \
UnpackedTarball/zxing/core/src/GenericGF \
UnpackedTarball/zxing/core/src/GenericGFPoly \
UnpackedTarball/zxing/core/src/GlobalHistogramBinarizer \
UnpackedTarball/zxing/core/src/GridSampler \
UnpackedTarball/zxing/core/src/GS1 \
UnpackedTarball/zxing/core/src/GTIN \
UnpackedTarball/zxing/core/src/HybridBinarizer \
UnpackedTarball/zxing/core/src/textcodec/JPTextEncoder \
UnpackedTarball/zxing/core/src/textcodec/JPTextDecoder \
UnpackedTarball/zxing/core/src/textcodec/JPTextEncoder \
UnpackedTarball/zxing/core/src/textcodec/KRHangulMapping \
UnpackedTarball/zxing/core/src/textcodec/KRTextEncoder \
UnpackedTarball/zxing/core/src/textcodec/KRTextDecoder \
UnpackedTarball/zxing/core/src/LuminanceSource \
UnpackedTarball/zxing/core/src/MultiFormatWriter \
UnpackedTarball/zxing/core/src/MultiFormatReader \
UnpackedTarball/zxing/core/src/maxicode/MCDecoder \
UnpackedTarball/zxing/core/src/textcodec/KRTextEncoder \
UnpackedTarball/zxing/core/src/maxicode/MCBitMatrixParser \
UnpackedTarball/zxing/core/src/maxicode/MCDecoder \
UnpackedTarball/zxing/core/src/maxicode/MCReader \
UnpackedTarball/zxing/core/src/oned/ODUPCEWriter \
UnpackedTarball/zxing/core/src/MultiFormatReader \
UnpackedTarball/zxing/core/src/MultiFormatWriter \
UnpackedTarball/zxing/core/src/oned/ODCodabarReader \
UnpackedTarball/zxing/core/src/oned/ODCodabarWriter \
UnpackedTarball/zxing/core/src/oned/ODCode39Reader \
UnpackedTarball/zxing/core/src/oned/ODCode39Writer \
UnpackedTarball/zxing/core/src/oned/ODCode93Reader \
UnpackedTarball/zxing/core/src/oned/ODCode93Writer \
UnpackedTarball/zxing/core/src/oned/ODCode128Patterns \
UnpackedTarball/zxing/core/src/oned/ODCode128Reader \
UnpackedTarball/zxing/core/src/oned/ODCode128Writer \
UnpackedTarball/zxing/core/src/oned/ODDataBarCommon \
UnpackedTarball/zxing/core/src/oned/ODDataBarExpandedBitDecoder \
UnpackedTarball/zxing/core/src/oned/ODDataBarExpandedReader \
UnpackedTarball/zxing/core/src/oned/ODDataBarReader \
UnpackedTarball/zxing/core/src/oned/ODEAN8Writer \
UnpackedTarball/zxing/core/src/oned/ODWriterHelper \
UnpackedTarball/zxing/core/src/oned/ODEAN13Writer \
UnpackedTarball/zxing/core/src/oned/ODITFWriter \
UnpackedTarball/zxing/core/src/oned/ODITFReader \
UnpackedTarball/zxing/core/src/oned/ODCode39Reader \
UnpackedTarball/zxing/core/src/oned/ODDataBarExpandedReader \
UnpackedTarball/zxing/core/src/oned/ODCode128Reader \
UnpackedTarball/zxing/core/src/oned/ODEAN13Writer \
UnpackedTarball/zxing/core/src/oned/ODMultiUPCEANReader \
UnpackedTarball/zxing/core/src/oned/ODCodabarWriter \
UnpackedTarball/zxing/core/src/oned/ODCode128Writer \
UnpackedTarball/zxing/core/src/oned/ODCode93Reader \
UnpackedTarball/zxing/core/src/oned/ODCodabarReader \
UnpackedTarball/zxing/core/src/oned/ODCode39Writer \
UnpackedTarball/zxing/core/src/oned/ODDataBarReader \
UnpackedTarball/zxing/core/src/oned/ODUPCAWriter \
UnpackedTarball/zxing/core/src/oned/ODUPCEWriter \
UnpackedTarball/zxing/core/src/oned/ODUPCEANCommon \
UnpackedTarball/zxing/core/src/oned/ODRowReader \
UnpackedTarball/zxing/core/src/oned/ODReader \
UnpackedTarball/zxing/core/src/oned/ODCode93Writer \
UnpackedTarball/zxing/core/src/oned/ODCode128Patterns \
UnpackedTarball/zxing/core/src/oned/ODDataBarCommon \
UnpackedTarball/zxing/core/src/oned/ODUPCAWriter \
UnpackedTarball/zxing/core/src/PerspectiveTransform \
UnpackedTarball/zxing/core/src/oned/ODWriterHelper \
UnpackedTarball/zxing/core/src/pdf417/PDFCodewordDecoder \
UnpackedTarball/zxing/core/src/pdf417/PDFHighLevelEncoder \
UnpackedTarball/zxing/core/src/pdf417/PDFDetectionResultColumn \
@@ -113,23 +114,23 @@ $(eval $(call gb_StaticLibrary_add_generated_exception_objects,zxing,\
UnpackedTarball/zxing/core/src/pdf417/PDFModulusPoly \
UnpackedTarball/zxing/core/src/pdf417/PDFDetector \
UnpackedTarball/zxing/core/src/pdf417/PDFBarcodeValue \
UnpackedTarball/zxing/core/src/qrcode/QRDecoder \
UnpackedTarball/zxing/core/src/qrcode/QRReader \
UnpackedTarball/zxing/core/src/qrcode/QRErrorCorrectionLevel \
UnpackedTarball/zxing/core/src/qrcode/QRFormatInformation \
UnpackedTarball/zxing/core/src/qrcode/QREncoder \
UnpackedTarball/zxing/core/src/qrcode/QRMaskUtil \
UnpackedTarball/zxing/core/src/qrcode/QRWriter \
UnpackedTarball/zxing/core/src/qrcode/QRMatrixUtil \
UnpackedTarball/zxing/core/src/qrcode/QRDetector \
UnpackedTarball/zxing/core/src/qrcode/QRVersion \
UnpackedTarball/zxing/core/src/PerspectiveTransform \
UnpackedTarball/zxing/core/src/qrcode/QRBitMatrixParser \
UnpackedTarball/zxing/core/src/qrcode/QRCodecMode \
UnpackedTarball/zxing/core/src/qrcode/QRDataBlock \
UnpackedTarball/zxing/core/src/qrcode/QRBitMatrixParser \
UnpackedTarball/zxing/core/src/Result \
UnpackedTarball/zxing/core/src/qrcode/QRDecoder \
UnpackedTarball/zxing/core/src/qrcode/QRDetector \
UnpackedTarball/zxing/core/src/qrcode/QREncoder \
UnpackedTarball/zxing/core/src/qrcode/QRErrorCorrectionLevel \
UnpackedTarball/zxing/core/src/qrcode/QRFormatInformation \
UnpackedTarball/zxing/core/src/qrcode/QRMaskUtil \
UnpackedTarball/zxing/core/src/qrcode/QRMatrixUtil \
UnpackedTarball/zxing/core/src/qrcode/QRReader \
UnpackedTarball/zxing/core/src/qrcode/QRWriter \
UnpackedTarball/zxing/core/src/qrcode/QRVersion \
UnpackedTarball/zxing/core/src/ReadBarcode \
UnpackedTarball/zxing/core/src/Result \
UnpackedTarball/zxing/core/src/ResultPoint \
UnpackedTarball/zxing/core/src/ResultMetadata \
UnpackedTarball/zxing/core/src/ReedSolomonDecoder \
UnpackedTarball/zxing/core/src/ReedSolomonEncoder \
UnpackedTarball/zxing/core/src/TextDecoder \

View File

@@ -14,12 +14,8 @@ $(eval $(call gb_UnpackedTarball_set_tarball,zxing,$(ZXING_TARBALL)))
$(eval $(call gb_UnpackedTarball_set_patchlevel,zxing,1))
$(eval $(call gb_UnpackedTarball_add_patches,zxing, \
external/zxing/zxing_newline.patch.1 \
external/zxing/0001-Use-a-patch-file-to-document-changes-from-upstream-s.patch \
external/zxing/0002-Update-stb_image_write-from-1.14-to-1.16.patch \
external/zxing/0003-Update-stb_image-from-2.25-to-2.27.patch \
external/zxing/0004-Apply-stb-PR-1223-to-stb_image.patch \
external/zxing/include.patch.0 \
external/zxing/assume.__cpp_lib_string_view.patch.0 \
external/zxing/android_include.patch.0 \
))
# vim: set noet sw=4 ts=4:

10
external/zxing/android_include.patch.0 vendored Normal file
View File

@@ -0,0 +1,10 @@
--- core/src/pdf417/PDFEncoder.cpp 2022-12-07 14:21:15.860189207 +0900
+++ core/src/pdf417/PDFEncoder.cpp 2022-12-07 14:21:20.856361002 +0900
@@ -8,6 +8,7 @@
#include "PDFEncoder.h"
#include "PDFHighLevelEncoder.h"
#include <array>
+#include <cmath>
#include <vector>
#include <stdexcept>

View File

@@ -0,0 +1,25 @@
--- ./core/src/ByteArray.h 2022-12-05 10:05:07.330193204 +0000
+++ ./core/src/ByteArray.h 2022-12-05 10:05:13.897892011 +0000
@@ -11,9 +11,7 @@
#include <string>
#include <vector>
-#ifdef __cpp_lib_string_view
#include <string_view>
-#endif
namespace ZXing {
@@ -30,12 +28,10 @@
void append(const ByteArray& other) { insert(end(), other.begin(), other.end()); }
-#ifdef __cpp_lib_string_view
std::string_view asString(size_t pos = 0, size_t len = std::string_view::npos) const
{
return std::string_view(reinterpret_cast<const char*>(data()), size()).substr(pos, len);
}
-#endif
};
inline std::string ToHex(const ByteArray& bytes)

View File

@@ -1,10 +0,0 @@
--- core/src/textcodec/JPTextEncoder.cpp
+++ core/src/textcodec/JPTextEncoder.cpp
@@ -36,6 +36,7 @@
// and the grateful thanks of the Qt team.
#include "JPTextEncoder.h"
+#include <stdint.h>
/*
* This data is derived from Unicode 1.1,

View File

@@ -1,21 +0,0 @@
Add newline at end of KRHangulMapping.h
without this, GCC 11 -E -fdirectives-only produces this:
extern const uint16_t ksc5601_hangul_to_unicode[2350];# 38 "/workdir/UnpackedTarball/zxing/core/src/textcodec/KRHangulMapping.cpp" 2
and compiling that fails with:
KRHangulMapping.h:38:55: error: stray '#' in program
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100392
--- zxing/core/src/textcodec/KRHangulMapping.h.orig 2021-05-01 18:00:09.011795242 +0200
+++ zxing/core/src/textcodec/KRHangulMapping.h 2021-05-01 18:00:16.774788294 +0200
@@ -35,4 +35,4 @@
#include <cstdint>
/* Table including ksc5601 hangul to unicode */
-extern const uint16_t ksc5601_hangul_to_unicode[2350];
\ No newline at end of file
+extern const uint16_t ksc5601_hangul_to_unicode[2350];