This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: printf and NL_ARGMAX


Eric Blake wrote:
Currently, if configured with --enable-newlib-io-pos-args, printf
hard-codes the decision of how many %n$ positional parameters to support
with MAX_POS_ARGS set to 32.  But since I hope to fix scanf to also
support positional parameters, this should probably be fixed to follow
POSIX and refer to NL_ARGMAX in limits.h.  Furthermore, POSIX only
requires support for 9 positional parameters, so it should be possible for
newlib clients to alter how much storage printf requires by setting
NL_ARGMAX in their limits.h override.

OK to apply?

Ok.

-- Jeff J.
2007-04-21 Eric Blake <ebb9@byu.net>

	* libc/include/limits.h (NL_ARGMAX): Define a default value.
	* libc/stdio/vfprintf.c (MAX_POS_ARGS): Define in terms of
	NL_ARGMAX, if present.

------------------------------------------------------------------------

Index: libc/include/limits.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/limits.h,v
retrieving revision 1.1
diff -u -p -r1.1 limits.h
--- libc/include/limits.h 11 Sep 2002 18:36:39 -0000 1.1
+++ libc/include/limits.h 21 Apr 2007 12:46:51 -0000
@@ -9,6 +9,11 @@
# define MB_LEN_MAX 1
# endif
+/* Maximum number of positional arguments, if _WANT_IO_POS_ARGS. */
+# ifndef NL_ARGMAX
+# define NL_ARGMAX 32
+# endif
+
/* if do not have #include_next support, then we
have to define the limits here. */
# if !defined __GNUC__ || __GNUC__ < 2
@@ -124,4 +129,3 @@
/* `_GCC_LIMITS_H_' is what GCC's file defines. */
# include_next <limits.h>
#endif /* __GNUC__ && !_GCC_LIMITS_H_ */
-
Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.49
diff -u -p -r1.49 vfprintf.c
--- libc/stdio/vfprintf.c 13 Apr 2007 01:57:33 -0000 1.49
+++ libc/stdio/vfprintf.c 21 Apr 2007 12:46:51 -0000
@@ -320,7 +320,11 @@ typedef int * int_ptr_t;
typedef short * short_ptr_t;
#ifndef _NO_POS_ARGS
-#define MAX_POS_ARGS 32
+# ifdef NL_ARGMAX
+# define MAX_POS_ARGS NL_ARGMAX
+# else
+# define MAX_POS_ARGS 32
+# endif
union arg_val
{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]