Replace local concat() and roundup() with C library defaults

Patch by Oxy (Michael) <virtual_worlds@gmx.de>
Ref: 34896811/
This commit is contained in:
Robin Stuart 2016-03-02 21:12:38 +00:00
parent 0a034fd5ea
commit f17f10fa7c
29 changed files with 772 additions and 837 deletions

View file

@ -56,7 +56,7 @@ int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexag
int render_plot_add_string(struct zint_symbol *symbol, unsigned char *text, float x, float y, float fsize, float width, struct zint_render_string **last_string);
int render_plot(struct zint_symbol *symbol,const float width,const float height) {
int render_plot(struct zint_symbol *symbol, const float width, const float height) {
struct zint_render *render;
struct zint_render_line *line, *last_line = NULL;
struct zint_render_string *last_string = NULL;
@ -81,6 +81,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
// Allocate memory for the rendered version
render = symbol->rendered = (struct zint_render *) malloc(sizeof (struct zint_render));
if (!symbol->rendered) return ZINT_ERROR_MEMORY;
render->lines = NULL;
render->strings = NULL;
render->rings = NULL;
@ -172,8 +173,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
break;
}
}
else if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
else if (((symbol->symbology == BARCODE_UPCA) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCA_CC)) {
upceanflag = 12;
if (symbol->whitespace_width < 10) {
symbol->whitespace_width = 10;
@ -190,8 +190,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
break;
}
}
else if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
else if (((symbol->symbology == BARCODE_UPCE) && (symbol->rows == 1)) || (symbol->symbology == BARCODE_UPCE_CC)) {
upceanflag = 6;
if (symbol->whitespace_width == 0) {
symbol->whitespace_width = 10;
@ -228,7 +227,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
if (large_bar_count == 0) {
required_aspect = width / height;
symbol_aspect = (total_symbol_width_x + (2 * xoffset)) / (preset_height + (2 * yoffset) + text_offset + text_height);
symbol->height = (int)preset_height;
symbol->height = (int) preset_height;
if (required_aspect > symbol_aspect) {
/* the area is too wide */
scaler = height / (preset_height + (2 * yoffset) + text_offset + text_height);
@ -242,7 +241,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
}
} else {
scaler = width / (total_symbol_width_x + (2 * xoffset));
symbol->height = (int)((height / scaler) - ((2 * yoffset) + text_offset + text_height));
symbol->height = (int) ((height / scaler) - ((2 * yoffset) + text_offset + text_height));
render->width = width;
render->height = height;
@ -276,8 +275,7 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
render->height = ((x_dimension * ((2 * symbol->border_width) + text_offset + text_height)) + 5.0) * GL_CONST;
}
}
else if(symbol->symbology == BARCODE_CODE49) {
else if (symbol->symbology == BARCODE_CODE49) {
/* The minimum X-dimension of Code 49 is 0.191mm */
if (x_dimension < 0.191) {
render->width = 0.191 * GL_CONST * total_area_width_x;
@ -315,21 +313,18 @@ int render_plot(struct zint_symbol *symbol,const float width,const float height
render->width = 0.508 * GL_CONST * total_area_width_x;
render->height = 4.064 * GL_CONST;
}
else if((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) {
else if ((symbol->symbology == BARCODE_POSTNET) || (symbol->symbology == BARCODE_PLANET)) {
/* The size of PostNet and PLANET are fized */
render->width = 0.508 * GL_CONST * total_area_width_x;
render->height = 2.921 * GL_CONST;
}
else if(((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) ||
else if (((symbol->symbology == BARCODE_AUSPOST) || (symbol->symbology == BARCODE_AUSREPLY)) ||
((symbol->symbology == BARCODE_AUSROUTE) || (symbol->symbology == BARCODE_AUSREDIRECT))) {
/* Australia Post use the same sizes as USPS */
render->width = 0.508 * GL_CONST * total_area_width_x;
render->height = 4.064 * GL_CONST;
}
else if((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) {
else if ((symbol->symbology == BARCODE_RM4SCC) || (symbol->symbology == BARCODE_KIX)) {
/* Royal Mail and KIX Code uses 22 bars per inch */
render->width = 0.577 * GL_CONST * total_area_width_x;
render->height = 5.22 * GL_CONST;
@ -696,7 +691,7 @@ struct zint_render_line *render_plot_create_line(float x, float y, float width,
* next value.
*/
int render_plot_add_line(struct zint_symbol *symbol, struct zint_render_line *line, struct zint_render_line **last_line) {
if (!line) return ZINT_ERROR_MEMORY;
if (!line) return ZINT_ERROR_MEMORY;
if (*last_line)
(*last_line)->next = line;
else
@ -721,7 +716,7 @@ struct zint_render_ring *render_plot_create_ring(float x, float y, float radius,
}
int render_plot_add_ring(struct zint_symbol *symbol, struct zint_render_ring *ring, struct zint_render_ring **last_ring) {
if (!ring) return ZINT_ERROR_MEMORY;
if (!ring) return ZINT_ERROR_MEMORY;
if (*last_ring)
(*last_ring)->next = ring;
else
@ -744,7 +739,7 @@ struct zint_render_hexagon *render_plot_create_hexagon(float x, float y) {
}
int render_plot_add_hexagon(struct zint_symbol *symbol, struct zint_render_hexagon *hexagon, struct zint_render_hexagon **last_hexagon) {
if (!hexagon) return ZINT_ERROR_MEMORY;
if (!hexagon) return ZINT_ERROR_MEMORY;
if (*last_hexagon)
(*last_hexagon)->next = hexagon;
else