Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Sep 2011 10:39:44 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r225578 - stable/8/cddl/contrib/opensolaris/lib/libdtrace/common
Message-ID:  <201109151039.p8FAdivN069802@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109151039.p8FAdivN069802>