libs/libc/stdio/lib_vsprintf.c and Kconfig:

- Numbered arguments now work by using two pass parsing and an argument list.
    The maximum number of numbered args is determined by CONFIG_LIBC_NL_ARGMAX
    which is then copied into NL_ARGMAX.
  - Size of pointer argument ('p') is determined before output.

include/limits.h:  Define NL_ARGMAX (as well as some of the other 'invariant
  values' per http://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html)
This commit is contained in:
Johannes
2019-02-21 13:26:33 -06:00
committed by Gregory Nutt
parent 146c398eff
commit 0059a5a88e
3 changed files with 596 additions and 252 deletions
+67 -2
View File
@@ -1,7 +1,7 @@
/********************************************************************************
* include/limits.h
*
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2014, 2019 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -197,7 +197,7 @@
#define _POSIX_SEM_NSEMS_MAX INT_MAX
#define _POSIX_SEM_VALUE_MAX 0x7fff
/* Actual limits. These values may be increased from the POSIX minimum
/* Numerical limits. These values may be increased from the POSIX minimum
* values above or made indeterminate
*/
@@ -230,6 +230,71 @@
#define TIMER_MAX _POSIX_TIMER_MAX
#define CLOCKRES_MIN _POSIX_CLOCKRES_MIN
/* Other invariant values */
/* CHARCLASS_NAME_MAX
* Maximum number of bytes in a character class name. Minimum Acceptable
* Value: 14
*/
#define CHARCLASS_NAME_MAX 14
/* Maximum value of digit in calls to the printf() and scanf() functions.
* Minimum Acceptable Value: 9
*/
#ifdef CONFIG_LIBC_NUMBERED_ARGS
# ifdef CONFIG_LIBC_NL_ARGMAX
# define NL_ARGMAX CONFIG_LIBC_NL_ARGMAX
# else
# define NL_ARGMAX 9
# endif
#endif
/* NL_LANGMAX
* Maximum number of bytes in a LANG name. Minimum Acceptable Value: 14
*/
#define NL_LANGMAX 14
/* NL_MSGMAX
* Maximum message number. Minimum Acceptable Value: 32 67
*/
#define NL_MSGMAX 32767
/* NL_NMAX
* Maximum number of bytes in an N-to-1 collation mapping. Minimum
* Acceptable Value: *
*/
/* NL_SETMAX
* Maximum set number. Minimum Acceptable Value: 255
*/
#define NL_SETMAX 255
/* NL_TEXTMAX
* Maximum number of bytes in a message string. Minimum Acceptable Value:
* _POSIX2_LINE_MAX
*/
#define NL_TEXTMAX _POSIX2_LINE_MAX
/* NZERO
* Default process priority. Minimum Acceptable Value: 20
*/
#define NZERO 20
/* TMP_MAX
* Minimum number of unique pathnames generated by tmpnam(). Maximum
* number of times an application can call tmpnam() reliably. (LEGACY)
* Minimum Acceptable Value: 10000
*/
#define TMP_MAX10000
/* Required for asynchronous I/O */
#define AIO_LISTIO_MAX _POSIX_AIO_LISTIO_MAX
+14 -2
View File
@@ -97,16 +97,28 @@ config LIBC_PRINT_MINIMAL
config LIBC_NUMBERED_ARGS
bool "Enable numbered arguments in printf"
default n
depends on (LIBC_FLOATINGPOINT || LIBC_LONG_LONG || !LIBC_PRINT_MINIMAL) && !LIBC_PRINT_LEGACY && EXPERIMENTAL
depends on (LIBC_FLOATINGPOINT || LIBC_LONG_LONG || !LIBC_PRINT_MINIMAL) && !LIBC_PRINT_LEGACY
---help---
Enables support for numbered arguments in printf.
printf("%3$s %3$s %1$s %2$s\n", "1", "2", "3"); --> "3 3 1 2"
printf("%3$*2$.*1$f\n", 4, 8, 1.234567); --> " 1.2346"
Attention mixing of numbered and traditional arguments in one
Attention: Mixing of numbered and sequential arguments in one
format string is not allowed according to POSIX.
config LIBC_NL_ARGMAX
int "Maximum number of numbered arguments for printf"
default 16
depends on LIBC_NUMBERED_ARGS
---help---
Applies only if there are numbered arguments in your format string.
The number of sequential arguments isn't affected.
Will be copied into stdio POSIX macro NL_ARGMAX.
Attention: Increasing this value will increase stack usage
of printf.
config LIBC_SCANSET
bool "Scanset support"
default n
File diff suppressed because it is too large Load Diff