[devel] Imported from libpng-1.5.0beta37.tar
This commit is contained in:
parent
dd80757941
commit
4eb18e9ca2
190
png.c
190
png.c
@ -1184,112 +1184,112 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
|
|
||||||
fp *= 10;
|
fp *= 10;
|
||||||
/* Use modf here, not floor and subtract, so that
|
/* Use modf here, not floor and subtract, so that
|
||||||
* the separation is done in one step. At the end
|
* the separation is done in one step. At the end
|
||||||
* of the loop don't break the number into parts so
|
* of the loop don't break the number into parts so
|
||||||
* that the final digit is rounded.
|
* that the final digit is rounded.
|
||||||
*/
|
*/
|
||||||
if (cdigits+czero-clead+1 < (int)precision)
|
if (cdigits+czero-clead+1 < (int)precision)
|
||||||
fp = modf(fp, &d);
|
fp = modf(fp, &d);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d = floor(fp + .5);
|
d = floor(fp + .5);
|
||||||
|
|
||||||
if (d > 9)
|
if (d > 9)
|
||||||
{
|
{
|
||||||
/* Rounding up to 10, handle that here. */
|
/* Rounding up to 10, handle that here. */
|
||||||
if (czero > 0)
|
if (czero > 0)
|
||||||
{
|
{
|
||||||
--czero, d = 1;
|
--czero, d = 1;
|
||||||
if (cdigits == 0) --clead;
|
if (cdigits == 0) --clead;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (cdigits > 0 && d > 9)
|
while (cdigits > 0 && d > 9)
|
||||||
{
|
{
|
||||||
int ch = *--ascii;
|
int ch = *--ascii;
|
||||||
|
|
||||||
if (exp != (-1))
|
if (exp != (-1))
|
||||||
++exp;
|
++exp;
|
||||||
|
|
||||||
else if (ch == 46)
|
else if (ch == 46)
|
||||||
{
|
{
|
||||||
ch = *--ascii, ++size;
|
ch = *--ascii, ++size;
|
||||||
/* Advance exp to '1', so that the
|
/* Advance exp to '1', so that the
|
||||||
* decimal point happens after the
|
* decimal point happens after the
|
||||||
* previous digit.
|
* previous digit.
|
||||||
*/
|
*/
|
||||||
exp = 1;
|
exp = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
--cdigits;
|
--cdigits;
|
||||||
d = ch - 47; /* I.e. 1+(ch-48) */
|
d = ch - 47; /* I.e. 1+(ch-48) */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Did we reach the beginning? If so adjust the
|
/* Did we reach the beginning? If so adjust the
|
||||||
* exponent but take into account the leading
|
* exponent but take into account the leading
|
||||||
* decimal point.
|
* decimal point.
|
||||||
*/
|
*/
|
||||||
if (d > 9) /* cdigits == 0 */
|
if (d > 9) /* cdigits == 0 */
|
||||||
{
|
{
|
||||||
if (exp == (-1))
|
if (exp == (-1))
|
||||||
{
|
{
|
||||||
/* Leading decimal point (plus zeros?), if
|
/* Leading decimal point (plus zeros?), if
|
||||||
* we lose the decimal point here it must
|
* we lose the decimal point here it must
|
||||||
* be reentered below.
|
* be reentered below.
|
||||||
*/
|
*/
|
||||||
int ch = *--ascii;
|
int ch = *--ascii;
|
||||||
|
|
||||||
if (ch == 46)
|
if (ch == 46)
|
||||||
++size, exp = 1;
|
++size, exp = 1;
|
||||||
|
|
||||||
/* Else lost a leading zero, so 'exp' is
|
/* Else lost a leading zero, so 'exp' is
|
||||||
* still ok at (-1)
|
* still ok at (-1)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++exp;
|
++exp;
|
||||||
|
|
||||||
/* In all cases we output a '1' */
|
/* In all cases we output a '1' */
|
||||||
d = 1;
|
d = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fp = 0; /* Guarantees termination below. */
|
fp = 0; /* Guarantees termination below. */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d == 0)
|
if (d == 0)
|
||||||
{
|
{
|
||||||
++czero;
|
++czero;
|
||||||
if (cdigits == 0) ++clead;
|
if (cdigits == 0) ++clead;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Included embedded zeros in the digit count. */
|
/* Included embedded zeros in the digit count. */
|
||||||
cdigits += czero - clead;
|
cdigits += czero - clead;
|
||||||
clead = 0;
|
clead = 0;
|
||||||
|
|
||||||
while (czero > 0)
|
while (czero > 0)
|
||||||
{
|
{
|
||||||
/* exp == (-1) means we just output the decimal
|
/* exp == (-1) means we just output the decimal
|
||||||
* place - after the DP don't adjust 'exp' any
|
* place - after the DP don't adjust 'exp' any
|
||||||
* more!
|
* more!
|
||||||
*/
|
*/
|
||||||
if (exp != (-1))
|
if (exp != (-1))
|
||||||
{
|
{
|
||||||
if (exp == 0) *ascii++ = 46, --size;
|
if (exp == 0) *ascii++ = 46, --size;
|
||||||
/* PLUS 1: TOTAL 4 */
|
/* PLUS 1: TOTAL 4 */
|
||||||
--exp;
|
--exp;
|
||||||
}
|
}
|
||||||
*ascii++ = 48, --czero;
|
*ascii++ = 48, --czero;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp != (-1))
|
if (exp != (-1))
|
||||||
{
|
{
|
||||||
if (exp == 0) *ascii++ = 46, --size; /* counted above */
|
if (exp == 0) *ascii++ = 46, --size; /* counted above */
|
||||||
--exp;
|
--exp;
|
||||||
}
|
}
|
||||||
*ascii++ = 48 + (int)d, ++cdigits;
|
*ascii++ = 48 + (int)d, ++cdigits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);
|
while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);
|
||||||
@ -1306,19 +1306,19 @@ png_ascii_from_fp(png_structp png_ptr, png_charp ascii, png_size_t size,
|
|||||||
if (exp >= (-1) && exp <= 2)
|
if (exp >= (-1) && exp <= 2)
|
||||||
{
|
{
|
||||||
/* The following only happens if we didn't output the
|
/* The following only happens if we didn't output the
|
||||||
* leading zeros above for negative exponent, so this
|
* leading zeros above for negative exponent, so this
|
||||||
* doest add to the digit requirement. Note that the
|
* doest add to the digit requirement. Note that the
|
||||||
* two zeros here can only be output if the two leading
|
* two zeros here can only be output if the two leading
|
||||||
* zeros were *not* output, so this doesn't increase
|
* zeros were *not* output, so this doesn't increase
|
||||||
* the output count.
|
* the output count.
|
||||||
*/
|
*/
|
||||||
while (--exp >= 0) *ascii++ = 48;
|
while (--exp >= 0) *ascii++ = 48;
|
||||||
|
|
||||||
*ascii = 0;
|
*ascii = 0;
|
||||||
|
|
||||||
/* Total buffer requirement (including the '\0') is
|
/* Total buffer requirement (including the '\0') is
|
||||||
* 5+precision - see check at the start.
|
* 5+precision - see check at the start.
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1452,7 +1452,7 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
|||||||
* have 31 bits each, however the result may be 32 bits.
|
* have 31 bits each, however the result may be 32 bits.
|
||||||
*/
|
*/
|
||||||
png_uint_32 s16 = (A >> 16) * (T & 0xffff) +
|
png_uint_32 s16 = (A >> 16) * (T & 0xffff) +
|
||||||
(A & 0xffff) * (T >> 16);
|
(A & 0xffff) * (T >> 16);
|
||||||
/* Can't overflow because the a*times bit is only 30
|
/* Can't overflow because the a*times bit is only 30
|
||||||
* bits at most.
|
* bits at most.
|
||||||
*/
|
*/
|
||||||
@ -1486,7 +1486,7 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
|||||||
|
|
||||||
if (s32 > d32)
|
if (s32 > d32)
|
||||||
{
|
{
|
||||||
if (s00 < d00) --s32; /* carry */
|
if (s00 < d00) --s32; /* carry */
|
||||||
s32 -= d32, s00 -= d00, result += 1<<bitshift;
|
s32 -= d32, s00 -= d00, result += 1<<bitshift;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2052,7 +2052,7 @@ png_build_16bit_table(png_structp png_ptr, png_uint_16pp *ptable,
|
|||||||
|
|
||||||
# else
|
# else
|
||||||
if (shift)
|
if (shift)
|
||||||
ig = (ig * 65535U + max_by_2)/max;
|
ig = (ig * 65535U + max_by_2)/max;
|
||||||
|
|
||||||
sub_table[j] = png_gamma_16bit_correct(ig, gamma);
|
sub_table[j] = png_gamma_16bit_correct(ig, gamma);
|
||||||
# endif
|
# endif
|
||||||
|
@ -3492,10 +3492,10 @@ png_get_num_cols(png_structp png_ptr)
|
|||||||
if (png_ptr != NULL)
|
if (png_ptr != NULL)
|
||||||
{
|
{
|
||||||
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
if (png_ptr->flags & PNG_FLAG_ROW_INIT)
|
||||||
return png_ptr->iwidth;
|
return png_ptr->iwidth;
|
||||||
else
|
else
|
||||||
png_error(png_ptr, "Call png_start_read_image or png_read_update_info "
|
png_error(png_ptr, "Call png_start_read_image or png_read_update_info "
|
||||||
"before png_get_num_cols");
|
"before png_get_num_cols");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Here on error */
|
/* Here on error */
|
||||||
|
@ -701,5 +701,5 @@ png_get_user_transform_ptr(png_structp png_ptr)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
#endif /* PNG_READ_USER_TRANSFORM_SUPPORTED ||
|
||||||
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
PNG_WRITE_USER_TRANSFORM_SUPPORTED */
|
||||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||||
|
Loading…
Reference in New Issue
Block a user