Author: avg
Date: Thu Sep 15 10:39:44 2011
New Revision: 225578
URL: http://svn.freebsd.org/changeset/base/225578

Log:
  MFC r209305,209358: Do not allow EOF token to be put back into input buffer.
  
  PR:           kern/159064
  On behalf of: kan, marcel

Modified:
  stable/8/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
Directory Properties:
  stable/8/cddl/contrib/opensolaris/   (props changed)

Modified: stable/8/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
==============================================================================
--- stable/8/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l     Thu Sep 
15 10:35:38 2011        (r225577)
+++ stable/8/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l     Thu Sep 
15 10:39:44 2011        (r225578)
@@ -44,7 +44,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) \
@@ -59,6 +59,19 @@
                        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)                                       \
+       do {                                            \
+               int _c = c;                             \
+               if (_c != EOF)                          \
+                       yyunput(_c, yytext_ptr);        \
+       } while(0)
 #endif
 
 static int id_or_type(const char *);
@@ -810,8 +823,7 @@ id_or_type(const char *s)
                        longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
        }
 
-       if (c0 != EOF)
-               unput(c0);
+       unput(c0);
        return (ttok);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to