From 2c5e7332e9791d5e6603ec75bc7aab0ff1c04200 Mon Sep 17 00:00:00 2001 From: hooper114 Date: Thu, 9 Jul 2009 09:07:37 +0000 Subject: [PATCH] Comply with Rule 2 --- backend/code128.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/backend/code128.c b/backend/code128.c index bf1ce25c..5ea5307e 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -675,17 +675,35 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[]) for(i = 0; i < read; i++) { if(set[i] == 'C') { if(reduced[i] == '[') { - if(c_count % 2) { set[i - c_count] = 'B'; } + if(c_count % 2) { + if((i - c_count) != 0) { + set[i - c_count] = 'B'; + } else { + set[i - 1] = 'B'; + } + } c_count = 0; } else { c_count++; } } else { - if(c_count % 2) { set[i - c_count] = 'B'; } + if(c_count % 2) { + if((i - c_count) != 0) { + set[i - c_count] = 'B'; + } else { + set[i - 1] = 'B'; + } + } c_count = 0; } } - if(c_count % 2) { set[i - c_count] = 'B'; } + if(c_count % 2) { + if((i - c_count) != 0) { + set[i - c_count] = 'B'; + } else { + set[i - 1] = 'B'; + } + } /* for(i = 0; i < read; i++) { printf("char %c mode %c\n", reduced[i], set[i]);