From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11486 invoked by alias); 30 Oct 2016 20:35:30 -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: X-Seq: 39786 Received: (qmail 24339 invoked from network); 30 Oct 2016 20:35:30 -0000 X-Qmail-Scanner-Diagnostics: from out2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.26):SA:0(0.0/5.0):. Processed in 0.461823 secs); 30 Oct 2016 20:35:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=e32WpQdc8LUe9g/ 7xIBxh1jcBu4=; b=HJ4ZrEvaUh92xlKgVWIbLWM5NlnEZSzW9tdFqvQ6wZgJnao 6C3+xW2m4HY4nIuEKXgfEOp7s+aRjkLZI/9qNUpn+xneyEniaUqhp9pHmJiqQrWK zfr5znpRFE009rdMyOa7BsB1iBeHtb/Ot/R7FUjESik5EX/xTV7w6oR1ulzs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=e32WpQdc8LUe9g /7xIBxh1jcBu4=; b=bVFlXAgrUxLAyMUyizJDJ1Pov3qg7LlcoURtyPFaxIq+4Z WgFnVtqa4nxV9paL5E/Ol1Y/PU190JKWkgeFZDGDDWRJNREhkQhSOR/PSX0NOu+a /lPZa9QKkdBbo9BW5ZPff+OEE0r37CN6Rvh2wPxA7iDuytRK4v1zuoKA9Nl0U= X-ME-Sender: X-Sasl-enc: N+khdPn8o2jjh10p+AA04yyngcV8kzlvsg18LSkRXzxL 1477859720 Date: Sun, 30 Oct 2016 20:33:14 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: [PATCH] Fix hexdump command used for mercurial dirstate parsing Message-ID: <20161030203314.GA4276@fujitsu.shahaf.local2> References: <20161030024723.62832-1-john.reed.riley@gmail.com> <87y416drcq.fsf@ft.bewatermyfriend.org> <20161030155530.GC12137@fujitsu.shahaf.local2> <20161030170534.GA17437@fujitsu.shahaf.local2> <161030112832.ZM14753@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <161030112832.ZM14753@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) Bart Schaefer wrote on Sun, Oct 30, 2016 at 11:28:32 -0700: > On Oct 30, 5:06pm, Daniel Shahaf wrote: > } > } setopt localoptions extendedglob > } local -r -A pad=( $'\0' 0 $'\1' 0 $'\2' 0 $'\3' 0 $'\4' 0 $'\5' 0 $'\6' 0 $'\7' 0 $'\10' 0 $'\11' 0 $'\12' 0 $'\13' 0 $'\14' 0 $'\15' 0 $'\16' 0 $'\17' 0 ) > } REPLY=${(L)val//(#b)(?)/$pad[$match[1]]$(( [##16] ##${match[1]} ))} > > I can't help thinking here must be an easier way to do that. > > f() { > setopt localoptions nomultibyte extendedglob > local val > read -k $2 -u 0 val <$1 > print -r -- ${(Lj::)${(l:2::0:)${(@s//)val}//(#m)*/$(( [##16] ##$MATCH ))}} > } Thanks; that's now VCS_INFO_hexdump: diff --git a/Functions/VCS_Info/VCS_INFO_hexdump b/Functions/VCS_Info/VCS_INFO_hexdump index e69de29..11f1c1a 100644 --- a/Functions/VCS_Info/VCS_INFO_hexdump +++ b/Functions/VCS_Info/VCS_INFO_hexdump @@ -0,0 +1,16 @@ +## vim:ft=zsh + +# VCS_INFO_hexdump FILENAME BYTECOUNT +# +# Return in $REPLY a hexadecimal representation (lowercase, no whitespace) +# of the first BYTECOUNT bytes of FILENAME. + +if [[ -r $1 ]]; then + setopt localoptions nomultibyte extendedglob + local val + read -k $2 -u 0 val <$1 + REPLY=${(Lj::)${(l:2::0:)${(@s//)val}//(#m)*/$(( [##16] ##$MATCH ))}} +else + return 1 +fi + diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index f35ad59..4ad4089 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -40,9 +40,9 @@ VCS_INFO_adjust # Disabled by default anyway, so no harm done. if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" use-simple \ - && ( VCS_INFO_check_com hexdump ) && [[ -r ${dirstatefile} ]] ; then + && VCS_INFO_hexdump ${dirstatefile} 20 ; then # Calling hexdump is (much) faster than hg but doesn't get the local rev - r_csetid=$(hexdump -n 20 -e '1/1 "%02x"' ${dirstatefile}) + r_csetid=$REPLY else # Settling for a short (but unique!) hash because getting the full # 40-char hash in addition to all the other info we want isn't diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index f13f6b5..c0c1182 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -19,6 +19,7 @@ static_functions=( VCS_INFO_check_com VCS_INFO_formats VCS_INFO_get_cmd + VCS_INFO_hexdump VCS_INFO_hook VCS_INFO_maxexports VCS_INFO_nvcsformats