From 891570299c28111155a7a742a943dced7623a9c2 Mon Sep 17 00:00:00 2001 From: tgotic Date: Wed, 4 May 2011 21:48:06 +0200 Subject: [PATCH] synchronized with master --- backend/2of5.c | 22 +++--- backend/auspost.c | 68 ++++++++--------- backend/code1.c | 23 +----- backend/dmatrix.c | 3 +- backend/maxicode.c | 3 + debian/changelog | 61 ++++++++++++++++ debian/control | 73 +++++++------------ debian/copyright | 5 +- debian/libzint-dev.install | 3 - debian/qzintfrontend.install | 1 - debian/zint-devel.install | 2 + ...zint-dev.install => zint-qt-devel.install} | 0 debian/{libqzint.install => zint-qt.install} | 1 + debian/{libzint.install => zint.install} | 1 + debian/zintfrontend.install | 1 - docs/README | 3 - frontend/main.c | 7 +- frontend_qt4/mainwindow.cpp | 7 +- frontend_qt4/resources.qrc | 2 +- readme | 8 ++ 20 files changed, 159 insertions(+), 135 deletions(-) delete mode 100644 debian/libzint-dev.install delete mode 100644 debian/qzintfrontend.install create mode 100644 debian/zint-devel.install rename debian/{libqzint-dev.install => zint-qt-devel.install} (100%) rename debian/{libqzint.install => zint-qt.install} (57%) rename debian/{libzint.install => zint.install} (61%) delete mode 100644 debian/zintfrontend.install delete mode 100644 docs/README diff --git a/backend/2of5.c b/backend/2of5.c index 95670d47..39e6661f 100644 --- a/backend/2of5.c +++ b/backend/2of5.c @@ -36,6 +36,10 @@ static char *C25IndustTable[10] = {"1111313111", "3111111131", "1131111131", "31 static char *C25InterTable[10] = {"11331", "31113", "13113", "33111", "11313", "31311", "13311", "11133", "31131", "13131"}; +static inline char check_digit(unsigned int count) +{ + return itoc((10 - (count % 10)) % 10); +} int matrix_two_of_five(struct zint_symbol *symbol, unsigned char source[], int length) { /* Code 2 of 5 Standard (Code 2 of 5 Matrix) */ @@ -235,7 +239,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[], int itf14(struct zint_symbol *symbol, unsigned char source[], int length) { int i, error_number, zeroes; - unsigned int count, check_digit; + unsigned int count; char localstr[16]; error_number = 0; @@ -269,9 +273,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[], int length) count += 2 * ctoi(localstr[i]); } } - check_digit = 10 - (count%10); - if (check_digit == 10) { check_digit = 0; } - localstr[13] = itoc(check_digit); + localstr[13] = check_digit(count); localstr[14] = '\0'; error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, strlen(localstr)); ustrcpy(symbol->text, (unsigned char*)localstr); @@ -281,7 +283,7 @@ int itf14(struct zint_symbol *symbol, unsigned char source[], int length) int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) { /* Deutshe Post Leitcode */ int i, error_number; - unsigned int count, check_digit; + unsigned int count; char localstr[16]; int zeroes; @@ -310,9 +312,7 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) count += 5 * ctoi(localstr[i]); } } - check_digit = 10 - (count%10); - if (check_digit == 10) { check_digit = 0; } - localstr[13] = itoc(check_digit); + localstr[13] = check_digit(count); localstr[14] = '\0'; error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, strlen(localstr)); ustrcpy(symbol->text, (unsigned char*)localstr); @@ -322,7 +322,7 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[], int length) int dpident(struct zint_symbol *symbol, unsigned char source[], int length) { /* Deutsche Post Identcode */ int i, error_number, zeroes; - unsigned int count, check_digit; + unsigned int count; char localstr[16]; count = 0; @@ -349,9 +349,7 @@ int dpident(struct zint_symbol *symbol, unsigned char source[], int length) count += 5 * ctoi(localstr[i]); } } - check_digit = 10 - (count%10); - if (check_digit == 10) { check_digit = 0; } - localstr[11] = itoc(check_digit); + localstr[11] = check_digit(count); localstr[12] = '\0'; error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, strlen(localstr)); ustrcpy(symbol->text, (unsigned char*)localstr); diff --git a/backend/auspost.c b/backend/auspost.c index c6f9149c..372eba8b 100644 --- a/backend/auspost.c +++ b/backend/auspost.c @@ -43,39 +43,24 @@ static char *AusBarTable[64] = {"000", "001", "002", "003", "010", "011", "012", #include "common.h" #include "reedsol.h" +static inline char convert_pattern(char data, int shift) +{ + return (data - '0') << shift; +} + void rs_error(char data_pattern[]) { /* Adds Reed-Solomon error correction to auspost */ - int reader, triple_writer; + int reader, triple_writer = 0; char triple[31], inv_triple[31]; unsigned char result[5]; - triple_writer = 0; - - for(reader = 2; reader < strlen(data_pattern); reader+= 3) - { - triple[triple_writer] = 0; - switch(data_pattern[reader]) + for(reader = 2; reader < strlen(data_pattern); reader += 3, triple_writer++) { - case '1': triple[triple_writer] += 16; break; - case '2': triple[triple_writer] += 32; break; - case '3': triple[triple_writer] += 48; break; - } - switch(data_pattern[reader + 1]) - { - case '1': triple[triple_writer] += 4; break; - case '2': triple[triple_writer] += 8; break; - case '3': triple[triple_writer] += 12; break; - } - switch(data_pattern[reader + 2]) - { - case '1': triple[triple_writer] += 1; break; - case '2': triple[triple_writer] += 2; break; - case '3': triple[triple_writer] += 3; break; - } - triple_writer++; - + triple[triple_writer] = convert_pattern(data_pattern[reader], 4) + + convert_pattern(data_pattern[reader + 1], 2) + + convert_pattern(data_pattern[reader + 2], 0); } for(reader = 0; reader < triple_writer; reader++) @@ -113,23 +98,35 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt char data_pattern[200]; char fcc[3] = { 0 }; char dpid[10]; - char localstr[30]; + char localstr[30] = { 0 }; error_number = 0; - strcpy(localstr, ""); /* Do all of the length checking first to avoid stack smashing */ if(symbol->symbology == BARCODE_AUSPOST) { /* Format control code (FCC) */ switch(length) { - case 8: strcpy(fcc, "11"); break; - case 13: strcpy(fcc, "59"); break; - case 16: strcpy(fcc, "59"); error_number = is_sane(NEON, source, length); break; - case 18: strcpy(fcc, "62"); break; - case 23: strcpy(fcc, "62"); error_number = is_sane(NEON, source, length); break; - default: strcpy(symbol->errtxt, "Auspost input is wrong length"); - return ZERROR_TOO_LONG; + case 8: + strcpy(fcc, "11"); + break; + case 13: + strcpy(fcc, "59"); + break; + case 16: + strcpy(fcc, "59"); + error_number = is_sane(NEON, source, length); + break; + case 18: + strcpy(fcc, "62"); + break; + case 23: + strcpy(fcc, "62"); + error_number = is_sane(NEON, source, length); + break; + default: + strcpy(symbol->errtxt, "Auspost input is wrong length"); + return ZERROR_TOO_LONG; break; } if(error_number == ZERROR_INVALID_DATA) { @@ -150,7 +147,6 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt /* Add leading zeros as required */ zeroes = 8 - length; memset(localstr, '0', zeroes); - localstr[8] = '\0'; } concat(localstr, (char*)source); @@ -195,7 +191,7 @@ int australia_post(struct zint_symbol *symbol, unsigned char source[], int lengt lookup(GDSET, AusCTable, localstr[reader], data_pattern); } } - if((h == 16) || (h == 23)) { + else if((h == 16) || (h == 23)) { for(reader = 8; reader < h; reader++) { lookup(NEON, AusNTable, localstr[reader], data_pattern); } diff --git a/backend/code1.c b/backend/code1.c index 1a41a378..488cbfbe 100644 --- a/backend/code1.c +++ b/backend/code1.c @@ -1200,29 +1200,8 @@ int code_one(struct zint_symbol *symbol, unsigned char source[], int length) data_blocks = c1_blocks[size - 1]; - /* - Section 2.2.5.1 states: - "The polynomial arithmetic... is calculated using bit-wise modulo 2 arithmetic - and byte-wise modulo 100101101 arithmetic (this is a Galois Field of 2^8 with - 100101101 representing the field's prime modulus polynomial: - x^8 + x^5 + x^3 + x^2 + 1)." - This is the same as Data Matrix (ISO/IEC 16022) however the calculations in Appendix F - of the Code One specification do not agree with those in Annex E of ISO/IEC 16022. - For example Code One Appendix F states: - "The polynomial divisor for generating ten check characters for Version T-16 - and Version A is: - g(x)=x^10 + 136x^9 + 141x^8 + 113x^7 + 76x^6 + 218x^5 + 43x^4 + 85x^3 - + 182x^2 + 31x + 52." - Whereas ISO/IEC 16022 Annex E states: - "The polynomial divisor for generating 10 check characters is: - g(x)=x^10 + 61x^9 + 110x^8 + 255x^7 + 116x^6 + 248x^5 + 223x^4 + 166x^3 - + 185x^2 + 24x + 28." - For this code I have assumed that ISO/IEC 16022 is correct and the USS Code One - specifications are incorrect - */ - rs_init_gf(0x12d); - rs_init_code(c1_ecc_blocks[size - 1], 1); + rs_init_code(c1_ecc_blocks[size - 1], 0); for(i = 0; i < data_blocks; i++) { for(j = 0; j < c1_data_blocks[size - 1]; j++) { diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 0a30b267..f052a035 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -775,7 +775,7 @@ void add_tail(unsigned char target[], int tp, int tail_length, int last_mode) int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, skew = 0; + int inputlen, i, skew = 0; unsigned char binary[2200]; int binlen; int symbolsize, optionsize, calcsize; @@ -783,6 +783,7 @@ int data_matrix_200(struct zint_symbol *symbol, unsigned char source[], int leng int H, W, FH, FW, datablock, bytes, rsblock; int last_mode; unsigned char *grid = 0; + inputlen = length; binlen = dm200encode(symbol, source, binary, &last_mode, length); diff --git a/backend/maxicode.c b/backend/maxicode.c index bd9a54cd..c39b137b 100644 --- a/backend/maxicode.c +++ b/backend/maxicode.c @@ -602,6 +602,9 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length) } if((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */ + if(lp == 0){ /* Mode set manually means lp doesn't get set */ + lp = strlen(symbol->primary); + } if(lp != 15) { strcpy(symbol->errtxt, "Invalid Primary String"); return ZERROR_INVALID_DATA; diff --git a/debian/changelog b/debian/changelog index 23d06f5d..ea29d15b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,64 @@ +zint (2.4.1) unstable; urgency=low + + * Update and review of files required by Debian including changelog. + + -- Robin Stuart Sat, 02 Oct 2010 09:26:00 +0000 + +zint (2.4) unstable; urgency=low + + * Built extensions to the API for integrating with glabels thanks + to Sam Lown and Jim Evins. + * Added code optimisation and input from stdin thanks to Ismael + Luceno. + * Reinstated escape character input. + * Simplification of Barcode Studio. + + -- Robin Stuart Sat, 02 Oct 2010 05:00:00 +0000 + +zint (2.3.2) unstable; urgency=low + + * Corrected many bugs in GS1 DataBar Extended thanks to the careful + study of the code by Pablo Orduña at the PIRAmIDE project. + * Similarly corrected some bugs in Maxicode thanks to Monica Swanson + at Source Technologies. + * Also minor bugfixes for ISBN and Aztec Code, and added some small + features like a --square option in the CLI. + + -- Robin Stuart Sat, 02 Oct 2010 04:00:00 +0000 + +zint (2.3.1) unstable; urgency=low + + * Removed Codablock-F. + * Redesigned scale function so that human readable text and Maxicode + symbols can be scaled consistently. + * Corrected encoding bugs with Code 128/Code 16k and Data Matrix ECC + 050. + * Added --notext option to CLI. + + -- Robin Stuart Sat, 02 Oct 2010 03:00:00 +0000 + +zint (2.3) unstable; urgency=low + + * Fixed problems with Micro QR Code and rebuilt QR Code support + removing dependence on libqrencode. + * Improved Kanji character support for QR Code and Micro QR Code + which now auto-detects and automatically converts to Shift-JIS. + * Added Grid Matrix symbology with Kanji character support and + automatic conversion to GB 2312. + * Removed no_qr compile option. + * Advanced Barcode Studio version number to match library version + number. + + -- Robin Stuart Sat, 02 Oct 2010 02:00:00 +0000 + +zint (2.2.2) unstable; urgency=low + + * A beta release previewing the new API structure. + * Better NULL character support with "nullchar" value removed. + * Added loading from file and sequence dialogs in Barcode Studio. + + -- Robin Stuart Sat, 02 Oct 2010 01:00:00 +0000 + zint (2.2.1-1) unstable; urgency=low * fix .so version diff --git a/debian/control b/debian/control index 30b9701e..5ae1367c 100644 --- a/debian/control +++ b/debian/control @@ -1,64 +1,43 @@ Source: zint Section: libs Priority: extra -Maintainer: BogDan Vatra -Build-Depends: cdbs, debhelper (>= 7), cmake, libpng12-dev, libqrencode-dev, libqt4-dev -Standards-Version: 3.8.1 +Maintainer: Robin Stuart +Build-Depends: cdbs, debhelper (>= 7), cmake, libpng12-dev, libqt4-dev +Standards-Version: 3.9.1 Homepage: http://www.zint.org.uk/ -Package: libzint +Package: zint Section: libs Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Zint is an Open Source barcode encoding and image generating library for Linux. - It currently features: - Over 50 symbologies including many not available in any other open source package. - Unicode translation for symbologies which support Latin-1 and Shift-JIS character sets. - Full GS1 support including data verification and automated insertion of FNC1 characters. - Support for encoding binary data including NULL (ASCII 0) characters. - Health Industry Barcode (HIBC) encoding capabilities. +Depends: libpng12-dev +Description: A library for encoding data in barcode symbols. + Zint is an Open Source barcode encoding and image generating library. + It currently features support for over 50 symbologies including + QR Code, Data Matrix, Aztec Code, Code 128, UPC/EAN, HIBC, GS1 DataBar and many others. + Also included are Unicode translation for symbologies which support Latin-1 and Kanji character sets, + full GS1 data support including verification and automated insertion of FNC1 characters and + support for encoding binary data including NULL (ASCII 0) characters. -Package: libzint-dbg -Section: libs -Architecture: any -Priority: extra -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Debugging symbols for Zint library. - This package contains debugging files used to investigate problems with - Zint binaries and libraries. - -Package: libzint-dev +Package: zint-devel Section: libdevel Architecture: any -Depends: libzint (= ${binary:Version}) -Description: Zint development files. - This package contains development files for zint. +Depends: zint (= ${binary:Version}) +Description: Zint development files + This package contains development files for the Zint barcode encoding + library. -Package: libqzint +Package: zint-qt Section: libs Architecture: any -Depends: libzint (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} -Description: Qt wrapper over Zint library - This package contains Qt wrapper over Zint library. +Depends: zint (= ${binary:Version}), libqt4-dev +Description: Zint Barcode Studio. + This package contains Zint Barcode Studio, a QT frontend for the Zint + barcode encoding library. -Package: libqzint-dev +Package: zint-qt-devel Section: libdevel Architecture: any -Depends: libqzint (= ${binary:Version}), libzint-dev (= ${source:Version}) +Depends: zint (= ${binary:Version}), zint-qt (= ${source:Version}), libqt4-dev Description: QZint development files. - This package contains development files for the Qt wrapper over Zint library.. - -Package: zintfrontend -Section: libs -Architecture: any -Depends: libzint (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} -Description: Zint console frontend. - This package contains a console frontend. - -Package: qzintfrontend -Section: libs -Architecture: any -Depends: libzint (= ${binary:Version}), libqzint (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} -Description: Zint QT frontend. - This package contains an easy to use QT frontend. - + This package contains development files for the Qt wrapper over the Zint + library. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright index 23fd34c4..edcef672 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,6 +1,7 @@ This package was debianized by: BogDan Vatra on Sat, 11 Apr 2009 23:45:53 +0300 + Modified by Robin Stuart on Sat, 02 Oct 2010 11:40:00 +0000 It was downloaded from: @@ -12,7 +13,7 @@ Upstream Author(s): Copyright: - + License: @@ -34,6 +35,6 @@ Public License version 3 can be found in `/usr/share/common-licenses/GPL-3'. The Debian packaging is: - Copyright (C) 2009 BogDan Vatra + Copyright (C) 2010 Robin Stuart and is licensed under the GPL version 3, see above. diff --git a/debian/libzint-dev.install b/debian/libzint-dev.install deleted file mode 100644 index b9ec78ba..00000000 --- a/debian/libzint-dev.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/include/zint.h -usr/lib/libzint.so -usr/share/cmake-2.6/Modules/FindZint.cmake diff --git a/debian/qzintfrontend.install b/debian/qzintfrontend.install deleted file mode 100644 index 66674579..00000000 --- a/debian/qzintfrontend.install +++ /dev/null @@ -1 +0,0 @@ -usr/bin/zint-qt diff --git a/debian/zint-devel.install b/debian/zint-devel.install new file mode 100644 index 00000000..4c8a20a2 --- /dev/null +++ b/debian/zint-devel.install @@ -0,0 +1,2 @@ +usr/include/zint.h +usr/lib/libzint.so diff --git a/debian/libqzint-dev.install b/debian/zint-qt-devel.install similarity index 100% rename from debian/libqzint-dev.install rename to debian/zint-qt-devel.install diff --git a/debian/libqzint.install b/debian/zint-qt.install similarity index 57% rename from debian/libqzint.install rename to debian/zint-qt.install index d07ebfb1..de70f44d 100644 --- a/debian/libqzint.install +++ b/debian/zint-qt.install @@ -1 +1,2 @@ usr/lib/libQZint.so.* +usr/bin/zint-qt diff --git a/debian/libzint.install b/debian/zint.install similarity index 61% rename from debian/libzint.install rename to debian/zint.install index f363cca8..d0ca3895 100644 --- a/debian/libzint.install +++ b/debian/zint.install @@ -1 +1,2 @@ usr/lib/libzint.so.* +usr/bin/zint diff --git a/debian/zintfrontend.install b/debian/zintfrontend.install deleted file mode 100644 index 294ee99a..00000000 --- a/debian/zintfrontend.install +++ /dev/null @@ -1 +0,0 @@ -usr/bin/zint diff --git a/docs/README b/docs/README deleted file mode 100644 index 2c3d1769..00000000 --- a/docs/README +++ /dev/null @@ -1,3 +0,0 @@ -Documentation has now been removed from the Zint package in -preference of the online documentation at: -http://www.zint.org.uk \ No newline at end of file diff --git a/frontend/main.c b/frontend/main.c index 444dba10..afebb949 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -208,7 +208,7 @@ int batch_process(struct zint_symbol *symbol, char *filename) char adjusted[2] = { 0 }; if(symbol->outfile[0] == '\0') { - strcpy(format_string, "$$$$$.png"); + strcpy(format_string, "~~~~~.png"); } else { if(strlen(symbol->outfile) < FILENAME_MAX) { strcpy(format_string, symbol->outfile); @@ -268,7 +268,7 @@ int batch_process(struct zint_symbol *symbol, char *filename) adjusted[0] = ' '; } break; - case '$': + case '~': if (inpos > 0) { adjusted[0] = reverse_number[inpos - 1]; inpos--; @@ -276,7 +276,7 @@ int batch_process(struct zint_symbol *symbol, char *filename) adjusted[0] = '0'; } break; - case '*': + case '@': if (inpos > 0) { adjusted[0] = reverse_number[inpos - 1]; inpos--; @@ -585,6 +585,7 @@ int main(int argc, char **argv) case 'o': strncpy(my_symbol->outfile, optarg, FILENAME_MAX - 1); + my_symbol->outfile[FILENAME_MAX - 1] = 0; break; case 'r': diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp index ec9508cf..a3a0bd51 100644 --- a/frontend_qt4/mainwindow.cpp +++ b/frontend_qt4/mainwindow.cpp @@ -163,10 +163,11 @@ bool MainWindow::save() void MainWindow::about() { QMessageBox::about(this, tr("About Zint"), - tr("

Zint Barcode Studio 2.4.1

" + tr("

Zint Barcode Studio 2.4.2

" "

A free barcode generator" - "

Visit the Zint Project Homepage at www.zint.org.uk for more information." - "

Copyright © 2010 Robin Stuart.
" + "

Instruction manual is available from Sourceforge:" + "

http://www.sourceforge.net/projects/zint" + "

Copyright © 2011 Robin Stuart.
" "Qt4 code by BogDan Vatra, MS Windows port by \"tgotic\".
" "With thanks to Norbert Szabó, and Robert Elliott." "

Released under the GNU General Public License ver. 3 or later.
" diff --git a/frontend_qt4/resources.qrc b/frontend_qt4/resources.qrc index 692d9d43..c07cce97 100644 --- a/frontend_qt4/resources.qrc +++ b/frontend_qt4/resources.qrc @@ -12,7 +12,7 @@ grpC128.ui grpChannel.ui grpCodeOne.ui - grpDBExtend.ui + grpDBExtend.ui grpDM.ui grpGrid.ui grpMaxicode.ui diff --git a/readme b/readme index ba6980a4..c060a0c5 100644 --- a/readme +++ b/readme @@ -50,6 +50,14 @@ Simplified GUI. Addition of "render" functions provides an API for glabels. Corrections to 4-state codes. Simplification in QR code. Added --dump option and support for reading from stdin. +Version 2.4.1: +Contains bugfixes for Data Matrix and QR Code. Add option to produce multiple +files from the command line. Add option to change font size in PNG images. +Tidy up information for creating Debian packages and for compiling on MS +Visual Studio. Correct bug preventing compilation without PNG support. + +Version 2.4.2: +Fix bugs in batch processing - this now works from the command line. CONTACT ME ----------