mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
new m4 -g stuff:
- expr(`4**3') - include(`hey I am not there') keeps going. work with Baptiste Daroussin, who had the idea but didn't nail all details right. okay otto@, miod@
This commit is contained in:
parent
4c4dcd9673
commit
a45fdd0c50
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.11 2004/05/12 21:17:03 espie Exp $
|
||||
# $OpenBSD: Makefile,v 1.12 2012/04/12 17:00:11 espie Exp $
|
||||
|
||||
# -DEXTENDED
|
||||
# if you want the paste & spaste macros.
|
||||
@ -8,8 +8,8 @@ CFLAGS+=-DEXTENDED -I.
|
||||
CDIAGFLAGS=-W -Wall -Wstrict-prototypes -pedantic \
|
||||
-Wno-unused -Wno-char-subscripts -Wno-sign-compare
|
||||
|
||||
LDADD= -ly -ll
|
||||
DPADD= ${LIBY} ${LIBL}
|
||||
LDADD= -ly -ll -lm
|
||||
DPADD= ${LIBY} ${LIBL} ${LIBM}
|
||||
|
||||
SRCS= eval.c expr.c look.c main.c misc.c gnum4.c trace.c tokenizer.l parser.y
|
||||
MAN= m4.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: eval.c,v 1.69 2011/03/24 11:23:08 espie Exp $ */
|
||||
/* $OpenBSD: eval.c,v 1.70 2012/04/12 17:00:11 espie Exp $ */
|
||||
/* $NetBSD: eval.c,v 1.7 1996/11/10 21:21:29 pk Exp $ */
|
||||
|
||||
/*
|
||||
@ -264,8 +264,13 @@ 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]);
|
||||
exit_code = 1;
|
||||
} else
|
||||
err(1, "%s at line %lu: include(%s)",
|
||||
CURRENT_NAME, CURRENT_LINE, argv[2]);
|
||||
break;
|
||||
|
||||
case SINCTYPE:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: extern.h,v 1.51 2011/09/27 07:24:02 espie Exp $ */
|
||||
/* $OpenBSD: extern.h,v 1.52 2012/04/12 17:00:11 espie Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */
|
||||
|
||||
/*-
|
||||
@ -86,6 +86,7 @@ extern ndptr macro_getbuiltin(const char *);
|
||||
/* main.c */
|
||||
extern void outputstr(const char *);
|
||||
extern void do_emit_synchline(void);
|
||||
extern int exit_code;
|
||||
#define emit_synchline() do { if (synch_lines) do_emit_synchline(); } while(0)
|
||||
|
||||
/* misc.c */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: main.c,v 1.80 2011/09/27 07:24:02 espie Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.81 2012/04/12 17:00:11 espie Exp $ */
|
||||
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -165,6 +165,8 @@ static void enlarge_stack(void);
|
||||
|
||||
int main(int, char *[]);
|
||||
|
||||
int exit_code = 0;
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -283,7 +285,7 @@ main(int argc, char *argv[])
|
||||
(void) fclose(outfile[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,5 @@
|
||||
%{
|
||||
/* $OpenBSD: parser.y,v 1.6 2008/08/21 21:00:14 espie Exp $ */
|
||||
/* $OpenBSD: parser.y,v 1.7 2012/04/12 17:00:11 espie Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
|
||||
*
|
||||
@ -15,6 +15,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#define YYSTYPE int32_t
|
||||
extern int32_t end_result;
|
||||
@ -33,6 +34,7 @@ extern int yyerror(const char *);
|
||||
%left LSHIFT RSHIFT
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%right EXPONENT
|
||||
%right UMINUS UPLUS '!' '~'
|
||||
|
||||
%%
|
||||
@ -41,6 +43,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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
%{
|
||||
/* $OpenBSD: tokenizer.l,v 1.7 2010/03/22 20:40:44 espie Exp $ */
|
||||
/* $OpenBSD: tokenizer.l,v 1.8 2012/04/12 17:00:11 espie Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
|
||||
*
|
||||
@ -53,6 +53,7 @@ radix 0[rR][0-9]+:[0-9a-zA-Z]+
|
||||
"!=" { return(NE); }
|
||||
"&&" { return(LAND); }
|
||||
"||" { return(LOR); }
|
||||
"**" { if (mimic_gnu) { return (EXPONENT); } }
|
||||
. { return yytext[0]; }
|
||||
%%
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user