diff options
author | Alexander Kabaev <kan@FreeBSD.org> | 2010-06-18 16:07:24 +0000 |
---|---|---|
committer | Alexander Kabaev <kan@FreeBSD.org> | 2010-06-18 16:07:24 +0000 |
commit | 283bcf71ad8bed94cef3d966c147f28354680f88 (patch) | |
tree | ff55e895063fd762e912eac5cab8cec466d5b782 /cddl/contrib | |
parent | c8812077bf640ee5073598870bb03eb307a866c1 (diff) | |
download | src-283bcf71ad8bed94cef3d966c147f28354680f88.tar.gz src-283bcf71ad8bed94cef3d966c147f28354680f88.zip |
Do not allow EOF token to be put back into input buffer.
This reimplements previous change from r20930 in more generic way.
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=209305
Diffstat (limited to 'cddl/contrib')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l index 568a2a1e9054..5c17e9270eda 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l @@ -45,7 +45,7 @@ #undef input #undef unput #else -/* +/* * Define YY_INPUT for flex since input() can't be re-defined. */ #define YY_INPUT(buf,result,max_size) \ @@ -60,6 +60,15 @@ buf[n] = *yypcb->pcb_strptr++; \ result = n; \ } +/* + * Do not EOF let tokens to be put back. This does not work with flex. + * On the other hand, leaving current buffer in same state it was when + * last EOF was received guarantees that input() will keep returning EOF + * for all subsequent invocations, which is the effect desired. + */ +#undef unput +#define unput(c) \ + if (c != EOF) yyunput( c, yytext_ptr ) #endif static int id_or_type(const char *); @@ -811,8 +820,7 @@ id_or_type(const char *s) longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM); } - if (c0 != EOF) - unput(c0); + unput(c0); return (ttok); } |