From 5c00c7893e91c35716ce12bda4ece991eb550942 Mon Sep 17 00:00:00 2001 From: Harald Oehlmann Date: Fri, 2 Nov 2018 09:09:38 +0100 Subject: [PATCH] Make it compile with MS-VC6++ --- backend/emf.c | 19 +++++++++++++------ backend/ps.c | 3 --- backend/vector.c | 12 +++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backend/emf.c b/backend/emf.c index 16016a52..2f0bd724 100644 --- a/backend/emf.c +++ b/backend/emf.c @@ -126,7 +126,7 @@ int bump_up(int input) { } int emf_plot(struct zint_symbol *symbol) { - int i; + int i,j; FILE *emf_file; int fgred, fggrn, fgblu, bgred, bggrn, bgblu; int error_number = 0; @@ -160,6 +160,13 @@ int emf_plot(struct zint_symbol *symbol) { //emr_extcreatefontindirectw_t emr_extcreatefontindirectw_big; //emr_selectobject_t emr_selectobject_font_big; +#ifdef _MSC_VER + emr_rectangle_t *rectangle; + emr_ellipse_t *circle; + emr_polygon_t *hexagon; + emr_exttextoutw_t *text; +#endif + fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); fgblu = (16 * ctoi(symbol->fgcolour[4])) + ctoi(symbol->fgcolour[5]); @@ -178,10 +185,10 @@ int emf_plot(struct zint_symbol *symbol) { emr_polygon_t hexagon[hexagon_count]; emr_exttextoutw_t text[string_count]; #else - emr_rectangle_t *rectangle = (emr_rectangle_t*) _alloca(rectangle_count * sizeof (emr_rectangle_t)); - emr_ellipse_t *circle = (emr_ellipse_t*) _alloca(circle_count * sizeof (emr_ellipse_t)); - emr_polygon_t *hexagon = (emr_polygon_t*) _alloca(hexagon_count * sizeof (emr_polygon_t)); - emr_exttextoutw_t *text = (emr_exttextoutw_t*) _alloca(string_count * sizeof (emr_exttextoutw_t)); + rectangle = (emr_rectangle_t*) _alloca(rectangle_count * sizeof (emr_rectangle_t)); + circle = (emr_ellipse_t*) _alloca(circle_count * sizeof (emr_ellipse_t)); + hexagon = (emr_polygon_t*) _alloca(hexagon_count * sizeof (emr_polygon_t)); + text = (emr_exttextoutw_t*) _alloca(string_count * sizeof (emr_exttextoutw_t)); #endif /* Header */ @@ -501,7 +508,7 @@ int emf_plot(struct zint_symbol *symbol) { fwrite(&emr_selectobject_font, sizeof (emr_selectobject_t), 1, emf_file); fwrite(&text[i], sizeof (emr_exttextoutw_t), 1, emf_file); fwrite(this_string[i], bump_up(text[i].w_emr_text.chars + 1) * 2, 1, emf_file); - for (int j = 0; j < bump_up(text[i].w_emr_text.chars + 1); j++) { + for (j = 0; j < bump_up(text[i].w_emr_text.chars + 1); j++) { fwrite(&spacing, 4, 1, emf_file); } } diff --git a/backend/ps.c b/backend/ps.c index f2185f4a..a8006ff5 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -60,9 +60,6 @@ int ps_plot(struct zint_symbol *symbol) { } if (feps == NULL) { strcpy(symbol->errtxt, "645: Could not open output file"); -#ifdef _MSC_VER - free(local_text); -#endif return ZINT_ERROR_FILE_ACCESS; } diff --git a/backend/vector.c b/backend/vector.c index e39a18f5..947a6622 100644 --- a/backend/vector.c +++ b/backend/vector.c @@ -315,7 +315,8 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { int upceanflag = 0; int rect_count, last_row_start; int this_row; - + int addon_latch = 0; + struct zint_vector_string *string; // Sanity check colours to_upper((unsigned char*) symbol->fgcolour); to_upper((unsigned char*) symbol->bgcolour); @@ -432,6 +433,8 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { if ((!symbol->show_hrt) || (ustrlen(symbol->text) == 0)) { hide_text = 1; + // HaO 2018-11-02 text_height and text_offset is an int. + // This gives the idea to me that a float is intended text_height = 0.0; text_offset = upceanflag ? 9.0 : 0.0; } else { @@ -466,8 +469,6 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { default_text_posn = symbol->height + text_offset + symbol->border_width; } - int addon_latch = 0; - // Plot rectangles - most symbols created here if ((symbol->symbology != BARCODE_MAXICODE) && ((symbol->output_options & BARCODE_DOTTY_MODE) == 0)) { for (r = 0; r < symbol->rows; r++) { @@ -527,11 +528,12 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { // Plot Maxicode symbols if (symbol->symbology == BARCODE_MAXICODE) { + struct zint_vector_circle *circle; vector->width = 37.0 + (2.0 * xoffset); vector->height = 36.0 + (2.0 * yoffset); // Bullseye - struct zint_vector_circle *circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 10.85, 0); + circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 10.85, 0); vector_plot_add_circle(symbol, circle, &last_circle); circle = vector_plot_create_circle(17.88 + xoffset, 17.8 + yoffset, 8.97, 1); vector_plot_add_circle(symbol, circle, &last_circle); @@ -793,7 +795,7 @@ int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type) { //Remove control characters from readable text // This only applies to Code 128 - struct zint_vector_string *string = symbol->vector->strings; + string = symbol->vector->strings; if (string) { for (i = 0; i < string->length; i++) { if (string->text[i] < ' ') {