From patchwork Fri May 24 20:48:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1939091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BrdEGgIF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VmHFw4v7Zz1ynR for ; Sat, 25 May 2024 06:49:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BD153858C48 for ; Fri, 24 May 2024 20:49:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by sourceware.org (Postfix) with ESMTPS id D24423858D29 for ; Fri, 24 May 2024 20:48:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D24423858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D24423858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::529 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716583729; cv=none; b=vXJyeZhRYUlURh0JEZhgRTqjyGSm+HL4zSuB6JfAUywWol01J3dp1He/dvLpnu6X6amPTHTLcStWYLTe1z1/dPl7CY/yxfINSZPutzUFC8Hw6GSaF7ha+AYcgmbyXbb2jtEAeMFmNrGRs+3+pxL2gqS6EPoL99DMXOoJjXbFY1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716583729; c=relaxed/simple; bh=5U5sKFaLPcrJ70lWADxnP04e4Z3viSD4E0cZD9RPXMI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uxzwJ5I1RyVxuZvoTEhjvh7Zulmf30qUYKspv5R0BfO+7lvjEKV/U/l4WNORTamAeNZUgrByC/UFjaUzTAMK01YFfcB39ZonNJ7Xj47/k5wPLjYLP8pYQwWK5sZ4CgKC1rqmE5cQKCJl7Ufn3CQW4UxmzZgrfwzW9TKF8ApREWg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-6818811cb8aso895999a12.0 for ; Fri, 24 May 2024 13:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716583727; x=1717188527; darn=sourceware.org; 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=58EyPiwnfp/rzFe3bPTjBDT4heG9CteaqEuiquZdl6o=; b=BrdEGgIFykCQRHcvRZ5lNkXNOs7/EU/9saMqWkCayh9cVSSwrB73J8rHwvGAQOgxY5 1DmTTjcY6rChiGxJUXSI5Lq0+3UhxKN+5YtajdEluK8WjpIoExyVLYV74ugYRddSdZ7c /bR6Yavz/RxeNvSxXLI1GfJTtCX00hu8lUbgCTYRvyirLhKh/ubEAnmVFO3vGZLa6rRx vX6yHWC8FfhUcwubbISi09gVA0PC8GIumypOFaThztqj0Qk2o5xW8pL7bW+OgCOxxOTL yP76TpcQgaSJuiHBgYD4AU/5O/JgVSMij9oQXxrQcwGxIF1FF5IQ1iR/99Zj7wPqrjWF hikA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716583727; x=1717188527; 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=58EyPiwnfp/rzFe3bPTjBDT4heG9CteaqEuiquZdl6o=; b=uzLJPNds56ANz0MOzQmfBqKMcGChNiIlus/xeExhQVJbvR+ukJ+YqnowXIwb2urMIb c1QPB9tgcEiPYUzrPEi/eoibdTzheGNZ+SSa3z4wmUsoWeGt+wHejT/qQAvklcM+U2Rp 3/UPO3HqA/6hrjOl+fqFWMY56WNJMlYZnoykTZurz+s7BEI9VTeGTPwqP9UxDYlQtHi+ Yvk2/+s2i+kRS1ls3wYvE+A/ZRYm+Jdsa+vdF2xKSOw2S9FzBx9852PsF2YMRCosvDWw RuSfFwNxbZxU64gAWb9r6ZaPk7SGJBuj075hPdHXvwKgbrAdZg/NB22z6QuD+nZ78BO5 d85g== X-Gm-Message-State: AOJu0YzZQW9tiqrt5dReWVrzIvxqqpRvJJ9wqqHbAwLSmMeMm7xCeSNq xUO+rKV2l63BfiUpiLq+U7vgwchiHK/QwL2FhtJmwhFaiNpKxSNTWhvdsQ== X-Google-Smtp-Source: AGHT+IFZmGIbkV9mW4SfpwepAdasCu1Uw+pRpnjHnm9HDnpWUVwKKkELhlGv2l2nYT8nGhvmvxunuw== X-Received: by 2002:a17:902:fa10:b0:1eb:7081:3e23 with SMTP id d9443c01a7336-1f4498e1e62mr26526305ad.66.1716583726623; Fri, 24 May 2024 13:48:46 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.129.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c9957ddsm17964705ad.190.2024.05.24.13.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 13:48:46 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 0393E7407C3; Fri, 24 May 2024 13:48:45 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH v2 1/2] Add scanf/vfscanf/vscanf tests of long double without Date: Fri, 24 May 2024 13:48:43 -0700 Message-ID: <20240524204844.3322444-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240524204844.3322444-1-hjl.tools@gmail.com> References: <20240524204844.3322444-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3021.8 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 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+incoming=patchwork.ozlabs.org@sourceware.org Update test-fscanf.c to add scanf/vfscanf/vscanf tests of long double without including . Signed-off-by: H.J. Lu --- stdio-common/test-fscanf.c | 55 ++++++++++++++++++++++++++++++++-- stdio-common/test-fscanf.input | 3 ++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/stdio-common/test-fscanf.c b/stdio-common/test-fscanf.c index f2c4250b51..26477300a5 100644 --- a/stdio-common/test-fscanf.c +++ b/stdio-common/test-fscanf.c @@ -1,4 +1,4 @@ -/* Test fscanf of long double without . +/* Test fscanf/scanf/vfscanf/vscanf of long double without . Copyright (C) 2024 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,11 +16,39 @@ License along with the GNU C Library; if not, see . */ +#include #include +#ifndef EXPECTED_LONG_DOUBLE_VALUE +# define EXPECTED_LONG_DOUBLE_VALUE 24.5 +#endif + struct FILE; extern struct FILE *stdin; extern int fscanf (struct FILE *, const char *, ...); +extern int scanf (const char *, ...); +extern int vfscanf (struct FILE *, const char *, va_list); +extern int vscanf (const char *, va_list); + +static int +wrap_vfscanf (struct FILE *fp, const char *format, ...) +{ + va_list ap; + va_start (ap, format); + int ret = vfscanf (fp, format, ap); + va_end (ap); + return ret; +} + +static int +wrap_vscanf (const char *format, ...) +{ + va_list ap; + va_start (ap, format); + int ret = vscanf (format, ap); + va_end (ap); + return ret; +} int main (void) @@ -29,8 +57,31 @@ main (void) long double x; char name[50]; n = fscanf (stdin, "%d%Lf%s", &i, &x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; + + n = scanf ("%d%Lf%s", &i, &x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; + + n = wrap_vfscanf (stdin, "%d%Lf%s", &i, &x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; - if (n != 3 || i != 25 || x != 24.5 || strcmp (name, "thompson")) + n = wrap_vscanf ("%d%Lf%s", &i, &x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) return 1; return 0; diff --git a/stdio-common/test-fscanf.input b/stdio-common/test-fscanf.input index 69322cc51a..20859d314a 100644 --- a/stdio-common/test-fscanf.input +++ b/stdio-common/test-fscanf.input @@ -1 +1,4 @@ 25 24.5 thompson +25 24.5 thompson +25 24.5 thompson +25 24.5 thompson