From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11611 invoked from network); 2 Jan 2024 04:28:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Jan 2024 04:28:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1704169705; b=gSlwiB6Te+ae/G2cjZYpsbYxUPJ5QkoGQZFPwkvijNybF69p4amoQ4Htb/a8pHx0tviXcuJE73 h+216OCL4+Y7iQKGR8phOZUfHACh4Ne4AeSeSjHSt6s7d1AWF4lVnwqWvMldpbTGeoKpRQmxy1 TTeggrbV1LMIltpzthZPW0s6x73pX529VGbX2qkQJzdlgYFTAcd+LzxoCtkWb1QnBfrwoZYXOn ++U+lMQ0dqBY843KB80S3U+W62E7FDLD3MRzQ1goW3MCEsG9aTH/SOTW/sDbbxVUjJxc+xK02K 2Val+QC10LiErvLar3F3EZxzC8Q6AZdOAESu62iAZG2K1A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f50.google.com) smtp.remote-ip=209.85.218.50; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1704169705; bh=9YfLwzwJL0gZrwiK7YCjAP+BwhjP4/dlIwzyeKBbt1g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=gfjRbU98MjXswQ52WguROxCCCHociyvgfTKiBbxtuKuAsTbaKQ6vSLIUamH8NMRS9f4XRIXUE+ 78WRL3nDlKqlLZjQAZhVq23fiwzLZ+axm0Ixunm5qFcdUVuPS/Er2lONKaWt8h8yeSY07L6xNN y9UvtM8gdlbktGf9TVsZvpl9d+UaaJ0ewfr4wdyDr6IZnQaGs7cyW5gmp3hJE0sLpuCA8EHkJY ZstFfeL1QbPwv8iYJluNNILXjOkKHwCL0UO5riWaSiqsVDS0CUqUDOuIKzPocbZG3HuOXN1F9u 8fkm0vkeFcck6oO/dA3vkNDbDE5YA8IyYXOnMx6cr+9lfg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=9YfLwzwJL0gZrwiK7YCjAP+BwhjP4/dlIwzyeKBbt1g=; b=Mh4XCVKg7zFvCydJNfg5fzSE1L /60u4Zop1TC8nXWKoDlCPMlVUHYHe/fD66jJbuQMLgaPZgQnP8Y8s9FCOPCA4X0U+KYNueveIyXJ1 ekfVL/hH4VfdNURybaqJ7VsmRvMDsr7ZVHXePTlRj4jv5NO46TjnQQCmGSMGCpVMFsfNvVJC/gX3m /emEeY/7ePtA5wxTMJqrDurcxERxIjy9TnDl2mp46Xx78qEjeFY0MQLJfp2AmH98TkHU3QURW/j3V LHl+AZGHB+WhiYNrj37YMrvE+s0x9kJBeEfTiEi3nU4CQPlLbFcJrnFLFfXqj+e8+AKh+Z+Hiiw88 UFbQIX1g==; Received: by zero.zsh.org with local id 1rKWO4-0001kO-UP; Tue, 02 Jan 2024 04:28:21 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f50.google.com) smtp.remote-ip=209.85.218.50; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f50.google.com ([209.85.218.50]:41989) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rKWNO-0001QQ-Ga; Tue, 02 Jan 2024 04:27:39 +0000 Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a2335d81693so1550183866b.0 for ; Mon, 01 Jan 2024 20:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704169658; x=1704774458; darn=zsh.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=9YfLwzwJL0gZrwiK7YCjAP+BwhjP4/dlIwzyeKBbt1g=; b=Q7ZAWy10iCbO8Bl5BfJDKIU92IC1jjAZuQ6qAD/2o+f3tOAZp/qiThYCaVSphMnXyp /WSu1bLKHziW5g9HRwjFEKJI5gLmtBQos1gZDosnTyBNSgiCIfLI5rs2Q6GmxszSH+YT KFmi+3avnqyN2S3B9bwgPa8G5W+c4h9rdM6vmrfubUgjcOplBfHUwGG+iPL7r0tBCq0A InokJm0Bo/2vbusLOhkD0RQAEdBpRmbPcmAl125xNSNdx76gUsfEeGRD4eRwf0hJDgUx 7U5XbIsdaFjaL/1fMMnfIg9pd7VyGqMTfCKMwQFF6Ull+p1u3VbCluD3BA8++B7U8Unk wX1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704169658; x=1704774458; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9YfLwzwJL0gZrwiK7YCjAP+BwhjP4/dlIwzyeKBbt1g=; b=MJy1shK2u7H8TeSJHeHxgjluNIs9N1OTSCfozVu5qhDsOtoXlGHtKP0Atnzkyg+kk2 BDqzqy4ZFs9ZCOS0jViMDsJ0pK0+F1ZdGSJxPUB4dHWcX5dfmCop1ZYLJGGv70pcQs9b LBVFyViWICMNhsEC/sokGsNEHgm/cQrnqvNVN+otP7nFE81+po5K1LM3LNKD0fXP5wdU xg2US9O12LSlQsDQi4d9/CcTyNcwqGRsCchnoAUgoRuX/Ra5sCrMjBzFF7a1q3PnTEkv szXdM8QprTByZJPpPtr14M2f6Z1vRNYygq72HYzl6IY1WorRAlBqetmuGjAOH0i4OTgb eEJA== X-Gm-Message-State: AOJu0YwIHQSsIaU/71TAGz2krk2VginfkIzcmTm6AGKAWSqPURo9HHt6 fSxz+fyEdnEw4lVPFuPTXDMQJhZlmDNGzGV9Gvy7S5UZ+B3NOw== X-Google-Smtp-Source: AGHT+IHVPOgP6HYGgyEOCum3ewRS5jAfpVpO9AjP3wMh7XaJsDqtB6A1CRw4D7u8GFqW9Se8EfXAnByF49nW7oDT4as= X-Received: by 2002:a17:906:8a70:b0:a28:872:9293 with SMTP id hy16-20020a1709068a7000b00a2808729293mr1874628ejc.18.1704169657562; Mon, 01 Jan 2024 20:27:37 -0800 (PST) MIME-Version: 1.0 References: <20231231054304.48689-1-tirtajames45@gmail.com> In-Reply-To: From: James Date: Tue, 2 Jan 2024 11:23:37 +0700 Message-ID: Subject: Re: [PATCH] string.c: prefer memcpy() over strcpy() To: Bart Schaefer Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="0000000000001377bc060deeebee" X-Seq: 52454 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000001377bc060deeebee Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 2, 2024 at 7:24=E2=80=AFAM Bart Schaefer wrote: > This may be a worthwhile optimization given how frequently > dupstring/ztrdup/dyncat are used, but I'm concerned that "WLEN" may be > confused with counts of wide characters. > > STRNCPY_NUL() or even ZSTRNCPY() ? > I was using WLEN based on dupstring_wlen(). I don't think strncpy() is a good name because it's already an extension that behaves very differently. According to the Linux man page: these functions [strncpy and stpncpy] copy the string pointed to by src into a null-padded character sequence at the fixed-width buffer pointed to by dst. --0000000000001377bc060deeebee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Jan 2, 2024 at 7:24=E2=80=AFA= M Bart Schaefer <schaefer@b= rasslantern.com> wrote:
This may be a worthwhile optimization given how frequently
dupstring/ztrdup/dyncat are used, but I'm concerned that "WLEN&quo= t; may be
confused with counts of wide characters.

STRNCPY_NUL() or even ZSTRNCPY() ?
I was using WLEN ba= sed on dupstring_wlen(). I don't think strncpy() is a good name because= it's already an extension that behaves very differently. According to = the Linux man page: these functions [strncpy and stpncpy] copy the string p= ointed to by src into a null-padded character sequence at the fixed-width b= uffer pointed to by dst.
--0000000000001377bc060deeebee--