From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16899 invoked by alias); 12 Sep 2014 13:17:30 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19069 Received: (qmail 8438 invoked from network); 12 Sep 2014 13:17:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=aSzmkIrxlw5uUhO2YQD1mFHEwH5/LKbKydmj//b0Pl0=; b=VulTfef+c21hI3407hro3hUWfeuydFTPMmariElWx3FjXRcv25ozBvqT7Iw7SwmVdj HYKzoBdrAy5MILKf6i0vRj4KOrEZ7qSqykupGUZamqQYf52eFX61MNYm1bpT4Rov67FH 4V5AtXD0yj2ERxGjLlLFschFf2PvL1/Uf04qwf+gm6/gYJ1UfZtV2YjpjeZpIo1UelcZ u1j6kH8FCU1d++vZiJnbM8UL4stRa41zRA7oBCAwjWW1pddK19uvtOG+g2hlZjt3qriv yGn0nwQ3oDkpD0j/25nXXHbXF3MhrhaV6+I+dYc3G2WnALcsbpDKFWM4mIe/PlaZVYlQ 2CTg== X-Gm-Message-State: ALoCoQmFZGxPaETi5HCmkp4FkhsnBVrBybmZRk4QAxNpB0kKakdd72xi6cZMtW/CrdrXtXfDawOH MIME-Version: 1.0 X-Received: by 10.52.164.136 with SMTP id yq8mr5554879vdb.23.1410527842890; Fri, 12 Sep 2014 06:17:22 -0700 (PDT) In-Reply-To: <20140912084230.GA4226@linux.vnet.ibm.com> References: <20140911213608.GA1029@gmx.de> <140911213901.ZM21898@torch.brasslantern.com> <20140912084230.GA4226@linux.vnet.ibm.com> Date: Fri, 12 Sep 2014 06:17:22 -0700 Message-ID: Subject: Re: Determining the length of "long"? From: Kurtis Rader To: vogt@linux.vnet.ibm.com, Zsh Users Content-Type: multipart/alternative; boundary=001a11c232e005cc6f0502de1b46 --001a11c232e005cc6f0502de1b46 Content-Type: text/plain; charset=UTF-8 Sorry, but I disagree. Zsh is absolutely the wrong tool for this task unless you're striving for an unmaintainable, obfuscated, brittle script. Please ask your peers, preferably including someone in the Linux level three support org (where I used to work at IBM), for feedback on your idea. P.S.., I would only use perl if there wasn't a better option. But perl is preferable to zsh for this task and python is even better. On Fri, Sep 12, 2014 at 1:42 AM, Dominik Vogt wrote: > On Thu, Sep 11, 2014 at 07:58:29PM -0700, Kurtis Rader wrote: > > There may be a way but why? A command shell is the wrong tool for > > that task. > > To give you a bit of background: The script is an fvwm module, > and apart from the need of sending two longs to the window manager > core in binary format, the shell is absolutely the right tool here > (combine several unix command line programs in a pipe, filter their > output and generate a wm command from that). > > > You don't need to compile a C program to do this. If you have perl or > > python it's an almost trivial problem. > > I know, but I never do something in perl if it can be done in zsh. > > On Thu, Sep 11, 2014 at 09:39:01PM -0700, Bart Schaefer wrote: > > if (( ${#:-"$(( [#2] (1<<31)))"} > ${#:-"$(( [#2] (1<<63)))"} )) > > then print "zsh integer type is 32 bits" > > elif (( ${#:-"$(( [#2] (1<<63)))"} > ${#:-"$(( [#2] (1<<64)))"} )) > > then print "zsh integer type is 64 bits" > > else print "zsh integer type is more than 64 bits" > > fi > > Hm, I'm not really sure that works reliably because the shift > amount may be truncated before it is used. I.e. on s390 "1 << 32" > and "1 << 64" and "1 << 0" are all the same. Luckily I don't need > that on s390. > > > There's no guarantee that zsh's integer type is "long", so no, there > > is not. > > If long is not guaranteed, how does zsh determine which integer > type it uses in arithmetic? Would it use long long if a long is > four bytes and long long is available? > > Is it possible to print pointers or memory contents in zsh? > > > setopt C_BASES > > integer i=0x12345 > > while (( i )) { > > printf '\\\\x%x\n' $(( [#16] (i & 0xff) )) > > (( i = i >> 8 )) > > } > > Actually the amount I have to print is just a byte, but with > three or seven null bytes before or after it, so all I really > need to know is the host byte order to pick the right variant. > But that is only a bonus for now. > > Ciao > > Dominik ^_^ ^_^ > > -- > > Dominik Vogt > IBM Germany > > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --001a11c232e005cc6f0502de1b46--