From patchwork Fri Feb 9 15:25:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 85531 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4FD9E3858011 for ; Fri, 9 Feb 2024 15:26:58 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 548DD3858292 for ; Fri, 9 Feb 2024 15:25:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 548DD3858292 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 548DD3858292 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707492339; cv=none; b=K/MNHLSO+Cp78wYHF8QEoYQ/MB3xJCFeCA+bfkC39xCFK6IXjiNdeBZXRq3NeemZyrPYqYE0zC0pXJ6QfplwMO3PHVJcW3wpXRdk0gzmj3WJ6WKLnTpgFfQDPRvFSmqvXg1CB2FsSdfQDBkJFKOKVtvAzLspHQIF320Lw/+sNsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707492339; c=relaxed/simple; bh=1qhPUFg2iig3XQA3d7IWjNgLnk97RgXy39PQ3VQ4KiU=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=u+kq5jAmu6WOXndcy1eriZer59at2BEgwRH9YYbRc/BW9HPpEdaAONudw53g2NbtFkGgSGcg4InnzwmF4qulcJOhEwWgsYlFYNwLSxTBl071iiUPrciNrxmdgEmgyIKK3CjL+HSR9/XLfLvx21QZmQtXuXzXTKMOyqUIac1pgOU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707492336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t/NoYXUrkb4feYtxyno0FEE9yQA0mxg7BNX5uaM4+Dw=; b=JpQDHNl2KSVnEb1M6aK84fmvEcRnPcO64eK+rIaM6PxKa7kAIQtTsV7r6YdKLYdZtaNuoY hnm+Xz0wFeEFzI7y0G07lbpwvWrNwTAprlaJNX01scigiFbb7NazHiB3gloSCexBLA84Js R7c1Um6j0nDFQs55i7gKqpg0TMNFChs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-C9PN-VKeN_ykFVjhJpI5lw-1; Fri, 09 Feb 2024 10:25:34 -0500 X-MC-Unique: C9PN-VKeN_ykFVjhJpI5lw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7BE1385A58C for ; Fri, 9 Feb 2024 15:25:34 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.58]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B44FB1103A for ; Fri, 9 Feb 2024 15:25:33 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 06/11] stdio: Rename __printf_buffer to __vfprintf_buffer In-Reply-To: Message-ID: References: X-From-Line: c23bed2f8fed8be96f0b56f3b81430515e6ccf24 Mon Sep 17 00:00:00 2001 Date: Fri, 09 Feb 2024 16:25:32 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org And __wprintf_buffer to __vwprintf_buffer. These functions take a va_list argument, so they are closer to the v-variant functions in . Also move the declaration to , which is arguably a better fit than (which contains lots of printf internals). Reviewed-by: Adhemerval Zanella --- include/printf.h | 9 +-------- include/printf_buffer.h | 9 +++++++++ libio/iovdprintf.c | 2 +- libio/iovsprintf.c | 2 +- libio/obprintf.c | 2 +- libio/vasprintf.c | 2 +- libio/vsnprintf.c | 2 +- libio/vswprintf.c | 2 +- stdio-common/vfprintf-internal.c | 10 ++++++---- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/printf.h b/include/printf.h index 2c998059d4..78aac4dcad 100644 --- a/include/printf.h +++ b/include/printf.h @@ -65,18 +65,11 @@ int __translated_number_width (locale_t loc, const char *first, const char *last) attribute_hidden; - -struct __printf_buffer; -void __printf_buffer (struct __printf_buffer *buf, const char *format, - va_list ap, unsigned int mode_flags); -struct __wprintf_buffer; -void __wprintf_buffer (struct __wprintf_buffer *buf, const wchar_t *format, - va_list ap, unsigned int mode_flags); - extern int __printf_fp (FILE *, const struct printf_info *, const void *const *); libc_hidden_proto (__printf_fp) +struct __printf_buffer; void __printf_fphex_l_buffer (struct __printf_buffer *, locale_t, const struct printf_info *, const void *const *) attribute_hidden; diff --git a/include/printf_buffer.h b/include/printf_buffer.h index eff8e3413a..fb0b42178e 100644 --- a/include/printf_buffer.h +++ b/include/printf_buffer.h @@ -200,6 +200,12 @@ int __printf_buffer_done (struct __printf_buffer *buf) attribute_hidden; known, and the flush implementation can be called directly. */ bool __printf_buffer_flush (struct __printf_buffer *buf) attribute_hidden; +/* Building block for printf-style functions. Write argument list AP + to BUF according to FORMAT. MODE_FLAGS contains PRINTF_* flags + defined in . */ +void __vprintf_buffer (struct __printf_buffer *buf, const char *format, + va_list ap, unsigned int mode_flags) attribute_hidden; + /* Wide version of struct __printf_buffer follows. */ enum __wprintf_buffer_mode @@ -274,6 +280,9 @@ int __wprintf_buffer_done (struct __wprintf_buffer *buf) attribute_hidden; bool __wprintf_buffer_flush (struct __wprintf_buffer *buf) attribute_hidden; +void __vwprintf_buffer (struct __wprintf_buffer *buf, const wchar_t *format, + va_list ap, unsigned int mode_flags) attribute_hidden; + /* Type-generic convenience macros. They are useful if printf_buffer-char.h or printf_buffer-wchar_t.h is included as well. */ diff --git a/libio/iovdprintf.c b/libio/iovdprintf.c index 6894fa8347..47d9d0ba8f 100644 --- a/libio/iovdprintf.c +++ b/libio/iovdprintf.c @@ -66,7 +66,7 @@ __vdprintf_internal (int d, const char *format, va_list arg, __printf_buffer_init (&buf.base, buf.buf, array_length (buf.buf), __printf_buffer_mode_dprintf); buf.fd = d; - __printf_buffer (&buf.base, format, arg, mode_flags); + __vprintf_buffer (&buf.base, format, arg, mode_flags); if (__printf_buffer_has_failed (&buf.base)) return -1; __printf_buffer_flush_dprintf (&buf); diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c index 2d81ee3507..7fdc06dcd4 100644 --- a/libio/iovsprintf.c +++ b/libio/iovsprintf.c @@ -59,7 +59,7 @@ __vsprintf_internal (char *string, size_t maxlen, __printf_buffer_init_end (&buf, string, (char *) ~(uintptr_t) 0, __printf_buffer_mode_sprintf); - __printf_buffer (&buf, format, args, mode_flags); + __vprintf_buffer (&buf, format, args, mode_flags); /* Write the NUL terminator if there is room. Do not use the putc operation to avoid overflowing the character write count. */ diff --git a/libio/obprintf.c b/libio/obprintf.c index 491d14fbae..24d1edf260 100644 --- a/libio/obprintf.c +++ b/libio/obprintf.c @@ -92,7 +92,7 @@ __obstack_vprintf_internal (struct obstack *obstack, const char *format, /* Now allocate the rest of the current chunk. */ obstack_blank_fast (obstack, room); - __printf_buffer (&buf.base, format, args, mode_flags); + __vprintf_buffer (&buf.base, format, args, mode_flags); if (buf.base.write_ptr == &buf.ch + 1) /* buf.ch is in use. Put it into the obstack. */ diff --git a/libio/vasprintf.c b/libio/vasprintf.c index 999ae526f4..edcfab2323 100644 --- a/libio/vasprintf.c +++ b/libio/vasprintf.c @@ -99,7 +99,7 @@ __vasprintf_internal (char **result_ptr, const char *format, va_list args, __printf_buffer_init (&buf.base, buf.direct, array_length (buf.direct), __printf_buffer_mode_asprintf); - __printf_buffer (&buf.base, format, args, mode_flags); + __vprintf_buffer (&buf.base, format, args, mode_flags); int done = __printf_buffer_done (&buf.base); if (done < 0) { diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c index dd7a585cbe..7077fcd9f2 100644 --- a/libio/vsnprintf.c +++ b/libio/vsnprintf.c @@ -93,7 +93,7 @@ __vsnprintf_internal (char *string, size_t maxlen, const char *format, { struct __printf_buffer_snprintf buf; __printf_buffer_snprintf_init (&buf, string, maxlen); - __printf_buffer (&buf.base, format, args, mode_flags); + __vprintf_buffer (&buf.base, format, args, mode_flags); return __printf_buffer_snprintf_done (&buf); } diff --git a/libio/vswprintf.c b/libio/vswprintf.c index 5990bd2eff..d73246ba41 100644 --- a/libio/vswprintf.c +++ b/libio/vswprintf.c @@ -41,7 +41,7 @@ __vswprintf_internal (wchar_t *string, size_t maxlen, const wchar_t *format, struct __wprintf_buffer buf; __wprintf_buffer_init (&buf, string, maxlen, __wprintf_buffer_mode_swprintf); - __wprintf_buffer (&buf, format, args, mode_flags); + __vwprintf_buffer (&buf, format, args, mode_flags); if (buf.write_ptr == buf.write_end) { diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c index 771beca9bf..23754232f2 100644 --- a/stdio-common/vfprintf-internal.c +++ b/stdio-common/vfprintf-internal.c @@ -122,6 +122,7 @@ #ifndef COMPILE_WPRINTF # include "printf_buffer-char.h" +# define VFPRINTF_BUFFER __vprintf_buffer # define vfprintf __vfprintf_internal # define OTHER_CHAR_T wchar_t # define UCHAR_T unsigned char @@ -136,6 +137,7 @@ typedef const char *THOUSANDS_SEP_T; # define CONVERT_FROM_OTHER_STRING __wcsrtombs #else # include "printf_buffer-wchar_t.h" +# define VFPRINTF_BUFFER __vwprintf_buffer # define vfprintf __vfwprintf_internal # define OTHER_CHAR_T char /* This is a hack!!! There should be a type uwchar_t. */ @@ -595,8 +597,8 @@ static void group_number (struct Xprintf_buffer *buf, /* The buffer-based function itself. */ void -Xprintf_buffer (struct Xprintf_buffer *buf, const CHAR_T *format, - va_list ap, unsigned int mode_flags) +VFPRINTF_BUFFER (struct Xprintf_buffer *buf, const CHAR_T *format, + va_list ap, unsigned int mode_flags) { /* The character used as thousands separator. */ THOUSANDS_SEP_T thousands_sep = 0; @@ -1541,7 +1543,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags) { struct Xprintf (buffer_to_file) wrap; Xprintf (buffer_to_file_init) (&wrap, s); - Xprintf_buffer (&wrap.base, format, ap, mode_flags); + VFPRINTF_BUFFER (&wrap.base, format, ap, mode_flags); return Xprintf (buffer_to_file_done) (&wrap); } @@ -1556,7 +1558,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags) Xprintf (buffer_to_file_init) (&wrap, s); /* Perform the printing operation on the buffer. */ - Xprintf_buffer (&wrap.base, format, ap, mode_flags); + VFPRINTF_BUFFER (&wrap.base, format, ap, mode_flags); done = Xprintf (buffer_to_file_done) (&wrap); /* Unlock the stream. */