Bring usr.bin/lex up to c++ standards

Andreas Hauser andy at splashground.de
Wed Aug 17 16:02:29 PDT 2005


Hoi,

this brings our lex up to the c++ standards our gcc wants (namespaces).
Obtained from FreeBSD.
Is needed to compile kdesdk.


Andy

http://ftp.fortunaty.net/DragonFly/inofficial/patches/lex.patch

Index: usr.bin/lex/FlexLexer.h
===================================================================
RCS file: /home/dcvs/src/usr.bin/lex/FlexLexer.h,v
retrieving revision 1.2
diff -u -p -r1.2 FlexLexer.h
--- usr.bin/lex/FlexLexer.h	17 Jun 2003 04:29:27 -0000	1.2
+++ usr.bin/lex/FlexLexer.h	17 Aug 2005 20:21:15 -0000
@@ -1,5 +1,5 @@
 // $Header: /home/daffy/u0/vern/flex/RCS/FlexLexer.h,v 1.19 96/05/25 20:43:02 vern Exp $
-// $FreeBSD: src/usr.bin/lex/FlexLexer.h,v 1.3 1999/10/27 07:56:43 obrien Exp $
+// $FreeBSD: src/usr.bin/lex/FlexLexer.h,v 1.4 2004/03/11 10:43:35 josef Exp $
 // $DragonFly: src/usr.bin/lex/FlexLexer.h,v 1.2 2003/06/17 04:29:27 dillon Exp $
 
 // FlexLexer.h -- define interfaces for lexical analyzer classes generated
@@ -45,7 +45,7 @@
 #ifndef __FLEX_LEXER_H
 // Never included before - need to define base class.
 #define __FLEX_LEXER_H
-#include <iostream.h>
+#include <iostream>
 
 extern "C++" {
 
@@ -62,14 +62,14 @@ public:
 	virtual void
 		yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
 	virtual struct yy_buffer_state*
-		yy_create_buffer( istream* s, int size ) = 0;
+		yy_create_buffer( std::istream* s, int size ) = 0;
 	virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
-	virtual void yyrestart( istream* s ) = 0;
+	virtual void yyrestart( std::istream* s ) = 0;
 
 	virtual int yylex() = 0;
 
 	// Call yylex with new input/output sources.
-	int yylex( istream* new_in, ostream* new_out = 0 )
+	int yylex( std::istream* new_in, std::ostream* new_out = 0 )
 		{
 		switch_streams( new_in, new_out );
 		return yylex();
@@ -77,8 +77,8 @@ public:
 
 	// Switch to new input/output streams.  A nil stream pointer
 	// indicates "keep the current one".
-	virtual void switch_streams( istream* new_in = 0,
-					ostream* new_out = 0 ) = 0;
+	virtual void switch_streams( std::istream* new_in = 0,
+					std::ostream* new_out = 0 ) = 0;
 
 	int lineno() const		{ return yylineno; }
 
@@ -105,17 +105,17 @@ class yyFlexLexer : public FlexLexer {
 public:
 	// arg_yyin and arg_yyout default to the cin and cout, but we
 	// only make that assignment when initializing in yylex().
-	yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
+	yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
 
 	virtual ~yyFlexLexer();
 
 	void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
-	struct yy_buffer_state* yy_create_buffer( istream* s, int size );
+	struct yy_buffer_state* yy_create_buffer( std::istream* s, int size );
 	void yy_delete_buffer( struct yy_buffer_state* b );
-	void yyrestart( istream* s );
+	void yyrestart( std::istream* s );
 
 	virtual int yylex();
-	virtual void switch_streams( istream* new_in, ostream* new_out );
+	virtual void switch_streams( std::istream* new_in, std::ostream* new_out );
 
 protected:
 	virtual int LexerInput( char* buf, int max_size );
@@ -126,7 +126,7 @@ protected:
 	int yyinput();
 
 	void yy_load_buffer_state();
-	void yy_init_buffer( struct yy_buffer_state* b, istream* s );
+	void yy_init_buffer( struct yy_buffer_state* b, std::istream* s );
 	void yy_flush_buffer( struct yy_buffer_state* b );
 
 	int yy_start_stack_ptr;
@@ -141,8 +141,8 @@ protected:
 	yy_state_type yy_try_NUL_trans( yy_state_type current_state );
 	int yy_get_next_buffer();
 
-	istream* yyin;	// input source for default LexerInput
-	ostream* yyout;	// output sink for default LexerOutput
+	std::istream* yyin;	// input source for default LexerInput
+	std::ostream* yyout;	// output sink for default LexerOutput
 
 	struct yy_buffer_state* yy_current_buffer;
 
Index: usr.bin/lex/flex.skl
===================================================================
RCS file: /home/dcvs/src/usr.bin/lex/flex.skl,v
retrieving revision 1.4
diff -u -p -r1.4 flex.skl
--- usr.bin/lex/flex.skl	2 Mar 2005 07:09:38 -0000	1.4
+++ usr.bin/lex/flex.skl	17 Aug 2005 20:28:22 -0000
@@ -27,7 +27,8 @@
 
 #include <stdlib.h>
 %+
-class istream;
+#include <iosfwd>
+using namespace std;
 %*
 #include <unistd.h>
 
@@ -1170,6 +1171,12 @@ void yyFlexLexer::yy_delete_buffer( YY_B
 
 
 %-
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
 #ifdef YY_USE_PROTOS
 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
 #else
Index: usr.bin/lex/yylex.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/lex/yylex.c,v
retrieving revision 1.3
diff -u -p -r1.3 yylex.c
--- usr.bin/lex/yylex.c	4 Oct 2003 20:36:47 -0000	1.3
+++ usr.bin/lex/yylex.c	17 Aug 2005 20:29:01 -0000
@@ -37,7 +37,7 @@
 
 /* yylex - scan for a regular expression token */
 
-int yylex(void)
+int yylex()
 	{
 	int toktype;
 	static int beglin = false;





More information about the Submit mailing list