]> granicus.if.org Git - php/commitdiff
Implement fast scanning in the multithreaded environment
authorZeev Suraski <zeev@php.net>
Wed, 1 Aug 2001 02:36:05 +0000 (02:36 +0000)
committerZeev Suraski <zeev@php.net>
Wed, 1 Aug 2001 02:36:05 +0000 (02:36 +0000)
Zend/flex.skl
Zend/zend_language_scanner.l

index 50be07a40f544f17026271319a1730f2447e5c6e..fb60c3ec9f2872309fdfc3bfedaf882a64fa14ea 100644 (file)
@@ -693,34 +693,29 @@ void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
                yyout = new_out;
        }
 
-#ifdef YY_INTERACTIVE
-int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
-#else
 int yyFlexLexer::LexerInput( char* buf, int max_size )
-#endif
        {
-       if ( yyin->eof() || yyin->fail() )
-               return 0;
+               if ( yyin->eof() || yyin->fail() )
+                       return 0;
 
-#ifdef YY_INTERACTIVE
-       yyin->get( buf[0] );
+               if (yy_current_buffer->yy_is_interactive) {
+                       yyin->get( buf[0] );
 
-       if ( yyin->eof() )
-               return 0;
-
-       if ( yyin->bad() )
-               return -1;
+                       if ( yyin->eof() )
+                               return 0;
 
-       return 1;
+                       if ( yyin->bad() )
+                               return -1;
 
-#else
-       (void) yyin->read( buf, max_size );
+                       return 1;
+               } else {
+                       (void) yyin->read( buf, max_size );
 
-       if ( yyin->bad() )
-               return -1;
-       else
-               return yyin->gcount();
-#endif
+                       if ( yyin->bad() )
+                               return -1;
+                       else
+                               return yyin->gcount();
+               }
        }
 
 void yyFlexLexer::LexerOutput( const char* buf, int size )
@@ -1213,7 +1208,7 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
 #endif
 #endif
 %+
-       b->yy_is_interactive = 0;
+       b->yy_is_interactive = (file == (istream *) &cin) ? 1 : 0;
 %*
        }
 
index 71e63d182016a24f698b65a8683b0b48d6b5642f..9b19423fc24e351054b73ab1bcdd4e0f1e246797 100644 (file)
@@ -78,8 +78,6 @@
 #define YY_DECL int lex_scan(zval *zendlval TSRMLS_DC)
 #endif
 
-#define YY_INTERACTIVE
-
 #define ECHO { ZEND_WRITE( yytext, yyleng ); }
 
 #ifdef ZTS