diff --git a/compile.c b/compile.c index 4ee9251..12ae8fa 100644 --- a/compile.c +++ b/compile.c @@ -506,14 +506,19 @@ static const char *preamble= "\ #ifndef YY_BUFFER_START_SIZE\n\ #define YY_BUFFER_START_SIZE 1024\n\ #endif\n\ +#ifndef YY_TEXT_START_SIZE\n\ +#define YY_TEXT_START_SIZE 1024\n\ +#endif\n\ \n\ #ifndef YY_PART\n\ #define yydata G->data\n\ +#define yybuf G->buf\n\ +#define yycapture (*thunk)\n\ #define yy G->ss\n\ \n\ struct _yythunk; /* forward declaration */\n\ typedef void (*yyaction)(struct _GREG *G, char *yytext, int yyleng, struct _yythunk *thunkpos, YY_XTYPE YY_XVAR);\n\ -typedef struct _yythunk { int begin, end; yyaction action; const char *name; struct _yythunk *next; } yythunk;\n\ +typedef struct _yythunk { int begin, end; yyaction action; const char *name; } yythunk;\n\ \n\ typedef struct _GREG {\n\ char *buf;\n\ @@ -648,7 +653,7 @@ YY_LOCAL(int) yyText(GREG *G, int begin, int end)\n\ int yyleng= end - begin;\n\ if (yyleng <= 0)\n\ yyleng= 0;\n\ - else\n\ + else if (G->text)\n\ {\n\ while (G->textlen < (yyleng + 1))\n\ {\n\ @@ -657,7 +662,7 @@ YY_LOCAL(int) yyText(GREG *G, int begin, int end)\n\ }\n\ memcpy(G->text, G->buf + begin, yyleng);\n\ }\n\ - G->text[yyleng]= '\\0';\n\ + if (G->text) G->text[yyleng]= '\\0';\n\ return yyleng;\n\ }\n\ \n\ @@ -736,8 +741,8 @@ YY_PARSE(int) YY_NAME(parse_from)(GREG *G, yyrule yystart)\n\ {\n\ G->buflen= YY_BUFFER_START_SIZE;\n\ G->buf= (char*)YY_ALLOC(G->buflen, G->data);\n\ - G->textlen= YY_BUFFER_START_SIZE;\n\ - G->text= (char*)YY_ALLOC(G->textlen, G->data);\n\ + G->textlen= YY_TEXT_START_SIZE;\n\ + G->text= (char*)(G->textlen ? YY_ALLOC(G->textlen, G->data) : 0);\n\ G->thunkslen= YY_STACK_SIZE;\n\ G->thunks= (yythunk*)YY_ALLOC(sizeof(yythunk) * G->thunkslen, G->data);\n\ G->valslen= YY_STACK_SIZE;\n\