From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 7 01:55:11 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 75D9137B401 for ; Mon, 7 Apr 2003 01:55:11 -0700 (PDT) Received: from gandalf.online.bg (gandalf.online.bg [217.75.128.9]) by mx1.FreeBSD.org (Postfix) with SMTP id 9F85643FA3 for ; Mon, 7 Apr 2003 01:55:09 -0700 (PDT) (envelope-from roam@ringlet.net) Received: (qmail 22452 invoked from network); 7 Apr 2003 08:50:02 -0000 Received: from office.sbnd.net (HELO straylight.ringlet.net) (217.75.140.130) by gandalf.online.bg with SMTP; 7 Apr 2003 08:50:02 -0000 Received: (qmail 66084 invoked by uid 1000); 7 Apr 2003 08:53:09 -0000 Date: Mon, 7 Apr 2003 11:53:09 +0300 From: Peter Pentchev To: Giorgos Keramidas Message-ID: <20030407085309.GC527@straylight.oblivion.bg> Mail-Followup-To: Giorgos Keramidas , Alex Semenyaka , freebsd-hackers@freebsd.org References: <20030405030629.GA2669@snark.ratmir.ru> <20030406032450.GC4130@gothmog.gr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4SFOXa2GPu3tIq4H" Content-Disposition: inline In-Reply-To: <20030406032450.GC4130@gothmog.gr> User-Agent: Mutt/1.5.4i cc: freebsd-hackers@freebsd.org cc: Alex Semenyaka Subject: Re: /bin/sh and BIG NUMBERS X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Apr 2003 08:55:11 -0000 --4SFOXa2GPu3tIq4H Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Apr 06, 2003 at 06:24:50AM +0300, Giorgos Keramidas wrote: > On 2003-04-05 07:06, Alex Semenyaka wrote: > > I found that /bin/sh cannot handle numbers those do not fit to integer > > type. That is not too bad. Too bad that it just silently warps them > > in arithmetical operations: > > > > alexs@snark> /bin/sh -c 'echo $((10000000000-1))' > > 2147483646 > > > > That was not a problem 5 years ago... But now we have a lot of 64-bits > > values. So those old scripts which perfectly worked for a long time > > now can give wrong results, and you will not be able even to notice > > it, there is no any diagnostics or such. The simplest way to fix it is > > to switch internal /bin/sh arithmetics from 32 to 64-bits (you know, > > approach "640K ought to be enough for anybody"). I've did the patch > > for this (below), please, look at it. Any comments or suggestions? > > > > diff -u -U1 -r ../sh.old/arith.h ./arith.h > > --- ../sh.old/arith.h Fri Jul 19 08:38:51 2002 > > +++ ./arith.h Sat Apr 5 06:26:48 2003 > > @@ -36,3 +36,3 @@ > > > > -int arith(char *); > > +long long arith(char *); > > int expcmd(int , char **); > > > > [snip rest of long-long using patch] >=20 > Nice idea, but we should probably ask the -standards people if we > can/should make this use uint64_t and %jd instead of `long long' > (using %qd is deprecated and %lld is advised in printf(3) anyway). intmax_t might be a better choice, if %jd is used :) G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@sbnd.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 If I had finished this sentence, --4SFOXa2GPu3tIq4H Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+kTx07Ri2jRYZRVMRAqZyAJ4tn1b9FvmYxoSdLltW+JDuJpHwawCfXrz8 Ue/A/ZctKUKp6spN4N4ejAA= =RNyF -----END PGP SIGNATURE----- --4SFOXa2GPu3tIq4H--