From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 8C6DA385840E for ; Wed, 28 Dec 2022 23:18:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C6DA385840E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x329.google.com with SMTP id g25-20020a7bc4d9000000b003d97c8d4941so6611462wmk.4 for ; Wed, 28 Dec 2022 15:18:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DoZtCDOkrM6EHl1iFqQN+zASRMnaJqWoyBzRsyneBuY=; b=KSBNVvlVU5Vj12ChnXa/QKAtTH01TN/9ZYY4xMZq3tJO6x7uoA4U6LUABAnMl4j8Tx khfjZzxEnDXg6BVkud1m0e0WriStqKxt2I4Uar/n6a5+lt6P0xW4olumyCNCJYNOFSxB tYST4D24dJaAB3w7r5sy5/Oc1VslcxKvo/Pvl0K2Et3LFHAOTayh3k1LUYUD3s7ZE8zQ uGn9Ng+asw29Ie2wJKa61RhX8/CK1iCC2jHX7Tl2sEsVyTa6HGksZIw290kYosu7S452 9565b4UaLQdF3qyfdgDEKFp/1f3WptmKQ2KxKLpm6t6pp3lTSBgJkz3z75McsS82BtZO 61zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DoZtCDOkrM6EHl1iFqQN+zASRMnaJqWoyBzRsyneBuY=; b=sZXxw9+bAR/g5eCvMZidYsxe6B4fhcya+plgBGNmoZriTtwlmPphwqHbe1fBbNs7Co j13/xh+CuDeFtNVP9e93v6JnFd2J5e85ihIvjsbDEL7xyB+geVgM3CdzINdt4y5cYcVO veJRKvkddAvAM9QEkrC5jOREneVb7nq4TXpJ5A1FpO3b2m26JDUd7jfd1H3/dZvZVFYs NkyhwVvCmGmWQOiWkYOGbXWaRiWeWWNXPFSdoaGMoSh3cTglib6b7L3rKMgjlbTq/3X9 HyH1+JyV+MIFd8MwBiBrTOZRiSR8yB69cWhdapeEWXup73XYIg2ChK5fCuLhKcM5t1U+ Ycpw== X-Gm-Message-State: AFqh2krsQDYrdZmqj4eLrKqC+daQBvCiv5e1FK8LJ3sQ9Fps5qfOZwf1 u0EnKHZMcxx6nop27RcniqPRrsAVyP8= X-Google-Smtp-Source: AMrXdXuTE6GO6n3hjCvth8C9M0s82A4Q1KBGH/biD42Fk1fgSIO8TMx/97UIvqXI7U704/ahAYcDTQ== X-Received: by 2002:a05:600c:5022:b0:3d3:5893:f4f8 with SMTP id n34-20020a05600c502200b003d35893f4f8mr18528044wmr.23.1672269492343; Wed, 28 Dec 2022 15:18:12 -0800 (PST) Received: from asus5775.alejandro-colomar.es ([170.253.36.171]) by smtp.googlemail.com with ESMTPSA id l27-20020a05600c1d1b00b003cfd4e6400csm24357367wms.19.2022.12.28.15.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 15:18:12 -0800 (PST) From: Alejandro Colomar X-Google-Original-From: Alejandro Colomar To: libc-alpha@sourceware.org Cc: Alejandro Colomar Subject: [PATCH v2 3/3] stdio: Add stpeprintf() Date: Thu, 29 Dec 2022 00:17:42 +0100 Message-Id: <20221228231741.125945-4-alx@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221222214217.1619716-1-alx@kernel.org> References: <20221222214217.1619716-1-alx@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2474; i=alx@kernel.org; h=from:subject; bh=jRfHgxMuuV9d9q5jrJ21qiWg0ydbJD3ABOsvXrNYPjo=; b=owEBbQKS/ZANAwAKAZ6MGvu+/9syAcsmYgBjrM6N+DPBQjRj0CoGlNT1Zws8wAZ5MBp0pbjRr0cp vkmOD3CJAjMEAAEKAB0WIQTqOofwpOugMORd8kCejBr7vv/bMgUCY6zOjQAKCRCejBr7vv/bMqp1D/ 4/9FPcrfaZAq8WRFnupmj6YdvtQ19NzJLK0U56RFH6W+wMvxDBRE54OxpNzHB4n5NVw+i2tXdMD/QL a7O71e161DzJ8n6Er7kzSD6ZtfjXPmNDfKEdvAhYUHiH5l1mNOcT+q32vXlHKT/bkrutARJv98nws4 D0+Q6DeEkxQxwTHc6Nv6ipiRpB8DRSKDnboZhdSPU9tLtLR26smkAEcsC4BTFmhwhCawzSHRcOiXSr U+11OVoDZSuE76p1mX4xgVqPhRPeQvDtWtyfsGnT0N4ptomSXcTDJDp2Kb1m8w68U5Ecs2n9QCMA/z x5FxpSH4j/tNEwFWLqLzgfhnOAVJq6BdyiV/AMkc8rEkGF5aovdEdCbEwoB3QEpKk/cuPz4Dn572nL a0TEFVsc5w7pXOIpc4ZmFq56M0qaT3Ky2tsDtpNGCtggtV0HJcAduXJ+QqPSG9jpz/vZ7jd4z5z8yE YmmXKD/2mGJvwZWu1ayhADVCM3SPBx3UdB/JPHrPO16yz8S9tFU8NNS6UEQOo94CostGAqCWnUxFrd p4I1/+JZMjYlqZfOLc7jKTYrg/hlMzv1TM6Dzoontuj8pBjRbwYoOKv1GZ1Vcfc0Gq6NFptRgu7YwS MaYJfeec+J5Z8+12qAmCQJZbw22+ibOVsUidiT59VCxkHtOUEPhzm1+GBsgw== X-Developer-Key: i=alx@kernel.org; a=openpgp; fpr=A9348594CE31283A826FBDD8D57633D441E25BB5 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Add variadic-argument version of vstpeprintf(3). Signed-off-by: Alejandro Colomar --- 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 + . */ + +#include +#include + +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