From: Alejandro Colomar <alx.manpages@gmail.com>
To: libc-alpha@sourceware.org
Cc: Alejandro Colomar <alx@kernel.org>
Subject: [PATCH v2 3/3] stdio: Add stpeprintf()
Date: Thu, 29 Dec 2022 00:17:42 +0100 [thread overview]
Message-ID: <20221228231741.125945-4-alx@kernel.org> (raw)
In-Reply-To: <20221222214217.1619716-1-alx@kernel.org>
Add variadic-argument version of vstpeprintf(3).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
libio/stdio.h | 4 ++++
stdio-common/Makefile | 1 +
stdio-common/stpeprintf.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
create mode 100644 stdio-common/stpeprintf.c
diff --git a/libio/stdio.h b/libio/stdio.h
index 59b8047ecc..7456ea6885 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -385,6 +385,10 @@ extern int vsnprintf (char *__restrict __s, size_t __maxlen,
#endif
#if __USE_GNU
+extern char *stpeprintf (char *__dest, char *__end,
+ const char *__restrict __fmt, ...)
+ __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
+
extern char *vstpeprintf (char *__dest, char *__end,
const char *__restrict __fmt, __gnuc_va_list __arg)
__THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 3e0c574ca5..d92942a86f 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -79,6 +79,7 @@ routines := \
snprintf \
sprintf \
sscanf \
+ stpeprintf \
tempnam \
tempname \
tmpfile \
diff --git a/stdio-common/stpeprintf.c b/stdio-common/stpeprintf.c
new file mode 100644
index 0000000000..7b953be3ee
--- /dev/null
+++ b/stdio-common/stpeprintf.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+char *
+stpeprintf(char *dst, char *end, const char *restrict fmt, ...)
+{
+ char *p;
+ va_list ap;
+
+ va_start(ap, fmt);
+ p = vstpeprintf(dst, end, fmt, ap);
+ va_end(ap);
+
+ return p;
+}
--
2.39.0
next prev parent reply other threads:[~2022-12-28 23:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 21:42 [PATCH 0/1] string: Add stpecpy(3) Alejandro Colomar
2022-12-22 21:42 ` [PATCH 1/1] " Alejandro Colomar
2022-12-23 7:02 ` Sam James
2022-12-23 12:26 ` Alejandro Colomar
2022-12-23 12:29 ` Alejandro Colomar
2022-12-23 17:21 ` Alejandro Colomar
2022-12-31 15:13 ` Sam James
2022-12-31 15:15 ` Alejandro Colomar
2022-12-28 23:17 ` [PATCH v2 0/3] Add stpe*() functions Alejandro Colomar
2022-12-29 0:01 ` Zack Weinberg
2022-12-29 10:13 ` Alejandro Colomar
2022-12-28 23:17 ` [PATCH v2 1/3] string: Add stpecpy() Alejandro Colomar
2022-12-28 23:27 ` Alejandro Colomar
2022-12-28 23:17 ` [PATCH v2 2/3] stdio: Add vstpeprintf() Alejandro Colomar
2022-12-28 23:17 ` Alejandro Colomar [this message]
2022-12-28 23:27 ` [PATCH v2 3/3] stdio: Add stpeprintf() Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221228231741.125945-4-alx@kernel.org \
--to=alx.manpages@gmail.com \
--cc=alx@kernel.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).