From 286f8990e8a8fccc83defa2324405be97735ee2f Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Fri, 14 Aug 2015 14:29:19 +0100 Subject: [PATCH] Some more explicit casts in lexer fill procedure (found with [-Wsign-conversion]). Lexer tries to maintain certain layout of pointers to buffer. Buffer refilling procedure relies on that layout. --- re2c/src/parse/scanner.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/re2c/src/parse/scanner.cc b/re2c/src/parse/scanner.cc index b7c9e823..7073db73 100644 --- a/re2c/src/parse/scanner.cc +++ b/re2c/src/parse/scanner.cc @@ -332,7 +332,8 @@ void Scanner::fill (uint32_t need) const ptrdiff_t diff = tok - bot; if (diff > 0) { - memmove(bot, tok, top - tok); + const size_t move = static_cast (top - tok); + memmove (bot, tok, move); tok -= diff; ptr -= diff; cur -= diff; @@ -348,12 +349,13 @@ void Scanner::fill (uint32_t need) } if (top - lim < need) { - char *buf = new char[(lim - bot) + need]; + const size_t copy = static_cast (lim - bot); + char * buf = new char[copy + need]; if (!buf) { fatal("Out of memory"); } - memcpy(buf, bot, lim - bot); + memcpy (buf, bot, copy); tok = &buf[tok - bot]; ptr = &buf[ptr - bot]; cur = &buf[cur - bot]; -- 2.40.0