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)
This commit is contained in:
parent
8a605b3f64
commit
4fff7a14ae
@ -269,8 +269,12 @@ expand_builtin(const char *argv[], int argc, int td)
|
|||||||
case INCLTYPE:
|
case INCLTYPE:
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
if (!doincl(argv[2]))
|
if (!doincl(argv[2]))
|
||||||
err(1, "%s at line %lu: include(%s)",
|
if (mimic_gnu)
|
||||||
CURRENT_NAME, CURRENT_LINE, argv[2]);
|
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;
|
break;
|
||||||
|
|
||||||
case SINCTYPE:
|
case SINCTYPE:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <math.h>
|
||||||
#define YYSTYPE int32_t
|
#define YYSTYPE int32_t
|
||||||
extern int32_t end_result;
|
extern int32_t end_result;
|
||||||
extern int yylex(void);
|
extern int yylex(void);
|
||||||
@ -34,6 +35,7 @@ extern int yyparse(void);
|
|||||||
%left EQ NE
|
%left EQ NE
|
||||||
%left '<' LE '>' GE
|
%left '<' LE '>' GE
|
||||||
%left LSHIFT RSHIFT
|
%left LSHIFT RSHIFT
|
||||||
|
%right EXPONENT
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/' '%'
|
%left '*' '/' '%'
|
||||||
%right UMINUS UPLUS '!' '~'
|
%right UMINUS UPLUS '!' '~'
|
||||||
@ -44,6 +46,7 @@ top : expr { end_result = $1; }
|
|||||||
;
|
;
|
||||||
expr : expr '+' expr { $$ = $1 + $3; }
|
expr : expr '+' expr { $$ = $1 + $3; }
|
||||||
| expr '-' expr { $$ = $1 - $3; }
|
| expr '-' expr { $$ = $1 - $3; }
|
||||||
|
| expr EXPONENT expr { $$ = pow($1, $3); }
|
||||||
| expr '*' expr { $$ = $1 * $3; }
|
| expr '*' expr { $$ = $1 * $3; }
|
||||||
| expr '/' expr {
|
| expr '/' expr {
|
||||||
if ($3 == 0) {
|
if ($3 == 0) {
|
||||||
|
@ -57,6 +57,7 @@ radix 0[rR][0-9]+:[0-9a-zA-Z]+
|
|||||||
"!=" { return(NE); }
|
"!=" { return(NE); }
|
||||||
"&&" { return(LAND); }
|
"&&" { return(LAND); }
|
||||||
"||" { return(LOR); }
|
"||" { return(LOR); }
|
||||||
|
"**" { if (mimic_gnu) { return (EXPONENT); } }
|
||||||
. { return yytext[0]; }
|
. { return yytext[0]; }
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user