Module Name: src Committed By: christos Date: Wed Mar 16 15:43:38 UTC 2016
Modified Files: src/bin/sh: arith.y Log Message: PR/50960: The || and && operators in $(( )) should always have a 0 or 1 result, never anything different. (from kre) To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/bin/sh/arith.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/arith.y diff -u src/bin/sh/arith.y:1.23 src/bin/sh/arith.y:1.24 --- src/bin/sh/arith.y:1.23 Wed Mar 16 11:42:33 2016 +++ src/bin/sh/arith.y Wed Mar 16 11:43:38 2016 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: arith.y,v 1.23 2016/03/16 15:42:33 christos Exp $ */ +/* $NetBSD: arith.y,v 1.24 2016/03/16 15:43:38 christos Exp $ */ /*- * Copyright (c) 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: arith.y,v 1.23 2016/03/16 15:42:33 christos Exp $"); +__RCSID("$NetBSD: arith.y,v 1.24 2016/03/16 15:43:38 christos Exp $"); #endif #endif /* not lint */ @@ -91,8 +91,8 @@ exp: expr { expr: ARITH_LPAREN expr ARITH_RPAREN { $$ = $2; } | expr ARITH_QM expr ARITH_COLON expr { $$ = $1 ? $3 : $5; } - | expr ARITH_OR expr { $$ = $1 ? $1 : $3 ? $3 : 0; } - | expr ARITH_AND expr { $$ = $1 ? ( $3 ? $3 : 0 ) : 0; } + | expr ARITH_OR expr { $$ = ($1 ? 1 : $3 ? 1 : 0); } + | expr ARITH_AND expr { $$ = ($1 ? ( $3 ? 1 : 0 ) : 0); } | expr ARITH_BOR expr { $$ = $1 | $3; } | expr ARITH_BXOR expr { $$ = $1 ^ $3; } | expr ARITH_BAND expr { $$ = $1 & $3; }