diff --git a/png.c b/png.c index 8b52f0306..a226a3e08 100644 --- a/png.c +++ b/png.c @@ -1402,49 +1402,49 @@ png_ascii_from_fixed(png_structp png_ptr, png_charp ascii, png_size_t size, if (num <= 0x80000000U) /* else overflowed */ { - unsigned ndigits = 0, first = 16/*flag value*/; + unsigned ndigits = 0, first = 16/*flag value*/; char digits[10]; - while (num) - { - /* Split the low digit off num: */ - unsigned tmp = num/10; - num -= tmp*10; - digits[ndigits++] = (char)(48 + num); - /* Record the first non-zero digit, note that this is a number - * starting at 1, it's not actually the array index. - */ - if (first == 16 && num > 0) - first = ndigits; - num = tmp; - } + while (num) + { + /* Split the low digit off num: */ + unsigned tmp = num/10; + num -= tmp*10; + digits[ndigits++] = (char)(48 + num); + /* Record the first non-zero digit, note that this is a number + * starting at 1, it's not actually the array index. + */ + if (first == 16 && num > 0) + first = ndigits; + num = tmp; + } - if (ndigits > 0) - { - while (ndigits > 5) *ascii++ = digits[--ndigits]; - /* The remaining digits are fractional digits, ndigits is '5' or - * smaller at this point. It is certainly not zero. Check for a - * non-zero fractional digit: - */ - if (first <= 5) - { - unsigned i; - *ascii++ = 46; /* decimal point */ - /* ndigits may be <5 for small numbers, output leading zeros then - * ndigits digits to first: - */ - i = 5; - while (ndigits < i) *ascii++ = 48, --i; - while (ndigits >= first) *ascii++ = digits[--ndigits]; - /* Don't output the trailing zeros! */ - } - } - else - *ascii++ = 48; + if (ndigits > 0) + { + while (ndigits > 5) *ascii++ = digits[--ndigits]; + /* The remaining digits are fractional digits, ndigits is '5' or + * smaller at this point. It is certainly not zero. Check for a + * non-zero fractional digit: + */ + if (first <= 5) + { + unsigned i; + *ascii++ = 46; /* decimal point */ + /* ndigits may be <5 for small numbers, output leading zeros then + * ndigits digits to first: + */ + i = 5; + while (ndigits < i) *ascii++ = 48, --i; + while (ndigits >= first) *ascii++ = digits[--ndigits]; + /* Don't output the trailing zeros! */ + } + } + else + *ascii++ = 48; - /* And null terminate the string: */ - *ascii = 0; - return; + /* And null terminate the string: */ + *ascii = 0; + return; } } @@ -2020,8 +2020,8 @@ png_gamma_8bit_correct(unsigned value, png_fixed_point gamma) if (png_muldiv(&res, gamma, log, PNG_FP_1)) return png_exp8bit(res); - /* Overflow. */ - value = 0; + /* Overflow. */ + value = 0; # endif } @@ -2043,8 +2043,8 @@ png_gamma_16bit_correct(unsigned value, png_fixed_point gamma) if (png_muldiv(&res, gamma, log, PNG_FP_1)) return png_exp16bit(res); - /* Overflow. */ - value = 0; + /* Overflow. */ + value = 0; # endif } diff --git a/pngget.c b/pngget.c index c3e5591a7..9e3bd20fb 100644 --- a/pngget.c +++ b/pngget.c @@ -216,7 +216,7 @@ png_get_pixel_aspect_ratio_fixed(png_structp png_ptr, png_infop info_ptr) if (png_muldiv(&res, info_ptr->y_pixels_per_unit, PNG_FP_1, info_ptr->x_pixels_per_unit)) - return res; + return res; } #endif return 0; diff --git a/pngpread.c b/pngpread.c index 55609e275..47d57b349 100644 --- a/pngpread.c +++ b/pngpread.c @@ -1214,7 +1214,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 { info_ptr = info_ptr; /* To quiet some compiler warnings */ png_error(png_ptr, "Out of place tEXt"); - /*NOT REACHED*/ + /*NOT REACHED*/ } #ifdef PNG_MAX_MALLOC_64K diff --git a/pngrutil.c b/pngrutil.c index c910751a6..9c87ab670 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -3075,8 +3075,8 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, } default: png_error(png_ptr, "Ignoring bad adaptive filter type"); - /*NOT REACHED */ - break; + /*NOT REACHED */ + break; } } diff --git a/pngwrite.c b/pngwrite.c index 2961b5e53..0f1cd4677 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1228,20 +1228,20 @@ png_init_filter_heuristics(png_structp png_ptr, int heuristic_method, png_ptr->prev_filters[i] = 255; } - png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); + png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); + png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * num_weights)); - for (i = 0; i < num_weights; i++) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } + for (i = 0; i < num_weights; i++) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } - /* Safe to set this now */ - png_ptr->num_prev_filters = (png_byte)num_weights; + /* Safe to set this now */ + png_ptr->num_prev_filters = (png_byte)num_weights; } /* If, in the future, there are other filter methods, this would @@ -1249,17 +1249,17 @@ png_init_filter_heuristics(png_structp png_ptr, int heuristic_method, */ if (png_ptr->filter_costs == NULL) { - png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); + png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); - png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); + png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr, + (png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST)); } for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) { - png_ptr->inv_filter_costs[i] = - png_ptr->filter_costs[i] = PNG_COST_FACTOR; + png_ptr->inv_filter_costs[i] = + png_ptr->filter_costs[i] = PNG_COST_FACTOR; } /* All the arrays are inited, safe to set this: */ @@ -1300,20 +1300,20 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, int i; for (i = 0; i < num_weights; i++) { - if (filter_weights[i] <= 0.0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } + if (filter_weights[i] <= 0.0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } - else - { - png_ptr->inv_filter_weights[i] = - (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5); + else + { + png_ptr->inv_filter_weights[i] = + (png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5); - png_ptr->filter_weights[i] = - (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5); - } + png_ptr->filter_weights[i] = + (png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5); + } } /* Here is where we set the relative costs of the different filters. We @@ -1325,11 +1325,11 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, */ for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0) { - png_ptr->inv_filter_costs[i] = - (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5); + png_ptr->inv_filter_costs[i] = + (png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5); - png_ptr->filter_costs[i] = - (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5); + png_ptr->filter_costs[i] = + (png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5); } } } @@ -1355,20 +1355,20 @@ png_set_filter_heuristics_fixed(png_structp png_ptr, int heuristic_method, int i; for (i = 0; i < num_weights; i++) { - if (filter_weights[i] <= 0) - { - png_ptr->inv_filter_weights[i] = - png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; - } + if (filter_weights[i] <= 0) + { + png_ptr->inv_filter_weights[i] = + png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR; + } - else - { - png_ptr->inv_filter_weights[i] = (png_uint_16) - ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1); + else + { + png_ptr->inv_filter_weights[i] = (png_uint_16) + ((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1); - png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR* - PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]); - } + png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR* + PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]); + } } /* Here is where we set the relative costs of the different filters. We @@ -1381,11 +1381,11 @@ png_set_filter_heuristics_fixed(png_structp png_ptr, int heuristic_method, for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= PNG_FP_1) { - png_ptr->inv_filter_costs[i] = (png_uint_16)((PNG_COST_FACTOR* - PNG_FP_1+(filter_costs[i]/2)) / filter_costs[i]); + png_ptr->inv_filter_costs[i] = (png_uint_16)((PNG_COST_FACTOR* + PNG_FP_1+(filter_costs[i]/2)) / filter_costs[i]); - png_ptr->filter_costs[i] = (png_uint_16) - ((PNG_COST_FACTOR * filter_costs[i] +PNG_FP_HALF)/PNG_FP_1); + png_ptr->filter_costs[i] = (png_uint_16) + ((PNG_COST_FACTOR * filter_costs[i] +PNG_FP_HALF)/PNG_FP_1); } } }