Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Feb 2009 04:58:18 +0000 (UTC)
From:      David Schultz <das@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189131 - head/lib/libc/stdio
Message-ID:  <200902280458.n1S4wIka095213@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: das
Date: Sat Feb 28 04:58:18 2009
New Revision: 189131
URL: http://svn.freebsd.org/changeset/base/189131

Log:
  Make sure %zd treats negative arguments properly on 32-bit platforms.
  Fix harmless but related bugs in %_$zd and %_$tu.
  
  PR:		131880
  MFC after:	1 week

Modified:
  head/lib/libc/stdio/printf-pos.c
  head/lib/libc/stdio/vfprintf.c
  head/lib/libc/stdio/vfwprintf.c

Modified: head/lib/libc/stdio/printf-pos.c
==============================================================================
--- head/lib/libc/stdio/printf-pos.c	Sat Feb 28 02:37:55 2009	(r189130)
+++ head/lib/libc/stdio/printf-pos.c	Sat Feb 28 04:58:18 2009	(r189131)
@@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$");
 enum typeid {
 	T_UNUSED, TP_SHORT, T_INT, T_U_INT, TP_INT,
 	T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG,
-	T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET,
+	T_PTRDIFFT, TP_PTRDIFFT, T_SSIZET, T_SIZET, TP_SIZET,
 	T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR,
 	T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR
 };
@@ -145,7 +145,7 @@ addsarg(struct typetable *types, int fla
 	if (flags & INTMAXT)
 		types->table[types->nextarg++] = T_INTMAXT;
 	else if (flags & SIZET)
-		types->table[types->nextarg++] = T_SIZET;
+		types->table[types->nextarg++] = T_SSIZET;
 	else if (flags & PTRDIFFT)
 		types->table[types->nextarg++] = T_PTRDIFFT;
 	else if (flags & LLONGINT)
@@ -168,7 +168,7 @@ adduarg(struct typetable *types, int fla
 	else if (flags & SIZET)
 		types->table[types->nextarg++] = T_SIZET;
 	else if (flags & PTRDIFFT)
-		types->table[types->nextarg++] = T_PTRDIFFT;
+		types->table[types->nextarg++] = T_SIZET;
 	else if (flags & LLONGINT)
 		types->table[types->nextarg++] = T_U_LLONG;
 	else if (flags & LONGINT)
@@ -716,6 +716,9 @@ build_arg_table(struct typetable *types,
 		    case T_SIZET:
 			(*argtable) [n].sizearg = va_arg (ap, size_t);
 			break;
+		    case T_SSIZET:
+			(*argtable) [n].sizearg = va_arg (ap, ssize_t);
+			break;
 		    case TP_SIZET:
 			(*argtable) [n].psizearg = va_arg (ap, size_t *);
 			break;

Modified: head/lib/libc/stdio/vfprintf.c
==============================================================================
--- head/lib/libc/stdio/vfprintf.c	Sat Feb 28 02:37:55 2009	(r189130)
+++ head/lib/libc/stdio/vfprintf.c	Sat Feb 28 04:58:18 2009	(r189131)
@@ -399,7 +399,7 @@ __vfprintf(FILE *fp, const char *fmt0, v
 #define	INTMAX_SIZE	(INTMAXT|SIZET|PTRDIFFT|LLONGINT)
 #define SJARG() \
 	(flags&INTMAXT ? GETARG(intmax_t) : \
-	    flags&SIZET ? (intmax_t)GETARG(size_t) : \
+	    flags&SIZET ? (intmax_t)GETARG(ssize_t) : \
 	    flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \
 	    (intmax_t)GETARG(long long))
 #define	UJARG() \

Modified: head/lib/libc/stdio/vfwprintf.c
==============================================================================
--- head/lib/libc/stdio/vfwprintf.c	Sat Feb 28 02:37:55 2009	(r189130)
+++ head/lib/libc/stdio/vfwprintf.c	Sat Feb 28 04:58:18 2009	(r189131)
@@ -479,7 +479,7 @@ __vfwprintf(FILE *fp, const wchar_t *fmt
 #define	INTMAX_SIZE	(INTMAXT|SIZET|PTRDIFFT|LLONGINT)
 #define SJARG() \
 	(flags&INTMAXT ? GETARG(intmax_t) : \
-	    flags&SIZET ? (intmax_t)GETARG(size_t) : \
+	    flags&SIZET ? (intmax_t)GETARG(ssize_t) : \
 	    flags&PTRDIFFT ? (intmax_t)GETARG(ptrdiff_t) : \
 	    (intmax_t)GETARG(long long))
 #define	UJARG() \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902280458.n1S4wIka095213>