From f40b429dbf87a57345849472224ac222e805e9e3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 28 Apr 2011 15:02:15 -0700 Subject: [PATCH] Document doprnt's behavior a bit better. --- src/doprnt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doprnt.c b/src/doprnt.c index 838581f7acd..e9a68f9d219 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -70,7 +70,9 @@ along with GNU Emacs. If not, see . */ %character where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length - is empty or l or ll. + is empty or l or ll. Also, %% in a format stands for a single % in the + output. A % that does not introduce a valid %-sequence causes + undefined behavior. The + flag character inserts a + before any positive number, while a space inserts a space before any positive number; these flags only affect %d, %o, @@ -129,8 +131,11 @@ along with GNU Emacs. If not, see . */ /* Generate output from a format-spec FORMAT, terminated at position FORMAT_END. + (*FORMAT_END is not part of the format, but must exist and be readable.) Output goes in BUFFER, which has room for BUFSIZE chars. - If the output does not fit, truncate it to fit. + BUFSIZE must be positive. If the output does not fit, truncate it + to fit and return BUFSIZE - 1; if this truncates a multibyte + sequence, store '\0' into the sequence's first byte. Returns the number of bytes stored into BUFFER, excluding the terminating null byte. Output is always null-terminated. String arguments are passed as C strings. -- 2.39.2