From patchwork Wed Nov 18 09:25:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1402137 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=dBuZw4Bd; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CbcqQ1Xbsz9sT6 for ; Wed, 18 Nov 2020 20:25:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDE543861847; Wed, 18 Nov 2020 09:25:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDE543861847 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1605691533; bh=vCH9v4394v7qLt2gSSN72WlS9hgItjbX+o7e/2Q6sfE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=dBuZw4BdCTpW6gKe8GA/BQcTE90kIPugylTXDwLfyK9Ro3hrkqQFmSC9cFgITWBIa uoXBeE5S/zfUbUSF8Kl/uBq2Xm7Vn76TYh4NexvTBZ56aYqQxcW4hk+hEyvzCp+zyl OsRnw4zG4LMBp8dX5UMVPCQcyzHgK1CPUXyHxqZM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by sourceware.org (Postfix) with ESMTPS id 0E616385800A for ; Wed, 18 Nov 2020 09:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0E616385800A Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4CbcqC1V84zQlKQ; Wed, 18 Nov 2020 10:25:27 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id 7dmWP4J4X6SI; Wed, 18 Nov 2020 10:25:23 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [committed] libphobos: Merge upstream phobos 7948e0967. Date: Wed, 18 Nov 2020 10:25:13 +0100 Message-Id: <20201118092513.3907545-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -4.41 / 15.00 / 15.00 X-Rspamd-Queue-Id: DF7021700 X-Rspamd-UID: 0e1307 X-Spam-Status: No, score=-16.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch merges the libphobos library with upstream phobos 7948e0967, removing all deprecated functions from std.string module. Regression tested and committed to mainline. Regards, Iain. --- libphobos/ChangeLog: * src/MERGE: Merge upstream phobos 7948e0967. --- libphobos/src/MERGE | 2 +- libphobos/src/std/string.d | 267 ------------------------------------- 2 files changed, 1 insertion(+), 268 deletions(-) diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index 1562f747b74..de86ff5b65b 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -021ae0df76727a32809a29887095ab7093489ea3 +7948e096735adbc093333da789fc28feadce24b0 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/string.d b/libphobos/src/std/string.d index 5b61cde4ac1..1128a090304 100644 --- a/libphobos/src/std/string.d +++ b/libphobos/src/std/string.d @@ -5174,273 +5174,6 @@ body assert(buffer.data == "h5 rd"); } -//@@@DEPRECATED_2.086@@@ -deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.") -bool inPattern(S)(dchar c, in S pattern) @safe pure @nogc -if (isSomeString!S) -{ - bool result = false; - int range = 0; - dchar lastc; - - foreach (size_t i, dchar p; pattern) - { - if (p == '^' && i == 0) - { - result = true; - if (i + 1 == pattern.length) - return (c == p); // or should this be an error? - } - else if (range) - { - range = 0; - if (lastc <= c && c <= p || c == p) - return !result; - } - else if (p == '-' && i > result && i + 1 < pattern.length) - { - range = 1; - continue; - } - else if (c == p) - return !result; - lastc = p; - } - return result; -} - - -deprecated -@safe pure @nogc unittest -{ - import std.conv : to; - import std.exception : assertCTFEable; - - assertCTFEable!( - { - assert(inPattern('x', "x") == 1); - assert(inPattern('x', "y") == 0); - assert(inPattern('x', string.init) == 0); - assert(inPattern('x', "^y") == 1); - assert(inPattern('x', "yxxy") == 1); - assert(inPattern('x', "^yxxy") == 0); - assert(inPattern('x', "^abcd") == 1); - assert(inPattern('^', "^^") == 0); - assert(inPattern('^', "^") == 1); - assert(inPattern('^', "a^") == 1); - assert(inPattern('x', "a-z") == 1); - assert(inPattern('x', "A-Z") == 0); - assert(inPattern('x', "^a-z") == 0); - assert(inPattern('x', "^A-Z") == 1); - assert(inPattern('-', "a-") == 1); - assert(inPattern('-', "^A-") == 0); - assert(inPattern('a', "z-a") == 1); - assert(inPattern('z', "z-a") == 1); - assert(inPattern('x', "z-a") == 0); - }); -} - -//@@@DEPRECATED_2.086@@@ -deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.") -bool inPattern(S)(dchar c, S[] patterns) @safe pure @nogc -if (isSomeString!S) -{ - foreach (string pattern; patterns) - { - if (!inPattern(c, pattern)) - { - return false; - } - } - return true; -} - -//@@@DEPRECATED_2.086@@@ -deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.") -size_t countchars(S, S1)(S s, in S1 pattern) @safe pure @nogc -if (isSomeString!S && isSomeString!S1) -{ - size_t count; - foreach (dchar c; s) - { - count += inPattern(c, pattern); - } - return count; -} - -deprecated -@safe pure @nogc unittest -{ - import std.conv : to; - import std.exception : assertCTFEable; - - assertCTFEable!( - { - assert(countchars("abc", "a-c") == 3); - assert(countchars("hello world", "or") == 3); - }); -} - -//@@@DEPRECATED_2.086@@@ -deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.") -S removechars(S)(S s, in S pattern) @safe pure -if (isSomeString!S) -{ - import std.utf : encode; - - Unqual!(typeof(s[0]))[] r; - bool changed = false; - - foreach (size_t i, dchar c; s) - { - if (inPattern(c, pattern)) - { - if (!changed) - { - changed = true; - r = s[0 .. i].dup; - } - continue; - } - if (changed) - { - encode(r, c); - } - } - if (changed) - return r; - else - return s; -} - -deprecated -@safe pure unittest -{ - import std.conv : to; - import std.exception : assertCTFEable; - - assertCTFEable!( - { - assert(removechars("abc", "a-c").length == 0); - assert(removechars("hello world", "or") == "hell wld"); - assert(removechars("hello world", "d") == "hello worl"); - assert(removechars("hah", "h") == "a"); - }); -} - -deprecated -@safe pure unittest -{ - assert(removechars("abc", "x") == "abc"); -} - -//@@@DEPRECATED_2.086@@@ -deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.") -S squeeze(S)(S s, in S pattern = null) -{ - import std.utf : encode, stride; - - Unqual!(typeof(s[0]))[] r; - dchar lastc; - size_t lasti; - int run; - bool changed; - - foreach (size_t i, dchar c; s) - { - if (run && lastc == c) - { - changed = true; - } - else if (pattern is null || inPattern(c, pattern)) - { - run = 1; - if (changed) - { - if (r is null) - r = s[0 .. lasti].dup; - encode(r, c); - } - else - lasti = i + stride(s, i); - lastc = c; - } - else - { - run = 0; - if (changed) - { - if (r is null) - r = s[0 .. lasti].dup; - encode(r, c); - } - } - } - return changed ? ((r is null) ? s[0 .. lasti] : cast(S) r) : s; -} - -deprecated -@system pure unittest -{ - import std.conv : to; - import std.exception : assertCTFEable; - - assertCTFEable!( - { - string s; - - assert(squeeze("hello") == "helo"); - - s = "abcd"; - assert(squeeze(s) is s); - s = "xyzz"; - assert(squeeze(s).ptr == s.ptr); // should just be a slice - - assert(squeeze("hello goodbyee", "oe") == "hello godbye"); - }); -} - -//@@@DEPRECATED_2.086@@@ -deprecated("This function is obsolete. It is available in https://github.com/dlang/undeaD if necessary.") -S1 munch(S1, S2)(ref S1 s, S2 pattern) @safe pure @nogc -{ - size_t j = s.length; - foreach (i, dchar c; s) - { - if (!inPattern(c, pattern)) - { - j = i; - break; - } - } - scope(exit) s = s[j .. $]; - return s[0 .. j]; -} - -/// -deprecated -@safe pure @nogc unittest -{ - string s = "123abc"; - string t = munch(s, "0123456789"); - assert(t == "123" && s == "abc"); - t = munch(s, "0123456789"); - assert(t == "" && s == "abc"); -} - -deprecated -@safe pure @nogc unittest -{ - string s = "123€abc"; - string t = munch(s, "0123456789"); - assert(t == "123" && s == "€abc"); - t = munch(s, "0123456789"); - assert(t == "" && s == "€abc"); - t = munch(s, "£$€¥"); - assert(t == "€" && s == "abc"); -} - - /********************************************** * Return string that is the 'successor' to s[]. * If the rightmost character is a-zA-Z0-9, it is incremented within