diff --git a/png.c b/png.c index 8b52f030656d369307c91ec2d639eb664c18b6b6..a226a3e08f1a39b8f8de598244f64ea1e63acb5a 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; - } - - 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; + 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; + + /* 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 c3e5591a72638cc0173780e33141acbfe44f7cfb..9e3bd20fb2252403d5cfdb113b479fabdade4228 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 55609e275a8d1c906ced6ce57c61c4bd55ef6764..47d57b349cceb50e1ada17004dd63f6a1ead545b 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 c910751a69a34447640380f3dd022a43db4a97c3..9c87ab670e4b1e2e9e0b7217cfc0146743c723ab 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 2961b5e53e05982bcf7a8b98d20bd46b8cdb05e7..0f1cd4677b6b67cc5c35ec8162843a7c51c3bc0a 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; - } - - 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); - } + 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); + + 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; - } - - 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]); - } + 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); + + 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); } } }