Maxicode - error correction bug and misplaced finder

This commit is contained in:
hooper114 2010-05-18 08:33:03 +00:00
parent 93d65a910c
commit 91251fbc26

View File

@ -2,7 +2,7 @@
/* /*
libzint - the open source barcode library libzint - the open source barcode library
Copyright (C) 2008 Robin Stuart <robin@zint.org.uk> Copyright (C) 2010 Robin Stuart <robin@zint.org.uk>
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -19,18 +19,14 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
/* This code has been thoroughly checked against ISO/IEC 16023:2000 */ /* Includes corrections thanks to Monica Swanson @ Source Technologies */
#include "common.h" #include "common.h"
#include "maxicode.h" #include "maxicode.h"
#include "reedsol.h" #include "reedsol.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef __APPLE__
#include <sys/malloc.h>
#else
#include <malloc.h> #include <malloc.h>
#endif
int maxi_codeword[144]; int maxi_codeword[144];
@ -52,7 +48,7 @@ void maxi_do_primary_check( )
rs_encode(datalen, data, results); rs_encode(datalen, data, results);
for ( j = 0; j < ecclen; j += 1) for ( j = 0; j < ecclen; j += 1)
maxi_codeword[ datalen + j] = results[j]; maxi_codeword[ datalen + j] = results[ecclen - 1 - j];
rs_free(); rs_free();
} }
@ -77,7 +73,7 @@ void maxi_do_secondary_chk_odd( int ecclen )
rs_encode(datalen/2, data, results); rs_encode(datalen/2, data, results);
for ( j = 0; j < (ecclen); j += 1) for ( j = 0; j < (ecclen); j += 1)
maxi_codeword[ datalen + (2 *j) + 1 + 20 ] = results[j]; maxi_codeword[ datalen + (2 *j) + 1 + 20 ] = results[ecclen - 1 - j];
rs_free(); rs_free();
} }
@ -102,7 +98,7 @@ void maxi_do_secondary_chk_even(int ecclen )
rs_encode(datalen/2, data, results); rs_encode(datalen/2, data, results);
for ( j = 0; j < (ecclen); j += 1) for ( j = 0; j < (ecclen); j += 1)
maxi_codeword[ datalen + (2 *j) + 20] = results[j]; maxi_codeword[ datalen + (2 *j) + 20] = results[ecclen - 1 - j];
rs_free(); rs_free();
} }
@ -581,13 +577,6 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
} }
memset(maxi_codeword, 0, sizeof(maxi_codeword)); memset(maxi_codeword, 0, sizeof(maxi_codeword));
if(symbol->output_options & READER_INIT) { mode = 6; }
if((mode == 6) && (symbol->input_mode == GS1_MODE)) {
strcpy(symbol->errtxt, "Cannot encode GS1 and Reader Initialisation at the same time");
return ERROR_INVALID_OPTION;
}
if(mode == -1) { /* If mode is unspecified */ if(mode == -1) { /* If mode is unspecified */
lp = strlen(symbol->primary); lp = strlen(symbol->primary);
if(lp == 0) { if(lp == 0) {
@ -695,7 +684,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[], int length)
set_module(symbol, 0, 28); // Top right filler set_module(symbol, 0, 28); // Top right filler
set_module(symbol, 0, 29); set_module(symbol, 0, 29);
set_module(symbol, 9, 10); // Top left marker set_module(symbol, 9, 10); // Top left marker
set_module(symbol, 0, 11); set_module(symbol, 9, 11);
set_module(symbol, 10, 11); set_module(symbol, 10, 11);
set_module(symbol, 15, 7); // Left hand marker set_module(symbol, 15, 7); // Left hand marker
set_module(symbol, 16, 8); set_module(symbol, 16, 8);