summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2003-11-11 19:49:02 +0000
committerotto <otto@openbsd.org>2003-11-11 19:49:02 +0000
commit41b07621f247376c83781ae96a4dd9f489b817a7 (patch)
treee16bc0f20ca79fc4fc53378cdddafb5449d3019d
parentsync the field names with what's in the man page; (diff)
downloadwireguard-openbsd-41b07621f247376c83781ae96a4dd9f489b817a7.tar.xz
wireguard-openbsd-41b07621f247376c83781ae96a4dd9f489b817a7.zip
Some syntactic sugar (all non-portable extensions):
- a line comment, starting with # - opening brace of define statement may be on next line - return expression, equivalent to return (expression)
-rw-r--r--usr.bin/bc/bc.y30
-rw-r--r--usr.bin/bc/scan.l5
2 files changed, 18 insertions, 17 deletions
diff --git a/usr.bin/bc/bc.y b/usr.bin/bc/bc.y
index 992d200e4e6..91438ed20d8 100644
--- a/usr.bin/bc/bc.y
+++ b/usr.bin/bc/bc.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: bc.y,v 1.15 2003/11/11 09:15:36 otto Exp $ */
+/* $OpenBSD: bc.y,v 1.16 2003/11/11 19:49:02 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.15 2003/11/11 09:15:36 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bc.y,v 1.16 2003/11/11 19:49:02 otto Exp $";
#endif /* not lint */
#include <ctype.h>
@@ -266,22 +266,13 @@ statement : expression
fflush(stdout);
exit(0);
}
- | RETURN
+ | RETURN return_expression
{
if (nesting == 0) {
warning("return must be in a function");
YYERROR;
}
- $$ = node(cs("0"), epilogue,
- numnode(nesting), cs("Q"), END_NODE);
- }
- | RETURN LPAR return_expression RPAR
- {
- if (nesting == 0) {
- warning("return must be in a function");
- YYERROR;
- }
- $$ = $3;
+ $$ = $2;
}
| FOR LPAR alloc_macro opt_expression SEMICOLON
opt_relational_expression SEMICOLON
@@ -362,11 +353,11 @@ pop_nesting : /* empty */
}
;
-function : function_header opt_parameter_list RPAR
+function : function_header opt_parameter_list RPAR opt_newline
LBRACE NEWLINE opt_auto_define_list
statement_list RBRACE
{
- int n = node(prologue, $7, epilogue,
+ int n = node(prologue, $8, epilogue,
cs("0"), numnode(nesting),
cs("Q"), END_NODE);
emit_macro($1, n);
@@ -387,6 +378,10 @@ function_header : DEFINE LETTER LPAR
}
;
+opt_newline : /* empty */
+ | NEWLINE
+ ;
+
opt_parameter_list
: /* empty */
| parameter_list
@@ -511,6 +506,11 @@ return_expression
$$ = node($1, epilogue,
numnode(nesting), cs("Q"), END_NODE);
}
+ | LPAR RPAR
+ {
+ $$ = node(cs("0"), epilogue,
+ numnode(nesting), cs("Q"), END_NODE);
+ }
;
diff --git a/usr.bin/bc/scan.l b/usr.bin/bc/scan.l
index d6de138c6f3..6b419ad5256 100644
--- a/usr.bin/bc/scan.l
+++ b/usr.bin/bc/scan.l
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: scan.l,v 1.11 2003/11/11 09:15:36 otto Exp $ */
+/* $OpenBSD: scan.l,v 1.12 2003/11/11 19:49:02 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -18,7 +18,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: scan.l,v 1.11 2003/11/11 09:15:36 otto Exp $";
+static const char rcsid[] = "$OpenBSD: scan.l,v 1.12 2003/11/11 19:49:02 otto Exp $";
#endif /* not lint */
#include <err.h>
@@ -163,6 +163,7 @@ DIGIT [0-9A-F]
\\\n lineno++;
\n lineno++; return NEWLINE;
+#[^\n]* ;
[ \t] ;
. yyerror("illegal character");