diff --git a/backend/code49.c b/backend/code49.c index 64fe280c..9caa0484 100644 --- a/backend/code49.c +++ b/backend/code49.c @@ -329,7 +329,9 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], const int length } symbol->whitespace_width = 10; - symbol->output_options += BARCODE_BIND; + if (!(symbol->output_options & BARCODE_BIND)) { + symbol->output_options += BARCODE_BIND; + } symbol->border_width = 2; return 0; diff --git a/backend/dotcode.c b/backend/dotcode.c index 0f0b29e0..993506ea 100644 --- a/backend/dotcode.c +++ b/backend/dotcode.c @@ -302,7 +302,7 @@ int seventeen_ten(unsigned char source[], int position, int length) { * returning the resulting number of codewords (Annex F.II.E) */ int ahead_c(unsigned char source[], int position, int length) { - int count = 0; + int count = 0; int i; for (i = position; (i < length) && datum_c(source, i, length); i += 2) { @@ -327,7 +327,7 @@ int try_c(unsigned char source[], int position, int length) { /* Annex F.II.G */ int ahead_a(unsigned char source[], int position, int length) { - int count = 0; + int count = 0; int i; for (i = position; ((i < length) && datum_a(source, i, length)) @@ -340,7 +340,7 @@ int ahead_a(unsigned char source[], int position, int length) { /* Annex F.II.H */ int ahead_b(unsigned char source[], int position, int length) { - int count = 0; + int count = 0; int i; for (i = position; ((i < length) && datum_b(source, i, length)) @@ -1050,8 +1050,8 @@ int dotcode(struct zint_symbol *symbol, unsigned char source[], int length) { unsigned char codeword_array[length * 3]; unsigned char masked_codeword_array[length * 3]; #else - char* dot_stream; - char* dot_array; + char* dot_stream; + char* dot_array; unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char)); unsigned char* masked_codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char)); #endif /* _MSC_VER */ @@ -1249,7 +1249,9 @@ int dotcode(struct zint_symbol *symbol, unsigned char source[], int length) { symbol->row_height[k] = 1; } - symbol->output_options += BARCODE_DOTTY_MODE; + if (!(symbol->output_options & BARCODE_DOTTY_MODE)) { + symbol->output_options += BARCODE_DOTTY_MODE; + } return 0; } \ No newline at end of file diff --git a/backend/library.c b/backend/library.c index d912dd50..a5a1826d 100644 --- a/backend/library.c +++ b/backend/library.c @@ -570,13 +570,17 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour if (symbol->symbology == BARCODE_CODE16K) { symbol->whitespace_width = 16; symbol->border_width = 2; - symbol->output_options += BARCODE_BIND; + if (!(symbol->output_options & BARCODE_BIND)) { + symbol->output_options += BARCODE_BIND; + } } if (symbol->symbology == BARCODE_ITF14) { symbol->whitespace_width = 20; symbol->border_width = 8; - symbol->output_options += BARCODE_BOX; + if (!(symbol->output_options & BARCODE_BOX)) { + symbol->output_options += BARCODE_BOX; + } } switch (symbol->input_mode) { diff --git a/backend/pcx.c b/backend/pcx.c index c0c71a95..4525f804 100644 --- a/backend/pcx.c +++ b/backend/pcx.c @@ -35,10 +35,10 @@ #include #include "common.h" #include "pcx.h" /* PCX header structure */ -#include -#ifdef _MSC_VER -#include -#include +#include +#ifdef _MSC_VER +#include +#include #endif #define SSET "0123456789ABCDEF" @@ -49,11 +49,11 @@ int pcx_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width int row, column, i, colour; int run_count; FILE *pcx_file; - pcx_header_t header; -#ifdef _MSC_VER - char* rotated_bitmap; - unsigned char* rle_row; -#endif + pcx_header_t header; +#ifdef _MSC_VER + char* rotated_bitmap; + unsigned char* rle_row; +#endif #ifndef _MSC_VER char rotated_bitmap[image_height * image_width]; @@ -180,7 +180,7 @@ int pcx_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width } /* Open output file in binary mode */ - if ((symbol->output_options & BARCODE_STDOUT) != 0) { + if (symbol->output_options & BARCODE_STDOUT) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { strcpy(symbol->errtxt, "Can't open output file"); diff --git a/backend/png.c b/backend/png.c index cb08dcd5..3210baf4 100644 --- a/backend/png.c +++ b/backend/png.c @@ -131,7 +131,7 @@ int png_pixel_plot(struct zint_symbol *symbol, int image_height, int image_width bgblu = (16 * ctoi(symbol->bgcolour[4])) + ctoi(symbol->bgcolour[5]); /* Open output file in binary mode */ - if ((symbol->output_options & BARCODE_STDOUT) != 0) { + if (symbol->output_options & BARCODE_STDOUT) { #ifdef _MSC_VER if (-1 == _setmode(_fileno(stdout), _O_BINARY)) { strcpy(symbol->errtxt, "Can't open output file"); diff --git a/backend/ps.c b/backend/ps.c index add5a9bd..5d06a962 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -99,7 +99,7 @@ int ps_plot(struct zint_symbol *symbol) { } } - if ((symbol->output_options & BARCODE_STDOUT) != 0) { + if (symbol->output_options & BARCODE_STDOUT) { feps = stdout; } else { feps = fopen(symbol->outfile, "w"); @@ -848,7 +848,7 @@ int ps_plot(struct zint_symbol *symbol) { /* Do nothing! (It's already been done) */ break; default: - if ((symbol->output_options & BARCODE_BIND) != 0) { + if (symbol->output_options & BARCODE_BIND) { if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { /* row binding */ fprintf(feps, "TE\n"); @@ -862,7 +862,7 @@ int ps_plot(struct zint_symbol *symbol) { } } } - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { fprintf(feps, "TE\n"); if ((symbol->output_options & CMYK_COLOUR) == 0) { fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink); @@ -872,7 +872,7 @@ int ps_plot(struct zint_symbol *symbol) { fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, textoffset * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler); fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", symbol->border_width * scaler, (textoffset + symbol->height + symbol->border_width) * scaler, 0.0, (symbol->width + xoffset + xoffset) * scaler); } - if ((symbol->output_options & BARCODE_BOX) != 0) { + if (symbol->output_options & BARCODE_BOX) { /* side bars */ fprintf(feps, "TE\n"); if ((symbol->output_options & CMYK_COLOUR) == 0) { diff --git a/backend/raster.c b/backend/raster.c index d13c1c5a..a5c5719b 100644 --- a/backend/raster.c +++ b/backend/raster.c @@ -292,7 +292,7 @@ int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, int data_ image_height = 300 + (2 * yoffset * 2); if (!(pixelbuf = (char *) malloc(image_width * image_height))) { - printf("Insifficient memory for pixel buffer"); + printf("Insufficient memory for pixel buffer"); return ZINT_ERROR_ENCODING_PROBLEM; } else { for (i = 0; i < (image_width * image_height); i++) { @@ -319,13 +319,13 @@ int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, int data_ } } - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { /* boundary bars */ draw_bar(pixelbuf, 0, image_width, 0, symbol->border_width * 2, image_width, image_height); draw_bar(pixelbuf, 0, image_width, 300 + (symbol->border_width * 2), symbol->border_width * 2, image_width, image_height); } - if ((symbol->output_options & BARCODE_BOX) != 0) { + if (symbol->output_options & BARCODE_BOX) { /* side bars */ draw_bar(pixelbuf, 0, symbol->border_width * 2, 0, image_height, image_width, image_height); draw_bar(pixelbuf, 300 + ((symbol->border_width + symbol->whitespace_width + symbol->whitespace_width) * 2), symbol->border_width * 2, 0, image_height, image_width, image_height); @@ -619,7 +619,7 @@ int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_t } } - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { default_text_posn = image_height - 17; } else { default_text_posn = image_height - 17 - symbol->border_width - symbol->border_width; @@ -867,7 +867,7 @@ int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_t xoffset -= comp_offset; /* Put boundary bars or box around symbol */ - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { /* boundary bars */ draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, textoffset * 2, symbol->border_width * 2, image_width, image_height); draw_bar(pixelbuf, 0, (symbol->width + xoffset + xoffset) * 2, (textoffset + symbol->height + symbol->border_width) * 2, symbol->border_width * 2, image_width, image_height); @@ -881,7 +881,7 @@ int plot_raster_default(struct zint_symbol *symbol, int rotate_angle, int data_t } } - if ((symbol->output_options & BARCODE_BOX) != 0) { + if (symbol->output_options & BARCODE_BOX) { /* side bars */ draw_bar(pixelbuf, 0, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height); draw_bar(pixelbuf, (symbol->width + xoffset + xoffset - symbol->border_width) * 2, symbol->border_width * 2, textoffset * 2, (symbol->height + (2 * symbol->border_width)) * 2, image_width, image_height); @@ -931,7 +931,7 @@ int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_type) { } #endif /* NO_PNG */ - if (symbol->output_options &= BARCODE_DOTTY_MODE) { + if (symbol->output_options & BARCODE_DOTTY_MODE) { error = plot_raster_dotty(symbol, rotate_angle, file_type); } else { if (symbol->symbology == BARCODE_MAXICODE) { diff --git a/backend/render.c b/backend/render.c index aa5d7de4..92dcbdb3 100644 --- a/backend/render.c +++ b/backend/render.c @@ -248,7 +248,7 @@ int render_plot(struct zint_symbol *symbol, const float width, const float heigh } large_bar_height = (symbol->height - preset_height) / large_bar_count; - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { default_text_posn = (symbol->height + text_offset + symbol->border_width + symbol->border_width) * scaler; } else { default_text_posn = (symbol->height + text_offset + symbol->border_width) * scaler; @@ -643,13 +643,13 @@ int render_plot(struct zint_symbol *symbol, const float width, const float heigh } } } - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { line = render_plot_create_line(0, 0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler); render_plot_add_line(symbol, line, &last_line); line = render_plot_create_line(0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler); render_plot_add_line(symbol, line, &last_line); } - if ((symbol->output_options & BARCODE_BOX) != 0) { + if (symbol->output_options & BARCODE_BOX) { /* side bars */ line = render_plot_create_line(0, 0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler); render_plot_add_line(symbol, line, &last_line); diff --git a/backend/svg.c b/backend/svg.c index 0ca80259..64576eb2 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -95,7 +95,7 @@ int svg_plot(struct zint_symbol *symbol) { } } - if ((symbol->output_options & BARCODE_STDOUT) != 0) { + if (symbol->output_options & BARCODE_STDOUT) { fsvg = stdout; } else { fsvg = fopen(symbol->outfile, "w"); @@ -230,7 +230,7 @@ int svg_plot(struct zint_symbol *symbol) { fprintf(fsvg, " \n", (int)ceil((74.0F + xoffset + xoffset) * scaler), (int)ceil((72.0F + yoffset + yoffset) * scaler), symbol->bgcolour); } - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { default_text_posn = (symbol->height + textoffset + symbol->border_width + symbol->border_width) * scaler; } else { default_text_posn = (symbol->height + textoffset + symbol->border_width) * scaler; @@ -242,11 +242,11 @@ int svg_plot(struct zint_symbol *symbol) { textoffset = 0.0; - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { fprintf(fsvg, " \n", 0.0, 0.0, (74.0 + xoffset + xoffset) * scaler, symbol->border_width * scaler); fprintf(fsvg, " \n", 0.0, (72.0 + symbol->border_width) * scaler, (74.0 + xoffset + xoffset) * scaler, symbol->border_width * scaler); } - if ((symbol->output_options & BARCODE_BOX) != 0) { + if (symbol->output_options & BARCODE_BOX) { /* side bars */ fprintf(fsvg, " \n", 0.0, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler); fprintf(fsvg, " \n", (74.0 + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (72.0 + (2 * symbol->border_width)) * scaler); @@ -307,7 +307,7 @@ int svg_plot(struct zint_symbol *symbol) { } row_posn += yoffset; - if ((symbol->output_options & BARCODE_DOTTY_MODE) != 0) { + if (symbol->output_options & BARCODE_DOTTY_MODE) { /* Use (currently undocumented) dot mode - see SF ticket #29 */ for (i = 0; i < symbol->width; i++) { if (module_is_set(symbol, this_row, i)) { @@ -609,7 +609,7 @@ int svg_plot(struct zint_symbol *symbol) { /* Do nothing! (It's already been done) */ break; default: - if ((symbol->output_options & BARCODE_BIND) != 0) { + if (symbol->output_options & BARCODE_BIND) { if ((symbol->rows > 1) && (is_stackable(symbol->symbology) == 1)) { /* row binding */ for (r = 1; r < symbol->rows; r++) { @@ -617,11 +617,11 @@ int svg_plot(struct zint_symbol *symbol) { } } } - if (((symbol->output_options & BARCODE_BOX) != 0) || ((symbol->output_options & BARCODE_BIND) != 0)) { + if ((symbol->output_options & BARCODE_BOX) || (symbol->output_options & BARCODE_BIND)) { fprintf(fsvg, " \n", 0.0, 0.0, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler); fprintf(fsvg, " \n", 0.0, (symbol->height + symbol->border_width) * scaler, (symbol->width + xoffset + xoffset) * scaler, symbol->border_width * scaler); } - if ((symbol->output_options & BARCODE_BOX) != 0) { + if (symbol->output_options & BARCODE_BOX) { /* side bars */ fprintf(fsvg, " \n", 0.0, 0.0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler); fprintf(fsvg, " \n", (symbol->width + xoffset + xoffset - symbol->border_width) * scaler, 0.0, symbol->border_width * scaler, (symbol->height + (2 * symbol->border_width)) * scaler); diff --git a/backend_qt4/qzint.cpp b/backend_qt4/qzint.cpp index 93dd956f..eb199fd9 100644 --- a/backend_qt4/qzint.cpp +++ b/backend_qt4/qzint.cpp @@ -331,7 +331,7 @@ namespace Zint { gwidth *= (maxi_width + 1); } - if (m_zintSymbol->output_options &= BARCODE_DOTTY_MODE) { + if (m_zintSymbol->output_options & BARCODE_DOTTY_MODE) { gwidth += 2.0; gheight += 2.0; } @@ -476,7 +476,7 @@ namespace Zint { painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w + w * 1.5, w + w * 1.5); painter.drawEllipse(QPointF(14.5 * w, 16.5 * w * 0.868), w + w * 3, w + w * 3); painter.restore(); - } else if (m_zintSymbol->output_options &= BARCODE_DOTTY_MODE) { + } else if (m_zintSymbol->output_options & BARCODE_DOTTY_MODE) { /* Draw with dots (circles) */ p.setColor(m_fgColor);