diff --git a/backend/ps.c b/backend/ps.c index c74b839b..3c849b1a 100644 --- a/backend/ps.c +++ b/backend/ps.c @@ -54,17 +54,7 @@ int ps_plot(struct zint_symbol *symbol) strcpy(addon, ""); comp_offset = 0; addon_text_posn = 0.0; - - if((symbol->output_options & BARCODE_STDOUT) != 0) { - feps = stdout; - } else { - feps = fopen(symbol->outfile, "w"); - } - if(feps == NULL) { - strcpy(symbol->errtxt, "Could not open output file"); - return ZERROR_FILE_ACCESS; - } - + /* sort out colour options */ to_upper((unsigned char*)symbol->fgcolour); to_upper((unsigned char*)symbol->bgcolour); @@ -87,6 +77,16 @@ int ps_plot(struct zint_symbol *symbol) strcpy(symbol->errtxt, "Malformed background colour target"); return ZERROR_INVALID_OPTION; } + + if((symbol->output_options & BARCODE_STDOUT) != 0) { + feps = stdout; + } else { + feps = fopen(symbol->outfile, "w"); + } + if(feps == NULL) { + strcpy(symbol->errtxt, "Could not open output file"); + return ZERROR_FILE_ACCESS; + } locale = setlocale(LC_ALL, "C"); fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); diff --git a/backend/svg.c b/backend/svg.c index 8c0824a0..d61bfe41 100644 --- a/backend/svg.c +++ b/backend/svg.c @@ -51,16 +51,7 @@ int svg_plot(struct zint_symbol *symbol) comp_offset = 0; addon_text_posn = 0.0; - if((symbol->output_options & BARCODE_STDOUT) != 0) { - fsvg = stdout; - } else { - fsvg = fopen(symbol->outfile, "w"); - } - if(fsvg == NULL) { - strcpy(symbol->errtxt, "Could not open output file"); - return ZERROR_FILE_ACCESS; - } - + /* sort out colour options */ to_upper((unsigned char*)symbol->fgcolour); to_upper((unsigned char*)symbol->bgcolour); @@ -83,6 +74,17 @@ int svg_plot(struct zint_symbol *symbol) strcpy(symbol->errtxt, "Malformed background colour target"); return ZERROR_INVALID_OPTION; } + + if((symbol->output_options & BARCODE_STDOUT) != 0) { + fsvg = stdout; + } else { + fsvg = fopen(symbol->outfile, "w"); + } + if(fsvg == NULL) { + strcpy(symbol->errtxt, "Could not open output file"); + return ZERROR_FILE_ACCESS; + } + locale = setlocale(LC_ALL, "C"); fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);