Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh PR/50958: (partial fix) - support ?: expressions in a...
details: https://anonhg.NetBSD.org/src/rev/48941c7a08ec
branches: trunk
changeset: 814315:48941c7a08ec
user: christos <christos%NetBSD.org@localhost>
date: Wed Mar 16 15:42:33 2016 +0000
description:
PR/50958: (partial fix) - support ?: expressions in arith expansions
(from kre)
diffstat:
bin/sh/arith.y | 6 ++++--
bin/sh/arith_lex.l | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diffs (63 lines):
diff -r 109c94bd2680 -r 48941c7a08ec bin/sh/arith.y
--- a/bin/sh/arith.y Wed Mar 16 15:41:55 2016 +0000
+++ b/bin/sh/arith.y Wed Mar 16 15:42:33 2016 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: arith.y,v 1.22 2012/03/20 18:42:29 matt Exp $ */
+/* $NetBSD: arith.y,v 1.23 2016/03/16 15:42:33 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.22 2012/03/20 18:42:29 matt Exp $");
+__RCSID("$NetBSD: arith.y,v 1.23 2016/03/16 15:42:33 christos Exp $");
#endif
#endif /* not lint */
@@ -65,6 +65,7 @@
%}
%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN
+%left ARITH_QM ARITH_COLON
%left ARITH_OR
%left ARITH_AND
%left ARITH_BOR
@@ -89,6 +90,7 @@
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_BOR expr { $$ = $1 | $3; }
diff -r 109c94bd2680 -r 48941c7a08ec bin/sh/arith_lex.l
--- a/bin/sh/arith_lex.l Wed Mar 16 15:41:55 2016 +0000
+++ b/bin/sh/arith_lex.l Wed Mar 16 15:42:33 2016 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: arith_lex.l,v 1.17 2016/03/16 15:41:55 christos Exp $ */
+/* $NetBSD: arith_lex.l,v 1.18 2016/03/16 15:42:33 christos Exp $ */
/*-
* Copyright (c) 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: arith_lex.l,v 1.17 2016/03/16 15:41:55 christos Exp $");
+__RCSID("$NetBSD: arith_lex.l,v 1.18 2016/03/16 15:42:33 christos Exp $");
#endif
#endif /* not lint */
@@ -92,6 +92,8 @@
"-" { return(ARITH_SUB); }
"~" { return(ARITH_BNOT); }
"!" { return(ARITH_NOT); }
+"?" { return(ARITH_QM); }
+":" { return(ARITH_COLON); }
. { error("arith: syntax error: \"%s\"", arith_startbuf); }
%%
Home |
Main Index |
Thread Index |
Old Index