[defined YYSETJMP]: Don't include <setjmp.h>.

(YYJMP_BUF, YYSETJMP, YYLONGJMP) [!defined YYSETJMP]: New macros.
All uses of jmp_buf, setjmp, longjmp changed to use these instead.
(yyparse): Abort if user code uses longjmp to throw an unexpected
value.
This commit is contained in:
Paul Eggert
2005-09-12 05:50:44 +00:00
parent d83a9c402c
commit c89b4c032c

View File

@@ -221,7 +221,6 @@ b4_syncline([@oline@], [@ofile@])
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <setjmp.h>
#ifndef YY_ #ifndef YY_
# if YYENABLE_NLS # if YYENABLE_NLS
@@ -255,6 +254,13 @@ b4_syncline([@oline@], [@ofile@])
#define yytrue 1 #define yytrue 1
#define yyfalse 0 #define yyfalse 0
#ifndef YYSETJMP
# include <setjmp.h>
# define YYJMP_BUF jmp_buf
# define YYSETJMP(env) setjmp (env)
# define YYLONGJMP(env, val) longjmp (env, val)
#endif
/*-----------------. /*-----------------.
| GCC extensions. | | GCC extensions. |
`-----------------*/ `-----------------*/
@@ -728,7 +734,7 @@ struct yyGLRStack {
int yyrawchar; int yyrawchar;
])[ ])[
yySymbol* yytokenp; yySymbol* yytokenp;
jmp_buf yyexception_buffer; YYJMP_BUF yyexception_buffer;
yyGLRStackItem* yyitems; yyGLRStackItem* yyitems;
yyGLRStackItem* yynextFree; yyGLRStackItem* yynextFree;
size_t yyspaceLeft; size_t yyspaceLeft;
@@ -746,7 +752,7 @@ yyFail (yyGLRStack* yystack]b4_pure_formals[, const char* yymsg)
{ {
if (yymsg != NULL) if (yymsg != NULL)
yyerror (]b4_yyerror_args[yymsg); yyerror (]b4_yyerror_args[yymsg);
longjmp (yystack->yyexception_buffer, 1); YYLONGJMP (yystack->yyexception_buffer, 1);
} }
static void yyMemoryExhausted (yyGLRStack* yystack) static void yyMemoryExhausted (yyGLRStack* yystack)
@@ -754,7 +760,7 @@ static void yyMemoryExhausted (yyGLRStack* yystack)
static void static void
yyMemoryExhausted (yyGLRStack* yystack) yyMemoryExhausted (yyGLRStack* yystack)
{ {
longjmp (yystack->yyexception_buffer, 2); YYLONGJMP (yystack->yyexception_buffer, 2);
} }
#if YYDEBUG || YYERROR_VERBOSE #if YYDEBUG || YYERROR_VERBOSE
@@ -2081,10 +2087,12 @@ b4_syncline([@oline@], [@ofile@])])dnl
[ [
if (! yyinitGLRStack (&yystack, YYINITDEPTH)) if (! yyinitGLRStack (&yystack, YYINITDEPTH))
goto yyexhaustedlab; goto yyexhaustedlab;
switch (setjmp (yystack.yyexception_buffer)) switch (YYSETJMP (yystack.yyexception_buffer))
{ {
case 0: break;
case 1: goto yyabortlab; case 1: goto yyabortlab;
case 2: goto yyexhaustedlab; case 2: goto yyexhaustedlab;
default: goto yybuglab;
} }
yystack.yytokenp = &yytoken; yystack.yytokenp = &yytoken;
yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc); yyglrShift (&yystack, 0, 0, 0, yylval, &yylloc);