]> granicus.if.org Git - flex/commitdiff
snapshot of cscope yymore fixes, prior to switching yymore-on-%array approach
authorVern Paxson <vern@ee.lbl.gov>
Sat, 25 May 1996 15:26:38 +0000 (15:26 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Sat, 25 May 1996 15:26:38 +0000 (15:26 +0000)
flex.skl

index 218e6524e2f6ddace30fa0797e206c01de651136..e6ebec8a2508d8d317461cb38c7b5dbcc85b4b71 100644 (file)
--- a/flex.skl
+++ b/flex.skl
@@ -749,7 +749,7 @@ int yyFlexLexer::yy_get_next_buffer()
                { /* Don't try to fill the buffer, so this is an EOF. */
                if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
                        {
-                       /* We matched a singled characater, the EOB, so
+                       /* We matched a single character, the EOB, so
                         * treat this as a final EOF.
                         */
                        return EOB_ACT_END_OF_FILE;
@@ -985,7 +985,7 @@ int yyFlexLexer::yyinput()
 
                else
                        { /* need more input */
-                       yytext_ptr = yy_c_buf_p;
+                       int offset = yy_c_buf_p - yytext_ptr;
                        ++yy_c_buf_p;
 
                        switch ( yy_get_next_buffer() )
@@ -994,8 +994,7 @@ int yyFlexLexer::yyinput()
                                        {
                                        if ( yywrap() )
                                                {
-                                               yy_c_buf_p =
-                                               yytext_ptr + YY_MORE_ADJ;
+                                               yy_c_buf_p = yytext_ptr + offset;
                                                return EOF;
                                                }
 
@@ -1009,7 +1008,7 @@ int yyFlexLexer::yyinput()
                                        }
 
                                case EOB_ACT_CONTINUE_SCAN:
-                                       yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+                                       yy_c_buf_p = yytext_ptr + offset;
                                        break;
 
                                case EOB_ACT_LAST_MATCH:
@@ -1025,7 +1024,16 @@ int yyFlexLexer::yyinput()
                }
 
        c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
+
+       /* If we're doing %array, then we don't need to bother preserving
+        * yytext.  Ironically, not doing so is a win in later preserving
+        * yytext if we're doing yymore(), because we won't have this
+        * errant '\0' sitting in the middle of it.
+        */
+#ifdef yytext_ptr
        *yy_c_buf_p = '\0';     /* preserve yytext */
+#endif
+
        yy_hold_char = *++yy_c_buf_p;
 
 %% update BOL and yylineno