summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2011-12-18 22:04:55 +0000
committerbapt <bapt@FreeBSD.org>2011-12-18 22:04:55 +0000
commite5ed1943238d5e0810656826221c9b6efe93d38a (patch)
tree0fb53cefa7c76fbd0599150cae313b3479cdfb17 /usr.bin
parent0283ff3e7267d5de73c77ca8a72a54e7f7f05887 (diff)
downloadFreeBSD-src-e5ed1943238d5e0810656826221c9b6efe93d38a.zip
FreeBSD-src-e5ed1943238d5e0810656826221c9b6efe93d38a.tar.gz
Reimplement support for the ** (exponent) gnu extension, make it available thought the -g (mimic gnu) option
Reviewed by: cognet Approved by: cognet Discussed with: espie@OpenBSD.org (upstream)
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/m4/eval.c8
-rw-r--r--usr.bin/m4/parser.y3
-rw-r--r--usr.bin/m4/tokenizer.l1
3 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/m4/eval.c b/usr.bin/m4/eval.c
index 9e5162f..c857b91 100644
--- a/usr.bin/m4/eval.c
+++ b/usr.bin/m4/eval.c
@@ -269,8 +269,12 @@ expand_builtin(const char *argv[], int argc, int td)
case INCLTYPE:
if (argc > 2)
if (!doincl(argv[2]))
- err(1, "%s at line %lu: include(%s)",
- CURRENT_NAME, CURRENT_LINE, argv[2]);
+ if (mimic_gnu)
+ warn("%s at line %lu: include(%s)",
+ CURRENT_NAME, CURRENT_LINE, argv[2]);
+ else
+ err(1, "%s at line %lu: include(%s)",
+ CURRENT_NAME, CURRENT_LINE, argv[2]);
break;
case SINCTYPE:
diff --git a/usr.bin/m4/parser.y b/usr.bin/m4/parser.y
index fac6709..deda962 100644
--- a/usr.bin/m4/parser.y
+++ b/usr.bin/m4/parser.y
@@ -18,6 +18,7 @@
* $FreeBSD$
*/
#include <stdint.h>
+#include <math.h>
#define YYSTYPE int32_t
extern int32_t end_result;
extern int yylex(void);
@@ -34,6 +35,7 @@ extern int yyparse(void);
%left EQ NE
%left '<' LE '>' GE
%left LSHIFT RSHIFT
+%right EXPONENT
%left '+' '-'
%left '*' '/' '%'
%right UMINUS UPLUS '!' '~'
@@ -44,6 +46,7 @@ top : expr { end_result = $1; }
;
expr : expr '+' expr { $$ = $1 + $3; }
| expr '-' expr { $$ = $1 - $3; }
+ | expr EXPONENT expr { $$ = pow($1, $3); }
| expr '*' expr { $$ = $1 * $3; }
| expr '/' expr {
if ($3 == 0) {
diff --git a/usr.bin/m4/tokenizer.l b/usr.bin/m4/tokenizer.l
index e9c9e12..ca3612e 100644
--- a/usr.bin/m4/tokenizer.l
+++ b/usr.bin/m4/tokenizer.l
@@ -57,6 +57,7 @@ radix 0[rR][0-9]+:[0-9a-zA-Z]+
"!=" { return(NE); }
"&&" { return(LAND); }
"||" { return(LOR); }
+"**" { if (mimic_gnu) { return (EXPONENT); } }
. { return yytext[0]; }
%%
OpenPOWER on IntegriCloud