From patchwork Wed Aug 14 19:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 95866 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 B462D3858428 for ; Wed, 14 Aug 2024 20:00:09 +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 ESMTP id F0CC03858D34 for ; Wed, 14 Aug 2024 19:59:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0CC03858D34 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 F0CC03858D34 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=1723665586; cv=none; b=qdISParGSUxBTsBB4SdXaAIQsZaPL6LUrfpLqufPkYzDHNDZ2Xme1aEy3FNJAy/M0jch9mXZt8ks/t5ACXo0QMDTm5oa0ucunTOi7UKdm1vCGSUx+BcMvF/6GUbB/o2WfFZMG5PdM2+h+5YNAFxYS79B46lMRdfjMj8w/4sKBQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723665586; c=relaxed/simple; bh=v0XexK7JHKymdJr8lddkRPYpj73Gvxf9A3GB+FSekuY=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=duou4hY7hBHyCQm92a2xkQaP/3pKSJyyW0Df52T473odV8+ZnfjkAVrlG5mgtGCCqWDssRWRNleOJ6SJ2/PixFIQH7nXi9c60wHFfnGKoW4o4pES7pdJQ38yPP07QNBKS8uKOTu+Dbg5OvA8xnK6VC4FtJissAFGXPtA/9bmsXQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723665584; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=FnLAq/mKw/RP9x7oPCGDxT8az0ZpiRRgsCL9B7CKAFc=; b=O3oRkiDi7pLDI0ZqzSnNtq21QJmwZt8wKk8oxK3yFz5X29OZpjj3v1eFImyYkmVrax8d0j uB9Z1XacVqZveGQ1e2V6ZZ7D5J4EQSOU7gyrIgEDml12khIL3xWv1cf+hhMO5VYK936Sbn d2rKbAk9SOO6BJcn6lfIo6cf8pxhsQM= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-REvo7BfLNC6cUdeSqVAmvQ-1; Wed, 14 Aug 2024 15:59:43 -0400 X-MC-Unique: REvo7BfLNC6cUdeSqVAmvQ-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52fcf2b5287so223753e87.0 for ; Wed, 14 Aug 2024 12:59:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723665581; x=1724270381; h=mime-version:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FnLAq/mKw/RP9x7oPCGDxT8az0ZpiRRgsCL9B7CKAFc=; b=mUhiFrONfqYt4QAUDlspQAvqpXgPafB29TiMdL6vlOLIXkeYP7ieh/CyhXfYYgdvQR lpdUHjKiWJ34O/4Sln1B+WLkmTyy+27KVia/Co2ne0zZgyQ24bLS+zTzo+DC1uTuElYs ph/9FJT27BUv1Je7eZk2FY6Zg9W1biCO6pAwsQ4uUt1tbaJJNMjorNqcn89zCrByGhW8 aMwgNI7mICMeigC44qXV77l+spzA91y4vgEg7zbEIlJ/VqWwuTeUP0OMitDvDNmB3HrY 4M6GGd85XJuIvauVs6p6xTitarzY35ZvzF43Yfq2aGbVWjcUwOUQqTHrnWc6pxqP6oC6 3QFA== X-Gm-Message-State: AOJu0YxJ45i/1aiF1RPsky8eOcboeG/7fFhopv4xZHIZNWnIg03C/0ac 1om5njUlZ9tpOaPiboj5QHBNdtTV+GbL04d0Dv5lkjqxA43YFi26n+CE3Bbhut9jhmSHemX65s7 rv+fi5dPU9hhweNysMHZ35uRGpC8SeKXwpsw5yHvX3B09TfqyW1syVC5lcAYATJhJDeMJBhe/jW 8rJYGfFFpDRlZc1935IAuJ18XKbhMcbAcMrBfjiguFCA== X-Received: by 2002:a05:6512:ac5:b0:52e:be2c:4b05 with SMTP id 2adb3069b0e04-532eda6be6fmr2665955e87.21.1723665581442; Wed, 14 Aug 2024 12:59:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxoTURNb7jP5azrzv9dBh8QjN/m6QokzANduKGeh7xsPi20ozwwDh5VJoV+p+YM32IC86ijQ== X-Received: by 2002:a05:6512:ac5:b0:52e:be2c:4b05 with SMTP id 2adb3069b0e04-532eda6be6fmr2665938e87.21.1723665580679; Wed, 14 Aug 2024 12:59:40 -0700 (PDT) Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [2001:8b0:bf73:93f7::51bb:e332]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429e7e1cc7bsm187255e9.47.2024.08.14.12.59.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 12:59:40 -0700 (PDT) Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.95) (envelope-from ) id 1seK8s-00AeCO-TD for libc-alpha@sourceware.org; Wed, 14 Aug 2024 19:58:46 +0000 Date: Wed, 14 Aug 2024 19:58:46 +0000 (UTC) From: Joseph Myers To: libc-alpha@sourceware.org Subject: Add more tests of strtod end pointer Message-ID: <79aa8aa0-fca7-9024-ef7-5e2f744cdd9f@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.1 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_H4, 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 Although there are some tests in tst-strtod2 and tst-strtod3 for the end pointer provided by strtod when it doesn't parse the whole string, they aren't very thorough. Add tests of more such cases to tst-strtod2. Tested for x86_64. --- This patch is relative to a tree with (pending review) applied. diff --git a/stdlib/tst-strtod2.c b/stdlib/tst-strtod2.c index 2cb0953fa9..c84bd792c1 100644 --- a/stdlib/tst-strtod2.c +++ b/stdlib/tst-strtod2.c @@ -1,3 +1,4 @@ +#include #include #include @@ -17,10 +18,46 @@ struct test_strto ## FSUF \ { "0x.0y", 0.0 ## LSUF, 4 }, \ { ".y", 0.0 ## LSUF, 0 }, \ { "0.y", 0.0 ## LSUF, 2 }, \ - { ".0y", 0.0 ## LSUF, 2 } \ + { ".0y", 0.0 ## LSUF, 2 }, \ + { "1.0e", 1.0 ## LSUF, 3 }, \ + { "1.0e+", 1.0 ## LSUF, 3 }, \ + { "1.0e-", 1.0 ## LSUF, 3 }, \ + { "1.0ex", 1.0 ## LSUF, 3 }, \ + { "1.0e+x", 1.0 ## LSUF, 3 }, \ + { "1.0e-x", 1.0 ## LSUF, 3 }, \ + { "0x1p", 1.0 ## LSUF, 3 }, \ + { "0x1p+", 1.0 ## LSUF, 3 }, \ + { "0x1p-", 1.0 ## LSUF, 3 }, \ + { "0x1px", 1.0 ## LSUF, 3 }, \ + { "0x1p+x", 1.0 ## LSUF, 3 }, \ + { "0x1p-x", 1.0 ## LSUF, 3 }, \ + { "INFx", INFINITY, 3 }, \ + { "infx", INFINITY, 3 }, \ + { "INFINITx", INFINITY, 3 }, \ + { "infinitx", INFINITY, 3 }, \ + { "INFINITYY", INFINITY, 8 }, \ + { "infinityy", INFINITY, 8 }, \ + { "NANx", NAN, 3 }, \ + { "nanx", NAN, 3 }, \ + { "NAN(", NAN, 3 }, \ + { "nan(", NAN, 3 }, \ + { "NAN(x", NAN, 3 }, \ + { "nan(x", NAN, 3 }, \ + { "NAN(x)y", NAN, 6 }, \ + { "nan(x)y", NAN, 6 }, \ + { "NAN(*)y", NAN, 3 }, \ + { "nan(*)y", NAN, 3 } \ }; \ \ static int \ +compare_strto ## FSUF (FTYPE x, FTYPE y) \ +{ \ + if (isnan (x) && isnan (y)) \ + return 1; \ + return x == y; \ +} \ + \ +static int \ test_strto ## FSUF (void) \ { \ int status = 0; \ @@ -30,7 +67,7 @@ test_strto ## FSUF (void) \ { \ char *ep; \ FTYPE r = strto ## FSUF (tests_strto ## FSUF[i].str, &ep); \ - if (r != tests_strto ## FSUF[i].result) \ + if (!compare_strto ## FSUF (r, tests_strto ## FSUF[i].result)) \ { \ char buf1[FSTRLENMAX], buf2[FSTRLENMAX]; \ FTOSTR (buf1, sizeof (buf1), "%g", r); \