From d2b4904401a3b96d3852767d59a68813b2217428 Mon Sep 17 00:00:00 2001 From: gitlost Date: Thu, 2 Oct 2025 11:34:45 +0100 Subject: [PATCH] gs1: Use new `gs1_encoders_init_ex()` API; remove refs to EXCLUDE_GS1_SYNTAX_DICTIONARY --- .github/workflows/ci.yml | 6 +++--- README.bsd | 4 ++-- README.linux | 6 +++--- README.macos | 4 ++-- backend/gs1.c | 11 +++++++++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c15ac85..a9cecd37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: sudo apt-get install libpng-dev - name: Install GS1 Syntax Engine - run: git clone --depth=1 https://github.com/gs1/gs1-syntax-engine && cd gs1-syntax-engine/src/c-lib && make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && sudo make install + run: git clone --depth=1 https://github.com/gs1/gs1-syntax-engine && cd gs1-syntax-engine/src/c-lib && make lib && sudo make install - name: Install locale shell: bash @@ -70,7 +70,7 @@ jobs: run: sudo apt-get install libpng-dev - name: Install GS1 Syntax Engine - run: git clone --depth=1 https://github.com/gs1/gs1-syntax-engine && cd gs1-syntax-engine/src/c-lib && make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && sudo make install + run: git clone --depth=1 https://github.com/gs1/gs1-syntax-engine && cd gs1-syntax-engine/src/c-lib && make lib && sudo make install - name: Install locale shell: bash @@ -236,7 +236,7 @@ jobs: run: brew install qt5 - name: Install GS1 Syntax Engine - run: git clone --depth=1 https://github.com/gs1/gs1-syntax-engine && cd gs1-syntax-engine/src/c-lib && make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && (sudo make install || true) + run: git clone --depth=1 https://github.com/gs1/gs1-syntax-engine && cd gs1-syntax-engine/src/c-lib && make lib && (sudo make install || true) - name: Configure CMake working-directory: build diff --git a/README.bsd b/README.bsd index 7a922fe5..15ccc4dc 100644 --- a/README.bsd +++ b/README.bsd @@ -1,4 +1,4 @@ -% README.bsd 2025-09-26 +% README.bsd 2025-10-02 % Tested on FreeBSD 14.3-RELEASE (with X11 + GNOME installed), OpenBSD 7.7 (with X11) and NetBSD 10.1 (with X11) 1. Prerequisites for building zint @@ -26,7 +26,7 @@ To install the gs1encoders library, optional but needed for GS1 Syntax Engine su git clone https://github.com/gs1/gs1-syntax-engine cd gs1-syntax-engine/src/c-lib - gmake CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib + gmake lib su gmake install exit diff --git a/README.linux b/README.linux index 79e2312d..46f54f5c 100644 --- a/README.linux +++ b/README.linux @@ -1,4 +1,4 @@ -% README.linux 2025-09-16 +% README.linux 2025-10-02 % Tested on Ubuntu 20.04.4 LTS, Ubuntu 22.04 LTS, Ubuntu 24.04 LTS and % Fedora Linux 42 (Workstation Edition) @@ -25,10 +25,10 @@ gs1encoders is optional but necessary for GS1 Syntax Engine support. To install git clone https://github.com/gs1/gs1-syntax-engine -and navigate to "src/c-lib" and make with EXCLUDE_SYNTAX_DICTIONARY_LOADER defined: +and navigate to "src/c-lib" and make: cd gs1-syntax-engine/src/c-lib - make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && sudo make install + make lib && sudo make install cd ../../.. Now either download the zint source code tarball diff --git a/README.macos b/README.macos index cbd031b7..174bb03a 100644 --- a/README.macos +++ b/README.macos @@ -1,4 +1,4 @@ -% README.macos 2025-09-16 +% README.macos 2025-10-02 % Tested on macOS 12.7.2 Monterey VirtualBox (thanks to https://github.com/myspaghetti/macos-virtualbox) 1. Prerequisites for building zint and zint-qt @@ -33,7 +33,7 @@ Clone and install the gs1encoders library (optional but necessary for GS1 Syntax git clone https://github.com/gs1/gs1-syntax-engine cd gs1-syntax-engine/src/c-lib - make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && sudo make install + make lib && sudo make install cd ../../.. Add the Qt5 bin directory to the PATH diff --git a/backend/gs1.c b/backend/gs1.c index 4ee4cbb5..f2aab7ff 100644 --- a/backend/gs1.c +++ b/backend/gs1.c @@ -1637,6 +1637,11 @@ static int gs1se_verify(struct zint_symbol *symbol, const unsigned char source[] unsigned char *local_source2_buf = (unsigned char *) z_alloca(ARRAY_SIZE(symbol->primary) * 2 + length + parens_cnt + 1); int is_digital_link = 0; + char msgBuf[120]; + gs1_encoder_init_status_t status = GS1_ENCODERS_INIT_SUCCESS; + gs1_encoder_init_opts_t opts = { + sizeof(gs1_encoder_init_opts_t), gs1_encoder_iNO_SYNDICT | gs1_encoder_iQUIET, &status, msgBuf, sizeof(msgBuf) + }; gs1_encoder *ctx; int gs1se_ret; @@ -1702,8 +1707,10 @@ static int gs1se_verify(struct zint_symbol *symbol, const unsigned char source[] } } - if (!(ctx = gs1_encoder_init(NULL))) { - return z_errtxt(ZINT_ERROR_MEMORY, symbol, 266, "Insufficient memory for GS1 Syntax Engine"); + if (!(ctx = gs1_encoder_init_ex(NULL /*mem*/, &opts))) { + const int error_number = status == GS1_ENCODERS_INIT_FAILED_NO_MEM + ? ZINT_ERROR_MEMORY : ZINT_ERROR_ENCODING_PROBLEM; + return z_errtxtf(error_number, symbol, 266, "GS1 Syntax Engine: %s", opts.msgBuf); } if (is_digital_link) {