X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCC.lex;h=414d44a88cf142e37cb32e009dcd8df04036f4ea;hb=6965f5d1c138f1372a5f38cd4a5c5e19ccba7ecc;hp=bb3e7a894f56f20d3d32216dd3676f91eaa299e8;hpb=2f4eed72ea3a3f34795b26887679fdac2adc6b5d;p=fw%2Fsdcc diff --git a/src/SDCC.lex b/src/SDCC.lex index bb3e7a89..414d44a8 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -54,7 +54,8 @@ int yywrap YY_PROTO((void)) } #define TKEYWORD(token) return (isTargetKeyword(yytext) ? token :\ check_type(yytext)) -char asmbuff[MAX_INLINEASM] ; +char *asmbuff=NULL; +int asmbuffSize=0; char *asmp ; extern int check_type (); extern int isTargetKeyword (); @@ -82,14 +83,37 @@ struct options save_options ; %} %x asm %% -"_asm" { count(); asmp = asmbuff ;BEGIN(asm) ;} -"_endasm" { count() ; - *asmp = '\0' ; - strcpy(yylval.yyinline,asmbuff) ; - BEGIN(INITIAL) ; - return (INLINEASM) ; } -. { *asmp++ = yytext[0] ; } -\n { count(); *asmp++ = '\n' ;} +"_asm" { + count(); + asmp = asmbuff = Safe_realloc (asmbuff, INITIAL_INLINEASM); + asmbuffSize=INITIAL_INLINEASM; + BEGIN(asm) ; +} +"_endasm" { + count(); + *asmp = '\0'; + yylval.yyinline = Safe_calloc (1, strlen(asmbuff)+1); + strcpy(yylval.yyinline,asmbuff); + BEGIN(INITIAL); + return (INLINEASM); +} +. { + if (asmp-asmbuff >= asmbuffSize-2) { + // increase the buffersize with 50% + asmbuffSize=asmbuffSize*3/2; + asmbuff = Safe_realloc (asmbuff, asmbuffSize); + } + *asmp++ = yytext[0]; +} +\n { + count(); + if (asmp-asmbuff >= asmbuffSize-3) { + // increase the buffersize with 50% + asmbuffSize=asmbuffSize*3/2; + asmbuff = Safe_realloc (asmbuff, asmbuffSize); + } + *asmp++ = '\n' ; +} "/*" { comment(); } "at" { count(); TKEYWORD(AT) ; } "auto" { count(); return(AUTO); }