From: helly Date: Mon, 24 Mar 2008 13:13:28 +0000 (+0000) Subject: - Do not drinput in -r mode X-Git-Tag: 0.13.6~54 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c04a233018d8669ca1de805a0858bff3d02dd7bf;p=re2c - Do not drinput in -r mode --- diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc index 8b7c3490..38fee065 100644 --- a/re2c/bootstrap/scanner.cc +++ b/re2c/bootstrap/scanner.cc @@ -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 #include @@ -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(top - lim) < need) + if (static_cast(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'; diff --git a/re2c/scanner.re b/re2c/scanner.re index 97419535..c907ed2e 100644 --- a/re2c/scanner.re +++ b/re2c/scanner.re @@ -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(top - lim) < need) + if (static_cast(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';