summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/bc/bc.18
-rw-r--r--usr.bin/bc/bc.y26
2 files changed, 26 insertions, 8 deletions
diff --git a/usr.bin/bc/bc.1 b/usr.bin/bc/bc.1
index d6734a810fc..26ed11be713 100644
--- a/usr.bin/bc/bc.1
+++ b/usr.bin/bc/bc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: bc.1,v 1.6 2003/10/18 19:57:10 otto Exp $
+.\" $OpenBSD: bc.1,v 1.7 2003/10/19 19:21:48 otto Exp $
.\"
.\" Copyright (C) Caldera International Inc. 2001-2002.
.\" All rights reserved.
@@ -125,6 +125,10 @@ quit
a string of characters, enclosed in double quotes
.Ed
.Pp
+The E's in a for statement may all three be empty.
+This is a non-portable extension.
+The continue statement also is a non-portable extension.
+.Pp
Function definitions
.Bd -unfilled -offset indent -compact
define L ( L ,..., L ) {
@@ -232,8 +236,6 @@ or
.Sq \&!
operators.
.Pp
-.Ql For
-statements must have all three E's.
.Pp
.Ql Quit
is interpreted when read, not when executed.
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y
index c97fbeb803a..e0f876f8a00 100644
--- a/usr.bin/bc/bc.y
+++ b/usr.bin/bc/bc.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: bc.y,v 1.12 2003/10/18 20:35:36 otto Exp $ */
+/* $OpenBSD: bc.y,v 1.13 2003/10/19 19:21:48 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: bc.y,v 1.12 2003/10/18 20:35:36 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bc.y,v 1.13 2003/10/19 19:21:48 otto Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -138,6 +138,8 @@ extern char *__progname;
%type <node> function_header
%type <node> input_item
%type <node> opt_argument_list
+%type <node> opt_expression
+%type <node> opt_relational_expression
%type <node> opt_statement
%type <node> relational_expression
%type <node> return_expression
@@ -278,9 +280,9 @@ statement : expression
}
$$ = $3;
}
- | FOR LPAR alloc_macro expression SEMICOLON
- relational_expression SEMICOLON
- expression RPAR opt_statement pop_nesting
+ | FOR LPAR alloc_macro opt_expression SEMICOLON
+ opt_relational_expression SEMICOLON
+ opt_expression RPAR opt_statement pop_nesting
{
ssize_t n;
@@ -443,6 +445,13 @@ argument_list : expression
}
;
+opt_relational_expression
+ : /* empty */
+ {
+ $$ = cs(" 0 0=");
+ }
+ | relational_expression
+ ;
relational_expression
: expression
@@ -490,6 +499,13 @@ return_expression
;
+opt_expression : /* empty */
+ {
+ $$ = cs(" 0");
+ }
+ | expression
+ ;
+
expression : named_expression
{
$$ = node($1.load, END_NODE);