]> granicus.if.org Git - re2c/commitdiff
- Do not drinput in -r mode
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Mon, 24 Mar 2008 13:13:28 +0000 (13:13 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Mon, 24 Mar 2008 13:13:28 +0000 (13:13 +0000)
re2c/bootstrap/scanner.cc
re2c/scanner.re

index 8b7c34906d49211fd54bbe59c8fbb63c48fff885..38fee065791aeea8e74b6a9541f18dc89dcf6158 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.4.dev on Mon Mar 24 01:44:05 2008 */
+/* Generated by re2c 0.13.4.dev on Mon Mar 24 14:11:59 2008 */
 /* $Id$ */
 #include <stdlib.h>
 #include <string.h>
@@ -44,18 +44,25 @@ char *Scanner::fill(char *cursor, uint need)
 {
        if(!eof)
        {
-               uint cnt = tok - bot;
-               if(cnt)
+               uint cnt;
+               /* Do not get rid of anything when rFlag is active. Otherwise
+                * get rid of everything that was already handedout. */
+               if (!rFlag)
                {
-                       memmove(bot, tok, top - tok);
-                       tok = bot;
-                       ptr -= cnt;
-                       cursor -= cnt;
-                       pos -= cnt;
-                       lim -= cnt;
+                       cnt = tok - bot;
+                       if (cnt)
+                       {
+                               memmove(bot, tok, top - tok);
+                               tok = bot;
+                               ptr -= cnt;
+                               cursor -= cnt;
+                               pos -= cnt;
+                               lim -= cnt;
+                       }
                }
+               /* In crease buffer size. */
                need = MAX(need, BSIZE);
-               if(static_cast<uint>(top - lim) < need)
+               if (static_cast<uint>(top - lim) < need)
                {
                        char *buf = new char[(lim - bot) + need];
                        if (!buf)
@@ -72,8 +79,9 @@ char *Scanner::fill(char *cursor, uint need)
                        delete [] bot;
                        bot = buf;
                }
+               /* Append to buffer. */
                in.read(lim, need);
-               if((cnt = in.gcount()) != need)
+               if ((cnt = in.gcount()) != need)
                {
                        eof = &lim[cnt];
                        *eof++ = '\0';
index 9741953589499b48628d2ce80ba6f048584b9c91..c907ed2e1806c9f5f4df3494388168489f6830c5 100644 (file)
@@ -43,18 +43,25 @@ char *Scanner::fill(char *cursor, uint need)
 {
        if(!eof)
        {
-               uint cnt = tok - bot;
-               if(cnt)
+               uint cnt;
+               /* Do not get rid of anything when rFlag is active. Otherwise
+                * get rid of everything that was already handedout. */
+               if (!rFlag)
                {
-                       memmove(bot, tok, top - tok);
-                       tok = bot;
-                       ptr -= cnt;
-                       cursor -= cnt;
-                       pos -= cnt;
-                       lim -= cnt;
+                       cnt = tok - bot;
+                       if (cnt)
+                       {
+                               memmove(bot, tok, top - tok);
+                               tok = bot;
+                               ptr -= cnt;
+                               cursor -= cnt;
+                               pos -= cnt;
+                               lim -= cnt;
+                       }
                }
+               /* In crease buffer size. */
                need = MAX(need, BSIZE);
-               if(static_cast<uint>(top - lim) < need)
+               if (static_cast<uint>(top - lim) < need)
                {
                        char *buf = new char[(lim - bot) + need];
                        if (!buf)
@@ -71,8 +78,9 @@ char *Scanner::fill(char *cursor, uint need)
                        delete [] bot;
                        bot = buf;
                }
+               /* Append to buffer. */
                in.read(lim, need);
-               if((cnt = in.gcount()) != need)
+               if ((cnt = in.gcount()) != need)
                {
                        eof = &lim[cnt];
                        *eof++ = '\0';