From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 3fdef5fa for ; Thu, 2 May 2019 20:15:20 +0000 (UTC) Received: (qmail 1118 invoked by alias); 2 May 2019 20:15:01 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44267 Received: (qmail 12783 invoked by uid 1010); 2 May 2019 20:15:01 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f67.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25434. spamassassin: 3.4.2. Clear:RC:0(209.85.166.67):SA:0(-1.9/5.0):. Processed in 2.007828 secs); 02 May 2019 20:15:01 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.166.67 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=5jm+CnM6sPao1COi81XKyLf8z1dEHqa0hP/HmslmxNM=; b=Nxm870a0+gusLfy3Te8vH/t37reUckZC0ebk+8M+ycirUtqKGMrs2bTN7QW8IQHGUt CuwyS7eMYL6Zs4ZvHD5jG1kR3BpVAU2Gt/AAFbg1qTMaw5Xy489zQxWPqEKJAZuP/qwN l78qWCSDx+v27Tel3+Yq0QuQ8Zls/dfP5udidXayXBst4i1iK1eOC3tZtPHs5+sMMTLf f91Vx5xc6S5grgkImcfs6+DeuVJkPNFBGPfSGrY6dChxISqjy6cGQNUzuRW6mLTzEKnX DU2IdU5dPgHvoucl/Uoc+wOluyItOFoAAVN5TOVxy9HlD1Y0n8yKgfqe8D6b57Oo5P9k ilJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=5jm+CnM6sPao1COi81XKyLf8z1dEHqa0hP/HmslmxNM=; b=aA85EVXvHMYY80vev2bfQE11WvVEPhIALdwdNjSj0hKSw3RfwS9lGKk9UbcYcCp4V4 6Pgb9kPVysF7sfrzqOvznVRc8fxNec1t+CuplXjPCzy0CmdrFBlDrXgH0SFNKUv/HvZ3 xz+zsh5ViJdEDUvj78lR0nyfuK7jG3fHdycdQrkgb6rt1CS2MyXkMZdUPbDGKwGWIEBz v4DpmpxR8ORLqpTnzEWmeSHelH7eRDWUwegfUnnD4Y/0byAr5w1vO0q/d9BeW8uudttS crvl5eTCctrYFgrGLPzBu5TxraOIcoJUDq6aTQE6dztZ4jnJ+EzM9BdbcrJuYhSFmDE4 igpw== X-Gm-Message-State: APjAAAUmsjTkBj5EdLHRuGSvQacvbkySFrv2YwWAERLVvPW7jHAL1wDP jRPjwSmPybJwHN9Hx+stMGJKkfE+BS1d9A== X-Google-Smtp-Source: APXvYqwUlpxImIYTJOEzwV4HjDNY4cK6rDLWNrlZhc2D4BZWOSi7dWuD+tu3+9oCEyxEdseMVTTXQA== X-Received: by 2002:a6b:b354:: with SMTP id c81mr4554792iof.242.1556828064405; Thu, 02 May 2019 13:14:24 -0700 (PDT) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: [PATCH] sort: Restore option to ignore back-slashes Message-Id: <0B615B84-776D-4033-8108-F66C0C762E42@dana.is> Date: Thu, 2 May 2019 15:14:22 -0500 To: Zsh hackers list X-Mailer: Apple Mail (2.3445.9.1) Oliver mentioned to me off-list (and earlier in workers/43842) that workers/41242 introduced an issue with sorting completion matches, where = it no longer ignores back-slashes like it used to. (e.g., in zsh 5.3 the match `\!foo` would be sorted ahead of `Afoo`, but now it's the other way = around.) This seems to restore that functionality. I pretty much just copied and pasted, though, so maybe someone could double-check my thinking... dana diff --git a/Src/sort.c b/Src/sort.c index 92ee1c0d4..562b89491 100644 --- a/Src/sort.c +++ b/Src/sort.c @@ -33,6 +33,9 @@ /* Flag for direction of sort: 1 forwards, -1 reverse */ static int sortdir; =20 +/* Flag that sort ignores backslashes */ +static int sortnobslash; + /* Flag that sort is numeric */ static int sortnumeric; =20 @@ -113,9 +116,24 @@ eltpcmp(const void *a, const void *b) bs +=3D (laststarta - as); as +=3D (laststarta - as); } + + if (sortnobslash) { + while (*as && *bs) { + if (*as =3D=3D '\\') + as++; + if (*bs =3D=3D '\\') + bs++; + if (*as !=3D *bs || !*as) + break; + as++; + bs++; + } + } + #ifdef HAVE_STRCOLL cmp =3D strcoll(as, bs); #endif + if (sortnumeric) { for (; *as =3D=3D *bs && *as; as++, bs++); #ifndef HAVE_STRCOLL @@ -162,7 +180,10 @@ mod_export int zstrcmp(const char *as, const char *bs, int sortflags) { struct sortelt ae, be, *aeptr, *beptr; - int oldsortdir =3D sortdir, oldsortnumeric =3D sortnumeric, ret; + int oldsortdir =3D sortdir; + int oldsortnobslash =3D sortnobslash; + int oldsortnumeric =3D sortnumeric; + int ret; =20 ae.cmp =3D as; be.cmp =3D bs; @@ -173,11 +194,13 @@ zstrcmp(const char *as, const char *bs, int = sortflags) beptr =3D &be; =20 sortdir =3D 1; + sortnobslash =3D (sortflags & SORTIT_IGNORING_BACKSLASHES) ? 1 : 0; sortnumeric =3D (sortflags & SORTIT_NUMERICALLY) ? 1 : 0; =20 ret =3D eltpcmp(&aeptr, &beptr); =20 /* Paranoia: I don't think we ever need to restore these. */ + sortnobslash =3D oldsortnobslash; sortnumeric =3D oldsortnumeric; sortdir =3D oldsortdir; =20 diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index b1c0e40e5..f1c981f26 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -99,6 +99,7 @@ F:regression test workers/31611 comptesteval 'cd "A(B)/C"' comptest $'cd ../\t' } always { + comptesteval 'cd -' # Reset CWD rmdir 'A(B)/C' 'A(B)' } 0:directory name is not a glob qualifier @@ -116,6 +117,27 @@ F:regression test workers/31611 0:allow for suffixes when moving cursor to end of match (without = ignored suffix) >line: {tst word:/}{} =20 +# Test for regression introduced by workers/41242, raised in = workers/43842 + { + mkdir sortnobslash + touch sortnobslash/{'!foo','#foo','\foo','|foo','~foo',Afoo,bfoo} + comptesteval 'old_LC_ALL=3D$LC_ALL; LC_ALL=3DC' + comptest $': sortnobslash/\t' + } always { + comptesteval 'LC_ALL=3D$old_LC_ALL' + rm -rf sortnobslash + } +0:ignore backslashes when sorting completion matches +>line: {: sortnobslash/}{} +>DESCRIPTION:{file} +>FI:{\!foo} +>FI:{\#foo} +>FI:{Afoo} +>FI:{\\foo} +>FI:{bfoo} +>FI:{\|foo} +>FI:{\~foo} + %clean =20 zmodload -ui zsh/zpty