From 188cfcdd1fce556d0e013409b17107a74164872b Mon Sep 17 00:00:00 2001 From: Harald Oehlmann Date: Mon, 4 Jul 2016 12:08:08 +0200 Subject: [PATCH] Compile MS-VC6 compatible: only define variables after "{" or at top --- backend/hanxin.c | 17 ++++++++++++++--- backend/png.c | 5 +++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/backend/hanxin.c b/backend/hanxin.c index 0f58dc48..3840957b 100644 --- a/backend/hanxin.c +++ b/backend/hanxin.c @@ -331,6 +331,7 @@ void calculate_binary(char binary[], char mode[], int source[], int length) { int first_byte, second_byte; int third_byte, fourth_byte; int glyph; + int submode; do { block_length = 0; @@ -413,7 +414,7 @@ void calculate_binary(char binary[], char mode[], int source[], int length) { } } - int submode = 1; + submode = 1; i = 0; @@ -1283,7 +1284,6 @@ int hx_apply_bitmask(unsigned char *grid, int size) { /* Han Xin Code - main */ int han_xin(struct zint_symbol *symbol, const unsigned char source[], int length) { - char mode[length + 1]; int est_binlen; int ecc_level = symbol->option_1; int i, j, version, posn = 0, glyph, glyph2; @@ -1298,9 +1298,16 @@ int han_xin(struct zint_symbol *symbol, const unsigned char source[], int length #ifndef _MSC_VER int utfdata[length + 1]; int gbdata[(length + 1) * 2]; + char mode[length + 1]; #else int* utfdata = (int *) _alloca((length + 1) * sizeof (int)); int* gbdata = (int *) _alloca(((length + 1) * 2) * sizeof (int)); + char* mode = (char *) _alloca((length + 1) * sizeof (char)); + char* binary; + unsigned char *datastream; + unsigned char *fullstream; + unsigned char *picket_fence; + unsigned char *grid; #endif switch (symbol->input_mode) { @@ -1368,7 +1375,11 @@ int han_xin(struct zint_symbol *symbol, const unsigned char source[], int length est_codewords++; } - char binary[est_binlen + 1]; +#ifndef _MSC_VER + char binary[est_binlen + 1]; +#else + binary = (char *) _alloca((est_binlen + 1) * sizeof (char));; +#endif for (i = 0; i < est_binlen + 1; i++) { binary[i] = '\0'; } diff --git a/backend/png.c b/backend/png.c index 86f1b593..7949cfb4 100644 --- a/backend/png.c +++ b/backend/png.c @@ -598,7 +598,8 @@ void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int yposn, int break; case 2: // bold font -> twice the regular font - { + { + char * linePtr; max_x = 7; max_y = 14; @@ -610,7 +611,7 @@ void draw_letter(char *pixelbuf, unsigned char letter, int xposn, int yposn, int max_y = image_height - yposn - 1; } - char * linePtr = pixelbuf + (yposn * image_width) + xposn + 1; + linePtr = pixelbuf + (yposn * image_width) + xposn + 1; for (y = 0; y < max_y; y++) { char * pixelPtr = linePtr; int extra_dot = 0;