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=DKIMWL_WL_MED,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 f1da5981 for ; Fri, 21 Dec 2018 09:41:46 +0000 (UTC) Received: (qmail 14118 invoked by alias); 21 Dec 2018 09:41:29 -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: 43922 Received: (qmail 28273 invoked by uid 1010); 21 Dec 2018 09:41:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f66.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(209.85.166.66):SA:0(-1.9/5.0):. Processed in 3.060049 secs); 21 Dec 2018 09:41:29 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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=ZlrHFoLm8eJFSBkIT5jtezeXkFcvLgpsT7zWsxbmByI=; b=EdMUh9dtxx1+Kj3xske5bOg+m0CCWPyD1lQY8zrJisfXeDRtJxSDOsh7a2ksvU0wu/ QmKvQFF7hHiF7PIGq3Etn1BdPVTuN6ZAbPLwZTIbz8Ym6VG6ksnWr1w1pm04O30fIVh9 pBa7IBvvFvbw+aEE2BA316VDTJ3Fp6oqWOWeV08GBGdxNgT7gFGIQ7ecs/IZABaEApG9 R6hlWuu4/fUkE8/9HEylaOvZQf9USYnHYLyP3l1WqEMc6SG3HQJyqbANx/+8VTGBAlXC Ecyd5FSyreMLoyF6fN0cuUti40ZyWMA2eBnejFLWcEjFQsyZp6zJvBnCsUp2wHXfsXId D8uw== 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=ZlrHFoLm8eJFSBkIT5jtezeXkFcvLgpsT7zWsxbmByI=; b=IrayvRFSmCpDosqXA/718/t/Dy62PgLiMFYn2ZbriYayHfkIyBIQEfHU6sDkyDsyV6 6D6Kw+L5VKC2FB9HclF9psp7zxTfIPjVEVnrjkI30gwOPTeGaqG/YywGsJF2cAWUXvfX +7sMh0snA8iSWwdz0MPkRQ+iWl7mx4ARrlVngIqB6qlg6gyycxP3sT0ASth30rUrOaoF 1EwqrKGzoi6par6Bp8xpvO67/kj+qnjudQZmmBCgUJxbuF/F82s5pWvdAk8JK9v4Y9d6 j/rUZ5kq70MX86QESvbkHc82NKa3NFz2+oaRW4PjxEir3PKKfVRuJc/ZOoH59DvMatnr lwCw== X-Gm-Message-State: AJcUukefs0MkXZBU9NkYHgDsyccIl0W+W6i/yBp5GzSspTwMogKcuCLX OQbWPkmQBCsM+w+2VRmTrJQ8LPCzQgIbjA== X-Google-Smtp-Source: ALg8bN4yxa6xvuINIWR46flFBYnFs6LXdnkLHNE6AWsgW0aiKmPJj7t47EY+roZPZsnAHRWG+kEhAA== X-Received: by 2002:a5d:9709:: with SMTP id h9mr1021486iol.3.1545385282836; Fri, 21 Dec 2018 01:41:22 -0800 (PST) From: dana Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [PATCH] computil: Fix inconsistent handling of slash-escaped option names Message-Id: Date: Fri, 21 Dec 2018 03:41:21 -0600 To: Zsh workers X-Mailer: Apple Mail (2.3445.100.39) When writing option specs, you're supposed to be able to escape = characters in the option name that are special to the syntax; as the manual says: >It is possible for options with a literal =E2=80=98+=E2=80=99 or = =E2=80=98=3D=E2=80=99 to appear, but that >character must be quoted, for example =E2=80=98-\+=E2=80=99. This sort of works, but not entirely. It does make the name valid, and = the option does appear correctly as a possibility, but because the slashes = are only skipped when parsing, not actually removed from the final name, the completion system gets confused when you actually use it. For example: % _foo() { _arguments -s : '-\+' -a -b } % compdef _foo foo % foo -+ Because of the -s, it should try to complete -a or -b in the same word. Instead, it starts a new word, and it behaves as if -+ hasn't been used = yet. Unless i'm missing something, this seems to fix it... dana diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index cb1c01042..a98574379 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -1409,7 +1409,7 @@ parse_cadef(char *nam, char **args) (*p !=3D '=3D' || (p[1] !=3D ':' && p[1] !=3D '[' && p[1] !=3D = '-')); p++) if (*p =3D=3D '\\' && p[1]) - p++; + chuck(p); =20 /* The character after the option name specifies the type. = */ c =3D *p; @@ -1527,7 +1527,7 @@ parse_cadef(char *nam, char **args) =20 opt->next =3D NULL; opt->gsname =3D doset; - opt->name =3D ztrdup(rembslashcolon(name)); + opt->name =3D ztrdup(name); if (descr) opt->descr =3D ztrdup(descr); else if (adpre && oargs && !oargs->next) { diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst index fa4589374..ec9fd9e8a 100644 --- a/Test/Y03arguments.ztst +++ b/Test/Y03arguments.ztst @@ -78,11 +78,17 @@ >line: {tst rest arg2 }{} >line: {tst rest arg2 rest }{} =20 - tst_arguments '-\+[opt]' + tst_arguments -s : '-\+[opt1]' '-a[opt2]' '-b[opt3]' comptest $'tst -\C-d' -0:-+ + comptest $'tst -+\C-d' +0:slash-escaped option name (-+) >DESCRIPTION:{option} ->NO:{-+ -- opt} +>NO:{-+ -- opt1} +>NO:{-a -- opt2} +>NO:{-b -- opt3} +>DESCRIPTION:{option} +>NO:{-a -- opt2} +>NO:{-b -- opt3} =20 tst_arguments -+o comptest $'tst -\t\t\t\C-w\C-w+\t\t\t'