From b0503096859e5cac849e4672b6a0c4004f9a68a6 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 15 Aug 2016 10:11:57 -0400 Subject: [PATCH 38/38] FIXME: add summary comment to c-format.c --- gcc/c-family/c-format.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index bffe67c..7a3ce0e 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -33,6 +33,40 @@ along with GCC; see the file COPYING3. If not see #include "substring-locations.h" #include "selftest.h" +/* Consider the format string for a call to printf: it consists of ordinary + characters and "conversion specifications". + + A conversion specification: + - starts with character %, then has + - zero or more flags, then + - an optional minimum field width, then + - an optional precision, then + - an optional length modifier, then + - ends with a conversion specifier. + + For example in: + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + then we have a single conversion specification here: + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^^^^^^^^ + with: + - flags: "-+": + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^ + - minimum field width: "*" (read from arg3): + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^ ^^^^ + - field precision ".*" (read from arg4): + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^ ^^^^ + - length modifier "ll" (expect a "long long"): + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^ ^^^^ + - conversion specifier "d" (expect an integer type, convert + to signed decimal): + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^ ^^^^. */ + /* Handle attributes associated with format checking. */ /* This must be in the same order as format_types, except for -- 1.8.5.3