This PR partially supersedes bin/51171. In src/bin/sh/shell.h there's a following comment: /* * Type of used arithmetics. SUSv3 requires us to have at least signed long. */ However in sh(1) code int type is used in several places for arithmetics which prevents long arithmetics to work on architectures where sizeof(int) != sizeof(long). Fix: I have attached two patches here. The first one converts places still using int instead of arith_t to use arith_t. It also converts hardcoded format strings to ARITH_FORMAT_STR and removes the hardcoded limitation of 10 characters for numbers. The second patch which must be applied on top of the first one converts arith_t from long to intmax_t. This patch is not strictly needed to comply with SUS but it extends 32 bit arithmetics to 64 bits for example on i386. How-To-Repeat: $ sh -c 'uname -m; echo $((2147483647 + 1))' amd64 -2147483648
Responsible Changed From-To: freebsd-bugs->stefanf I will handle this.
stefanf 2008-04-27 20:25:43 UTC FreeBSD src repository Modified files: (Branch: RELENG_6) bin/sh arith.h arith.y expand.c shell.h Log: - Fix bugs where the value of arithmetic expansion$((...)) was trucated to type int. - Change the type used for arithmetic expansion to intmax_t (ie. 64 bit on all currently supported FreeBSD architectures). SUSv3 requires at least type long but allows for larger types. Other shells (eg. bash, zsh, NetBSD's sh) do that too. PR: 122659 Submitted by: Jaakko Heinonen (minor modifications by me) Revision Changes Path 1.9.8.2 +5 -1 src/bin/sh/arith.h 1.19.8.2 +13 -9 src/bin/sh/arith.y 1.47.2.4 +3 -6 src/bin/sh/expand.c 1.17.8.1 +11 -4 src/bin/sh/shell.h _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
stefanf 2008-04-27 20:46:45 UTC FreeBSD src repository Modified files: bin/sh arith.h arith.y shell.h Log: - Fix bugs where the value of arithmetic expansion$((...)) was trucated to type int. - Change the type used for arithmetic expansion to intmax_t (ie. 64 bit on all currently supported FreeBSD architectures). SUSv3 requires at least type long but allows for larger types. Other shells (eg. bash, zsh, NetBSD's sh) do that too. PR: 122659 Submitted by: Jaakko Heinonen (minor modifications by me) Revision Changes Path 1.12 +5 -1 src/bin/sh/arith.h 1.22 +13 -9 src/bin/sh/arith.y 1.18 +11 -4 src/bin/sh/shell.h _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
State Changed From-To: open->patched Fixed in HEAD.
Stefan, this has been committed to HEAD and RELENG_6 but not to RELENG_7. Can you please check? Volker
On Sat, May 10, 2008 at 07:10:04PM +0000, Volker wrote: > The following reply was made to PR bin/122659; it has been noted by GNATS. > > From: Volker <volker@vwsoft.com> > To: bug-followup@FreeBSD.org, stefanf@freebsd.org > Cc: jh@saunalahti.fi > Subject: Re: bin/122659: [patch] sh(1) long arithmetics broken on certain > architectures > Date: Sat, 10 May 2008 22:04:42 +0200 > > Stefan, > > this has been committed to HEAD and RELENG_6 but not to RELENG_7. Can > you please check? The commit to RELENG_6 was an error and backed out. I will merge this change to RELENG_{6,7} these days.
State Changed From-To: patched->closed Already merged back into 7 and 8.