From 8438d1298d6454841d940e2ac18787822a45fa8c Mon Sep 17 00:00:00 2001 From: hooper114 Date: Thu, 16 Oct 2008 19:10:34 +0000 Subject: [PATCH] Corrected Code 11 check digits --- backend/code.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/backend/code.c b/backend/code.c index a7ef6d59..e152b3c7 100644 --- a/backend/code.c +++ b/backend/code.c @@ -82,6 +82,7 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) int h, c_digit, c_weight, c_count, k_digit, k_weight, k_count; int weight[1000], error_number; char dest[1000]; + char checkstr[3]; error_number = 0; strcpy(dest, ""); @@ -120,8 +121,6 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) } c_digit = c_count%11; - /* Draw C checksum */ - lookup(NASET, C11Table, itoc(c_digit), dest); weight[ustrlen(source)] = c_digit; /* Calculate K checksum */ @@ -135,18 +134,21 @@ int code_11(struct zint_symbol *symbol, unsigned char source[]) } k_digit = k_count%11; - /* Draw K checksum */ - lookup(NASET, C11Table, itoc(k_digit), dest); - + checkstr[0] = itoc(c_digit); + checkstr[1] = itoc(k_digit); + if(checkstr[0] == 'A') { checkstr[0] = '-'; } + if(checkstr[1] == 'A') { checkstr[1] = '-'; } + checkstr[2] = '\0'; + lookup(NASET, C11Table, checkstr[0], dest); + lookup(NASET, C11Table, checkstr[1], dest); + /* Stop character */ concat (dest, "11221"); - - h = ustrlen(source); - source[h] = itoc(c_digit); - source[h + 1] = itoc(k_digit); - source[h + 2] = '\0'; + expand(symbol, dest); + strcpy(symbol->text, (char*)source); + concat(symbol->text, checkstr); return error_number; }