Module Name:    src
Committed By:   christos
Date:           Wed Mar 16 15:42:33 UTC 2016

Modified Files:
        src/bin/sh: arith.y arith_lex.l

Log Message:
PR/50958: (partial fix) - support ?: expressions in arith expansions
(from kre)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/bin/sh/arith.y
cvs rdiff -u -r1.17 -r1.18 src/bin/sh/arith_lex.l

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.22 src/bin/sh/arith.y:1.23
--- src/bin/sh/arith.y:1.22	Tue Mar 20 14:42:29 2012
+++ src/bin/sh/arith.y	Wed Mar 16 11:42:33 2016
@@ -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 @@ int error(char *);
 %}
 %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 @@ 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_BOR expr	{ $$ = $1 | $3; }

Index: src/bin/sh/arith_lex.l
diff -u src/bin/sh/arith_lex.l:1.17 src/bin/sh/arith_lex.l:1.18
--- src/bin/sh/arith_lex.l:1.17	Wed Mar 16 11:41:55 2016
+++ src/bin/sh/arith_lex.l	Wed Mar 16 11:42:33 2016
@@ -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 @@ extern const char *arith_buf, *arith_sta
 "-"	{ return(ARITH_SUB); }
 "~"	{ return(ARITH_BNOT); }
 "!"	{ return(ARITH_NOT); }
+"?"	{ return(ARITH_QM); }
+":"	{ return(ARITH_COLON); }
 .	{ error("arith: syntax error: \"%s\"", arith_startbuf); }
 %%
 

Reply via email to