From e12c5ed3baaa36800b5e002c2cbf838668df80b3 Mon Sep 17 00:00:00 2001 From: gitlost Date: Mon, 10 Mar 2025 01:22:52 +0000 Subject: [PATCH] DBAR_STK/DBAR_OMNSTK/DBAR_EXPSTK (including composites): output HRT if `BARCODE_RAW_TEXT` manual: default to always making html --- backend/rss.c | 13 +++++++++++++ backend/tests/test_composite.c | 4 ++-- backend/tests/test_gs1.c | 14 +++++++++----- backend/tests/test_rss.c | 6 +++--- backend/zint.h | 3 ++- docs/Makefile | 6 +++--- docs/manual.html | 4 ++-- docs/manual.pmd | 4 ++-- docs/manual.txt | 4 ++-- docs/zint.1.pmd | 32 ++++++++++++++++---------------- tools/update_version.php | 4 ++-- 11 files changed, 56 insertions(+), 38 deletions(-) diff --git a/backend/rss.c b/backend/rss.c index 8cc6a2aa..3bcf97e4 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -291,6 +291,7 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int int latch; int separator_row; int widths[4]; + const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; separator_row = 0; @@ -547,6 +548,10 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int symbol->width = 50; } + if (raw_text) { + dbar_set_gtin14_hrt(symbol, source, length); + } + if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls dbar_omnstk_set_height() itself */ error_number = dbar_omnstk_set_height(symbol, 0 /*first_row*/); } @@ -595,6 +600,10 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int } symbol->rows = symbol->rows + 1; + if (raw_text) { + dbar_set_gtin14_hrt(symbol, source, length); + } + /* ISO/IEC 24724:2011 5.3.2.2 minimum 33X height per row */ if (symbol->symbology == BARCODE_DBAR_OMNSTK_CC) { symbol->height = symbol->height ? 33.0f : 66.0f; /* Pass back min row or default height */ @@ -1583,6 +1592,10 @@ INTERNAL int dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[], int symbol->rows = symbol->rows + 4; } symbol->rows = symbol->rows - 3; + + if (raw_text) { + hrt_cpy_nochk(symbol, reduced, reduced_length); + } } if (symbol->symbology == BARCODE_DBAR_EXP_CC || symbol->symbology == BARCODE_DBAR_EXPSTK_CC) { diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c index ad8b7515..2de783ba 100644 --- a/backend/tests/test_composite.c +++ b/backend/tests/test_composite.c @@ -3275,9 +3275,9 @@ static void test_hrt(const testCtx *const p_ctx) { /* 43*/ { BARCODE_UPCE_CC, -1, -1, "1234567+2", "[20]12", 0, "12345670+02" }, /* 44*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "1234567+2", "[20]12", 0, "12345670+02" }, /* 45*/ { BARCODE_DBAR_STK_CC, -1, -1, "12345678901231", "[20]12", 0, "" }, /* No HRT for stacked symbologies */ - /* 46*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "" }, + /* 46*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "0112345678901231" }, /* Unless RAW_TEXT */ /* 47*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "12345678901231", "[20]12", 0, "" }, - /* 48*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "" }, + /* 48*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "0112345678901231" }, }; const int data_size = ARRAY_SIZE(data); int i, length, composite_length, ret; diff --git a/backend/tests/test_gs1.c b/backend/tests/test_gs1.c index ad05ef7b..4366d82f 100644 --- a/backend/tests/test_gs1.c +++ b/backend/tests/test_gs1.c @@ -353,12 +353,16 @@ static void test_hrt(const testCtx *const p_ctx) { /* 76*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "011234567890123120122112345" }, /* 77*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" }, /* 78*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "" }, - /* 79*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "" }, + /* 79*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, /* 80*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "" }, - /* 81*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" }, - /* 82*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "" }, - /* 83*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" }, - /* 84*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "" }, + /* 81*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "" }, + /* 82*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "011234567890123110AB\035201290ABC20)12" }, + /* 83*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" }, + /* 84*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "" }, + /* 85*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "01123456789012342012" }, + /* 86*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "" }, + /* 87*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "" }, + /* 88*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "011234567890123110AB\035201290ABC20)12" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_rss.c b/backend/tests/test_rss.c index fa9e78d5..02b0ac6d 100644 --- a/backend/tests/test_rss.c +++ b/backend/tests/test_rss.c @@ -1322,11 +1322,11 @@ static void test_hrt(const testCtx *const p_ctx) { /* 10*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, "(01)12345678901231" }, /* See test_hrt() in "test_gs1.c" for full HRT tests */ /* 11*/ { BARCODE_DBAR_EXP, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "0112345678901231" }, /* 12*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "" }, /* No HRT for stacked */ - /* 13*/ { BARCODE_DBAR_STK, BARCODE_RAW_TEXT, "12345678901231", 0, "" }, + /* 13*/ { BARCODE_DBAR_STK, BARCODE_RAW_TEXT, "12345678901231", 0, "0112345678901231" }, /* Unless RAW_TEXT */ /* 14*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "" }, - /* 15*/ { BARCODE_DBAR_OMNSTK, BARCODE_RAW_TEXT, "10000000000090", 0, "" }, + /* 15*/ { BARCODE_DBAR_OMNSTK, BARCODE_RAW_TEXT, "10000000000090", 0, "0110000000000090" }, /* 16*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "" }, - /* 17*/ { BARCODE_DBAR_EXPSTK, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "" }, + /* 17*/ { BARCODE_DBAR_EXPSTK, BARCODE_RAW_TEXT, "[01]12345678901231", 0, "0112345678901231" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/zint.h b/backend/zint.h index 52a7d988..2040b8db 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -301,7 +301,8 @@ extern "C" { #define BARCODE_MEMORY_FILE 0x10000 /* Write output to in-memory buffer `memfile` instead of to `outfile` */ #define BARCODE_RAW_TEXT 0x20000 /* Set HRT with no decoration (GS1 data will not have parentheses but GS separators as needed), complete with any control chars and check chars, and - for all linear symbologies, including those that normally don't set it */ + for all linear and DataBar Stacked symbologies, including those that + normally don't set it */ /* Input data types (`symbol->input_mode`) */ #define DATA_MODE 0 /* Binary */ diff --git a/docs/Makefile b/docs/Makefile index 58d1c9b8..81b11674 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,5 +1,5 @@ # Makefile for generating "manual.txt" and "manual.pdf" from "manual.pmd" and "zint.1" from "zint.1.pmd" using pandoc -# Copyright (C) 2022-2024 +# Copyright (C) 2022-2025 # vim: set ts=4 sw=4 noet : # # Requires a recent version of pandoc, plus pandoc-tablenos, xelatex and various other packages - see "README" @@ -8,6 +8,7 @@ SOURCE = manual.pmd OUT_PDF = manual.pdf OUT_TXT = manual.txt +OUT_HTML = manual.html INC_HEADER_PDF = inc_header_pdf.tex INC_BEFORE_BODY_PDF = inc_before_body_pdf.tex INC_PDF = --include-in-header $(INC_HEADER_PDF) --include-before-body $(INC_BEFORE_BODY_PDF) @@ -149,7 +150,7 @@ TEX_MAN_PAGE = zint.1.tex TXT_OPTS = --filter pandoc-tablenos -M tablenos-warning-level=0 --columns 80 --eol=lf -t plain MAN_PAGE_OPTS = -s -t man -all : $(OUT_PDF) $(OUT_TXT) $(OUT_MAN_PAGE) +all : $(OUT_PDF) $(OUT_TXT) $(OUT_MAN_PAGE) $(OUT_HTML) $(OUT_PDF) : $(SOURCE) $(SOURCE_MAN_PAGE) $(INC_HEADER_PDF) $(INC_BEFORE_BODY_PDF) $(IMAGES) Makefile pandoc $(SOURCE_MAN_PAGE) -f markdown \ @@ -199,7 +200,6 @@ manual.tex : $(SOURCE) $(SOURCE_MAN_PAGE) $(INC_HEADER_PDF) $(INC_BEFORE_BODY_PD # HTML one-page (uses modified "templates/styles.html", unchanged "templates/default.html") -OUT_HTML = manual.html HTML_OPTS = --filter pandoc-tablenos -M tablenos-warning-level=0 --highlight-style=haddock \ --template=templates/default.html --eol=lf -s -t html INC_BEFORE_BODY_HTML = inc_before_body_html.html diff --git a/docs/manual.html b/docs/manual.html index a6c7a479..9c81f17a 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -3963,8 +3963,8 @@ class="footnote-ref" id="fnref14" role="doc-noteref">14 complete with any control characters15 and check characters,16 and for all linear symbologies, -including those that normally don’t set it. +role="doc-noteref">16 and for all linear and DataBar +Stacked symbologies, including those that normally don’t set it. diff --git a/docs/manual.pmd b/docs/manual.pmd index 7d20d2cc..00ca3240 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -2341,8 +2341,8 @@ Value Effect `BARCODE_RAW_TEXT` Set HRT with no decoration,[^14] complete with any control characters[^15] and check characters,[^16] - and for all linear symbologies, including those - that normally don't set it. + and for all linear and DataBar Stacked symbologies, + including those that normally don't set it. ------------------------------------------------------------------------------ Table: API `output_options` Values {#tbl:api_output_options tag="$ $"} diff --git a/docs/manual.txt b/docs/manual.txt index d9127f88..db872aa7 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -2324,8 +2324,8 @@ together when adjusting this value: BARCODE_RAW_TEXT Set HRT with no decoration,[14] complete with any control characters[15] and check characters,[16] - and for all linear symbologies, including those - that normally don’t set it. + and for all linear and DataBar Stacked symbologies, + including those that normally don’t set it. ------------------------------------------------------------------------------ : Table  : API output_options Values diff --git a/docs/zint.1.pmd b/docs/zint.1.pmd index fe5c040a..19468cd9 100644 --- a/docs/zint.1.pmd +++ b/docs/zint.1.pmd @@ -564,55 +564,55 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S `--version`). `-1` -: Human Readable Text was outputted as raw text (`ZINT_WARN_HRT_RAW_TEXT`) +: Human Readable Text was outputted as raw text (`ZINT_WARN_HRT_RAW_TEXT`) `1` -: Human Readable Text was truncated (maximum 199 bytes) (`ZINT_WARN_HRT_TRUNCATED`) +: Human Readable Text was truncated (maximum 199 bytes) (`ZINT_WARN_HRT_TRUNCATED`) `2` -: Invalid option given but overridden by Zint (`ZINT_WARN_INVALID_OPTION`) +: Invalid option given but overridden by Zint (`ZINT_WARN_INVALID_OPTION`) `3` -: Automatic ECI inserted by Zint (`ZINT_WARN_USES_ECI`) +: Automatic ECI inserted by Zint (`ZINT_WARN_USES_ECI`) `4` -: Symbol created not compliant with standards (`ZINT_WARN_NONCOMPLIANT`) +: Symbol created not compliant with standards (`ZINT_WARN_NONCOMPLIANT`) `5` -: Input data wrong length (`ZINT_ERROR_TOO_LONG`) +: Input data wrong length (`ZINT_ERROR_TOO_LONG`) `6` -: Input data incorrect (`ZINT_ERROR_INVALID_DATA`) +: Input data incorrect (`ZINT_ERROR_INVALID_DATA`) `7` -: Input check digit incorrect (`ZINT_ERROR_INVALID_CHECK`) +: Input check digit incorrect (`ZINT_ERROR_INVALID_CHECK`) `8` -: Incorrect option given (`ZINT_ERROR_INVALID_OPTION`) +: Incorrect option given (`ZINT_ERROR_INVALID_OPTION`) `9` -: Internal error (should not happen) (`ZINT_ERROR_ENCODING_PROBLEM`) +: Internal error (should not happen) (`ZINT_ERROR_ENCODING_PROBLEM`) `10` -: Error opening output file (`ZINT_ERROR_FILE_ACCESS`) +: Error opening output file (`ZINT_ERROR_FILE_ACCESS`) `11` -: Memory allocation (malloc) failure (`ZINT_ERROR_MEMORY`) +: Memory allocation (malloc) failure (`ZINT_ERROR_MEMORY`) `12` -: Error writing to output file (`ZINT_ERROR_FILE_WRITE`) +: Error writing to output file (`ZINT_ERROR_FILE_WRITE`) `13` : Error counterpart of warning if `--werror` given (`ZINT_ERROR_USES_ECI`) `14` -: Error counterpart of warning if `--werror` given (`ZINT_ERROR_NONCOMPLIANT`) +: Error counterpart of warning if `--werror` given (`ZINT_ERROR_NONCOMPLIANT`) `15` -: Error counterpart of warning if `--werror` given (`ZINT_ERROR_HRT_TRUNCATED`) +: Error counterpart of warning if `--werror` given (`ZINT_ERROR_HRT_TRUNCATED`) `16` -: Error counterpart of warning if `--werror` given (`ZINT_ERROR_HRT_RAW_TEXT`) +: Error counterpart of warning if `--werror` given (`ZINT_ERROR_HRT_RAW_TEXT`) # EXAMPLES diff --git a/tools/update_version.php b/tools/update_version.php index d2ee8383..33470889 100644 --- a/tools/update_version.php +++ b/tools/update_version.php @@ -376,8 +376,8 @@ version_replace(2, $data_dirname . 'win32/vs2019/zint.vcxproj', '/ZINT_VERSION=" print PHP_EOL; print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' . PHP_EOL; -print '!!! REMEMBER: update release date in manual and man page !!!' . PHP_EOL; -print '!!! REMEMBER: cd docs; make; make manual.html !!!' . PHP_EOL; +print '!!! REMEMBER: update release date in manual !!!' . PHP_EOL; +print '!!! REMEMBER: cd docs; make !!!' . PHP_EOL; print '!!! REMEMBER: run "autoconf" and "./configure" in "backend_tcl/" !!!' . PHP_EOL; print '!!! REMEMBER: update version and date in "ChangeLog" !!!' . PHP_EOL; print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' . PHP_EOL;