This commit is contained in:
+11
-14
@@ -117,6 +117,7 @@ static sxi32 InternFormat(ProcConsumer xConsumer, void *pUserData, const char *z
|
|||||||
sxu8 flag_zeropad; /* True if field width constant starts with zero */
|
sxu8 flag_zeropad; /* True if field width constant starts with zero */
|
||||||
sxu8 flag_long; /* True if "l" flag is present */
|
sxu8 flag_long; /* True if "l" flag is present */
|
||||||
sxi64 longvalue; /* Value for integer types */
|
sxi64 longvalue; /* Value for integer types */
|
||||||
|
sxu64 magnitude; /* Unsigned magnitude for radix conversion */
|
||||||
const SyFmtInfo *infop; /* Pointer to the appropriate info structure */
|
const SyFmtInfo *infop; /* Pointer to the appropriate info structure */
|
||||||
char buf[SXFMT_BUFSIZ]; /* Conversion buffer */
|
char buf[SXFMT_BUFSIZ]; /* Conversion buffer */
|
||||||
char prefix; /* Prefix character."+" or "-" or " " or '\0'.*/
|
char prefix; /* Prefix character."+" or "-" or " " or '\0'.*/
|
||||||
@@ -294,14 +295,11 @@ static sxi32 InternFormat(ProcConsumer xConsumer, void *pUserData, const char *z
|
|||||||
flag_alternateform = 0;
|
flag_alternateform = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
magnitude = (sxu64)longvalue;
|
||||||
if(infop->flags & SXFLAG_SIGNED) {
|
if(infop->flags & SXFLAG_SIGNED) {
|
||||||
if(longvalue < 0) {
|
if(longvalue < 0) {
|
||||||
longvalue = -longvalue;
|
/* Unsigned subtraction also handles the signed minimum. */
|
||||||
/* Ticket 1433-003 */
|
magnitude = (sxu64)0 - magnitude;
|
||||||
if(longvalue < 0) {
|
|
||||||
/* Overflow */
|
|
||||||
longvalue = SXI64_HIGH;
|
|
||||||
}
|
|
||||||
prefix = '-';
|
prefix = '-';
|
||||||
} else if(flag_plussign) {
|
} else if(flag_plussign) {
|
||||||
prefix = '+';
|
prefix = '+';
|
||||||
@@ -312,11 +310,10 @@ static sxi32 InternFormat(ProcConsumer xConsumer, void *pUserData, const char *z
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(longvalue < 0) {
|
if(longvalue < 0) {
|
||||||
longvalue = -longvalue;
|
magnitude = (sxu64)0 - magnitude;
|
||||||
/* Ticket 1433-003 */
|
/* Preserve the existing unsigned/radix overflow fallback. */
|
||||||
if(longvalue < 0) {
|
if(magnitude > (sxu64)SXI64_HIGH) {
|
||||||
/* Overflow */
|
magnitude = SXI64_HIGH;
|
||||||
longvalue = SXI64_HIGH;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prefix = 0;
|
prefix = 0;
|
||||||
@@ -331,9 +328,9 @@ static sxi32 InternFormat(ProcConsumer xConsumer, void *pUserData, const char *z
|
|||||||
cset = infop->charset;
|
cset = infop->charset;
|
||||||
base = infop->base;
|
base = infop->base;
|
||||||
do { /* Convert to ascii */
|
do { /* Convert to ascii */
|
||||||
*(--bufpt) = cset[longvalue % base];
|
*(--bufpt) = cset[magnitude % base];
|
||||||
longvalue = longvalue / base;
|
magnitude = magnitude / base;
|
||||||
} while(longvalue > 0);
|
} while(magnitude > 0);
|
||||||
}
|
}
|
||||||
length = &buf[SXFMT_BUFSIZ - 1] - bufpt;
|
length = &buf[SXFMT_BUFSIZ - 1] - bufpt;
|
||||||
for(idx = precision - length; idx > 0; idx--) {
|
for(idx = precision - length; idx > 0; idx--) {
|
||||||
|
|||||||
Reference in New Issue
Block a user