Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sL2Hv-00DA0M-AT for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Jun 2024 15:04:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sL2Hs-00A7GT-KV for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Jun 2024 15:04:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sL2Hr-00A7G1-N2 for pgsql-hackers@lists.postgresql.org; Sat, 22 Jun 2024 15:04:20 +0000 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sL2Ho-00303V-ES for pgsql-hackers@postgresql.org; Sat, 22 Jun 2024 15:04:18 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 7E29C1380092; Sat, 22 Jun 2024 11:04:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 22 Jun 2024 11:04:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm1; t=1719068654; x=1719155054; bh=HOPcl887PHyF/ZJdh4cgwkEj7uzJulAV yA9FS8/Tb78=; b=MfFTvTJitT+lgsMBo0PrDxKA6vDkUnE+jAndSt06dNMy8tY6 LmnK4DsdQ+h9WFavN/LkqZ0vfvKDJ1sooaDB+wXZWgs9sxeED6qgHyUO8WJBP/nS WBfAyczispa0gxHzzH3bIsGhAIcmjYCNkRj+ieiDOOpBoqTQtINKXd4eheANdVLI iEgriNJQ/WAI94ogW0Fq/QL0O3HNOJBeC0y56iftP9+fhHrAgRaiVa8Dp6bXKqjM LsTvuAIRDWlXaFz0eZJlQ4VTHg1jXB6yj6wOJEg7K7IhsNFmpAliWoMhYMg3aHFU v1Ly2Dl0Y2Q0kxFqT/i5NLEtP7I2/vDwj2RBMg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1719068654; x= 1719155054; bh=HOPcl887PHyF/ZJdh4cgwkEj7uzJulAVyA9FS8/Tb78=; b=v +m/KPWAStVKdu3Q+ne9nrIC7qz05UAApEed2Cxco6jdL7F7Vzk961+a4O7+uka07 Nnh7u6zY+k7FyJRzFTIJcJRc3OhQKN2yvVZJ0hf/cU118+SV1+bRDQwRJUSprqiw 6KrhjAQPsgFSIGe8hjHk59Fl0fBT4v4ia7W8ROjNcL/YEf+YwnzVc3t0KgHvAUqo FVL+4J4SoUvpa0mYYEDJqAt296XrNEk6vOZD4TguHwy8/ceIw0POr+8vI6/tHUiV XIeGfgr/EdkEJ2+fuqQzZEGQpJw2vl9FcG++j+KpV6DNIo26Tzqzp5q0ccdDmSyw AscV+OB/WItquqe7yfGGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefiedgkeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfevfhfhjggtgfesth ejredttddvjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgv rhesvghishgvnhhtrhgruhhtrdhorhhgqeenucggtffrrghtthgvrhhnpefgjedthfekfe dtuefgieelheetleejgefhueeltdfhueetvdffudekfeejhfegheenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsegvihhsvghnth hrrghuthdrohhrgh X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 22 Jun 2024 11:04:13 -0400 (EDT) Message-ID: <7bb7219b-bd94-46c6-bf56-fee1e13cec0e@eisentraut.org> Date: Sat, 22 Jun 2024 17:04:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: replace strtok() To: Ranier Vilela Cc: pgsql-hackers References: <79692bf9-17d3-41e6-b9c9-fc8c3944222a@eisentraut.org> Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 18.06.24 13:43, Ranier Vilela wrote: > But I would like to see more const char * where this is possible. > > For example, in pg_locale.c > IMO, the token variable can be const char *. > > At least strchr expects a const char * as the first parameter. This would not be future-proof. In C23, if you pass a const char * into strchr(), you also get a const char * as a result. And in this case, we do write into the area pointed to by the result. So with a const char *token, this whole thing would not compile cleanly under C23. > I found another implementation of strsep, it seems lighter to me. > I will attach it for consideration, however, I have not done any testing. Yeah, surely there are many possible implementations. I'm thinking, since we already took other str*() functions from OpenBSD, it makes sense to do this here as well, so we have only one source to deal with.