Commit 4723b2b9 authored by Tom Lane's avatar Tom Lane

Be more careful about the difference between signed and unsigned ints.

Bug is revealed by OID regress test on 64-bit platforms.
parent eedfac64
...@@ -74,7 +74,7 @@ typedef unsigned long ulong_long; ...@@ -74,7 +74,7 @@ typedef unsigned long ulong_long;
* causing nast effects. * causing nast effects.
**************************************************************/ **************************************************************/
/*static char _id[] = "$Id: snprintf.c,v 1.28 2000/12/03 20:45:34 tgl Exp $";*/ /*static char _id[] = "$Id: snprintf.c,v 1.29 2000/12/30 19:17:47 tgl Exp $";*/
static char *end; static char *end;
static int SnprfOverflow; static int SnprfOverflow;
...@@ -192,12 +192,12 @@ dopr(char *buffer, const char *format, va_list args) ...@@ -192,12 +192,12 @@ dopr(char *buffer, const char *format, va_list args)
if (longflag) if (longflag)
{ {
if (longlongflag) if (longlongflag)
value = va_arg(args, long_long); value = va_arg(args, ulong_long);
else else
value = va_arg(args, long); value = va_arg(args, unsigned long);
} }
else else
value = va_arg(args, int); value = va_arg(args, unsigned int);
fmtnum(value, 10, 0, ljust, len, zpad); fmtnum(value, 10, 0, ljust, len, zpad);
break; break;
case 'o': case 'o':
...@@ -206,12 +206,12 @@ dopr(char *buffer, const char *format, va_list args) ...@@ -206,12 +206,12 @@ dopr(char *buffer, const char *format, va_list args)
if (longflag) if (longflag)
{ {
if (longlongflag) if (longlongflag)
value = va_arg(args, long_long); value = va_arg(args, ulong_long);
else else
value = va_arg(args, long); value = va_arg(args, unsigned long);
} }
else else
value = va_arg(args, int); value = va_arg(args, unsigned int);
fmtnum(value, 8, 0, ljust, len, zpad); fmtnum(value, 8, 0, ljust, len, zpad);
break; break;
case 'd': case 'd':
...@@ -225,31 +225,30 @@ dopr(char *buffer, const char *format, va_list args) ...@@ -225,31 +225,30 @@ dopr(char *buffer, const char *format, va_list args)
} }
else else
value = va_arg(args, int); value = va_arg(args, int);
fmtnum(value, 10, 1, ljust, len, zpad); fmtnum(value, 10, 1, ljust, len, zpad);
break; break;
case 'x': case 'x':
if (longflag) if (longflag)
{ {
if (longlongflag) if (longlongflag)
value = va_arg(args, long_long); value = va_arg(args, ulong_long);
else else
value = va_arg(args, long); value = va_arg(args, unsigned long);
} }
else else
value = va_arg(args, int); value = va_arg(args, unsigned int);
fmtnum(value, 16, 0, ljust, len, zpad); fmtnum(value, 16, 0, ljust, len, zpad);
break; break;
case 'X': case 'X':
if (longflag) if (longflag)
{ {
if (longlongflag) if (longlongflag)
value = va_arg(args, long_long); value = va_arg(args, ulong_long);
else else
value = va_arg(args, long); value = va_arg(args, unsigned long);
} }
else else
value = va_arg(args, int); value = va_arg(args, unsigned int);
fmtnum(value, -16, 0, ljust, len, zpad); fmtnum(value, -16, 0, ljust, len, zpad);
break; break;
case 's': case 's':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment